Skip to content

Commit

Permalink
Merge pull request #169 from arkedge/feature/fix_small
Browse files Browse the repository at this point in the history
Pre Release (v4.0.0-beta.5): フォーマット微修正 / 変数名修正
  • Loading branch information
meltingrabbit authored Oct 26, 2023
2 parents 8f34b0f + 05c5029 commit 8e99ba4
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "4.0.0-beta.4"
version = "4.0.0-beta.5"

[workspace]
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion c2a_core_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ void C2A_core_main(void);
#define C2A_CORE_VER_MAJOR (4)
#define C2A_CORE_VER_MINOR (0)
#define C2A_CORE_VER_PATCH (0)
#define C2A_CORE_VER_PRE ("beta.4")
#define C2A_CORE_VER_PRE ("beta.5")

#endif
14 changes: 7 additions & 7 deletions component_driver/driver_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ CDS_ERR_CODE CDS_reset(ComponentDriverSuper* p_super)
p_super->hal_handler_id = HAL_HANDLER_ID_MAX; // FIXME: (*HAL_init_handlers[p_super->hal_handler_id])(p_super->hal_config) の様な使い方をするのでセグフォが起こる可能性があり
p_super->hal_config = NULL; // FIXME: NULL ポインタはこの関数が Reset 単体で使われるとマズい

p_super->config.settings.hal_rx_buffer_size_ = CDS_HAL_RX_BUFFER_SIZE;
p_super->config.settings.hal_rx_buffer_size_ = CDS_HAL_RX_BUFFER_SIZE;
p_super->config.settings.should_monitor_for_rx_disruption_ = 0;
p_super->config.settings.time_threshold_for_rx_disruption_ = 60 * 1000; // この値はよく考えること

Expand Down Expand Up @@ -578,8 +578,8 @@ static int CDS_tx_(ComponentDriverSuper* p_super, uint8_t stream)
#endif

ret = (*HAL_tx_handlers[p_super->hal_handler_id])(p_super->hal_config,
p_stream_config->settings.tx_frame_,
(int)p_stream_config->settings.tx_frame_size_);
p_stream_config->settings.tx_frame_,
(int)p_stream_config->settings.tx_frame_size_);

if (ret != 0) return ret;
return CDS_ERR_CODE_OK;
Expand Down Expand Up @@ -608,8 +608,8 @@ static int CDS_rx_(ComponentDriverSuper* p_super)
if (flag == 0) return 0;

rec_data_len = (*HAL_rx_handlers[p_super->hal_handler_id])(p_super->hal_config,
CDS_hal_rx_buffer_,
p_super->config.settings.hal_rx_buffer_size_);
CDS_hal_rx_buffer_,
p_super->config.settings.hal_rx_buffer_size_);

#ifdef CDS_DEBUG
Printf("DS: rx_\n");
Expand Down Expand Up @@ -1204,7 +1204,7 @@ static CDS_ERR_CODE CDS_reset_stream_config_(CDS_StreamConfig* p_stream_config)
p->settings.data_analyzer_ = CDS_data_analyzer_dummy_;

// CDS_StreamSendStatus の初期化
p->info.send_status_.status_code = CDS_STREAM_SEND_STATUS_DISABLE;
p->info.send_status_.status_code = CDS_STREAM_SEND_STATUS_DISABLE;
p->info.send_status_.ret_from_hal_tx = 0;

// CDS_StreamRecStatus の初期化
Expand Down Expand Up @@ -1321,7 +1321,7 @@ uint16_t CDSC_get_hal_rx_buffer_size(const ComponentDriverSuper* p_super)
}

CDS_ERR_CODE CDSC_set_hal_rx_buffer_size(ComponentDriverSuper* p_super,
const uint16_t hal_rx_buffer_size)
const uint16_t hal_rx_buffer_size)
{
if (hal_rx_buffer_size > CDS_HAL_RX_BUFFER_SIZE) return CDS_ERR_CODE_ERR;
p_super->config.settings.hal_rx_buffer_size_ = hal_rx_buffer_size;
Expand Down
25 changes: 12 additions & 13 deletions component_driver/driver_super.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#define CDS_STREAM_MAX (3) /*!< CDS_StreamConfig の最大数
uint8_t を想定 */
#define CDS_HAL_RX_BUFFER_SIZE (1024) /*!< HAL_rx_handlers で受信するときの一次バッファ
#define CDS_HAL_RX_BUFFER_SIZE (1024) /*!< HAL_rx_handlers で受信するときの一次バッファ
HAL_rx_handlers から受信できる最大数を規定する
OBC の物理的な信号ラインのバッファサイズ以上とするともっともパフォーマンスが出る */

Expand Down Expand Up @@ -114,7 +114,7 @@ typedef enum
*/
typedef enum
{
CDS_ERR_CODE_OK = 0, //!< 返り値は継承先や IF 先で上書きされるため,OK は 0 であることが必須
CDS_ERR_CODE_OK = 0, //!< 返り値は継承先や HAL 先で上書きされるため,OK は 0 であることが必須
CDS_ERR_CODE_ERR = 1
} CDS_ERR_CODE;

Expand All @@ -131,11 +131,11 @@ typedef enum

/**
* @struct CDS_RecStatus
* @brief IF 受信状況
* @brief HAL 受信状況
*/
typedef struct
{
int ret_from_hal_rx; //!< HAL_rx_handlers の返り値
int ret_from_hal_rx; //!< HAL_rx_handlers の返り値
CDS_RX_DISRUPTION_STATUS_CODE rx_disruption_status; //!< 受信途絶判定
} CDS_RecStatus;

Expand All @@ -160,7 +160,7 @@ typedef enum
typedef struct
{
CDS_STREAM_SEND_STATUS_CODE status_code; //!< status
int ret_from_hal_tx; //!< HAL_tx_handlers の返り値
int ret_from_hal_tx; //!< HAL_tx_handlers の返り値
// 今後詳細情報を拡張するなら,ここに入れる
} CDS_StreamSendStatus;

Expand Down Expand Up @@ -233,14 +233,13 @@ typedef struct
* @struct CDS_Config
* @brief ComponentDriverSuper の設定
*
* 各IFはこれを継承してつかう.
* CDS_Config のメンバはすべての ComponentDriver から非公開とし, getter / setter でアクセスする
*/
typedef struct
{
struct
{
uint16_t hal_rx_buffer_size_; /*!< HAL_rx_handlers で受信するときの一次バッファのサイズ
uint16_t hal_rx_buffer_size_; /*!< HAL_rx_handlers で受信するときの一次バッファのサイズ
DS ではまず HAL_rx_handlers を全 ComponentDriver 共通の一次バッファにコピーした後,
CDS_StreamRecBuffer に push して解析していく.
HAL_rx_handlers で読み込む量が多すぎると,CDS_StreamRecBuffer に収まりきらないことがあるので,
Expand Down Expand Up @@ -402,13 +401,13 @@ struct CDS_StreamConfig
/**
* @struct ComponentDriverSuper
* @brief ComponentDriverSuper の設定
* 各 IF はこれを継承してつかう.
* 各 Driver はこれを継承してつかう.
*/
struct ComponentDriverSuper
{
// 【継承先まで公開】
HAL_HANDLER_ID hal_handler_id; //!< 継承先の機器の使用 IF
void* hal_config; //!< IF 設定
HAL_HANDLER_ID hal_handler_id; //!< 継承先の機器の使用 HAL
void* hal_config; //!< HAL 設定

CDS_Config config; //!< ComponentDriverSuper の設定

Expand All @@ -430,7 +429,7 @@ struct ComponentDriverSuper
* デフォルト値の上書きは load_init_setting で行う
* @note ComponentDriverSuper を使用する時は起動時に必ず実施すること
* @param p_super: 初期化する ComponentDriverSuper 構造体へのポインタ
* @param hal_config: 初期化する ComponentDriverで用いられている IF の config 構造体
* @param hal_config: 初期化する ComponentDriverで用いられている HAL の config 構造体
* @param rx_buffer: 初期化する ComponentDriverSuper の stream 0 で用いられるフレーム受信バッファ
* @param load_init_setting: ComponentDriverSuper の初期設定ロード関数ポインタ
* @return CDS_ERR_CODE
Expand All @@ -448,7 +447,7 @@ CDS_ERR_CODE CDS_init(ComponentDriverSuper* p_super,
* デフォルト値の上書きは load_init_setting で行う
* @note ComponentDriverSuper を使用する時は起動時に必ず実施すること
* @param p_super: 初期化する ComponentDriverSuper 構造体へのポインタ
* @param hal_config: 初期化する ComponentDriverで用いられている IF の config 構造体
* @param hal_config: 初期化する ComponentDriverで用いられている HAL の config 構造体
* @param rx_buffers: 初期化する ComponentDriverSuper で用いられるフレーム受信バッファ.使用しない stream は NULL を設定しておく
* @param load_init_setting: ComponentDriverSuper の初期設定ロード関数ポインタ
* @return CDS_ERR_CODE
Expand Down Expand Up @@ -544,7 +543,7 @@ CDS_ERR_CODE CDS_send_req_tlm_cmd(ComponentDriverSuper* p_super, uint8_t stream)
// ###### CDS_Config Getter/Setter of Settings ######
uint16_t CDSC_get_hal_rx_buffer_size(const ComponentDriverSuper* p_super);
CDS_ERR_CODE CDSC_set_hal_rx_buffer_size(ComponentDriverSuper* p_super,
const uint16_t hal_rx_buffer_size);
const uint16_t hal_rx_buffer_size);
uint8_t CDSC_get_should_monitor_for_rx_disruption(const ComponentDriverSuper* p_super);
void CDSC_enable_monitor_for_rx_disruption(ComponentDriverSuper* p_super);
void CDSC_disable_monitor_for_rx_disruption(ComponentDriverSuper* p_super);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "./driver_super_params.h"

#define CDS_STREAM_REC_BUFFER_SIZE_DEFAULT (CDS_HAL_RX_BUFFER_SIZE * 2) /*!< CDS_StreamRecBuffer のバッファサイズのデフォルト値
#define CDS_STREAM_REC_BUFFER_SIZE_DEFAULT (CDS_HAL_RX_BUFFER_SIZE * 2) /*!< CDS_StreamRecBuffer のバッファサイズのデフォルト値
UART などの非同期通信はメモリに余力があれば CDS_HAL_RX_BUFFER_SIZE * 2 を推奨
詳細は dirver_super.c の @note を参照 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#undef CDS_HAL_RX_BUFFER_SIZE

#define CDS_STREAM_MAX (3)
#define CDS_HAL_RX_BUFFER_SIZE (1024)
#define CDS_HAL_RX_BUFFER_SIZE (1024)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#include <stddef.h>

int (*HAL_init_handlers[])(void* my_if) = { CCSDS_init, UART_init};
int (*HAL_init_handlers[])(void* config) = { CCSDS_init, UART_init };

int (*HAL_rx_handlers[])(void* my_if, void* data_v, int buffer_size) = { CCSDS_rx, UART_rx};
int (*HAL_rx_handlers[])(void* config, void* buffer, int buffer_size) = { CCSDS_rx, UART_rx };

int (*HAL_tx_handlers[])(void* my_if, void* data_v, int data_size) = { CCSDS_tx, UART_tx};
int (*HAL_tx_handlers[])(void* config, void* data, int data_size) = { CCSDS_tx, UART_tx };

int (*HAL_reopen_handlers[])(void* my_if, int reason) = { CCSDS_reopen, UART_reopen};
int (*HAL_reopen_handlers[])(void* config, int reason) = { CCSDS_reopen, UART_reopen };

#pragma section
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

typedef enum
{
CCSDS,
UART,
HAL_HANDLER_ID_CCSDS,
HAL_HANDLER_ID_UART,
HAL_HANDLER_ID_MAX
} HAL_HANDLER_ID;

Expand All @@ -17,9 +17,9 @@ typedef enum
IF_REOPEN_TLM_DISRUPTION = 100
} HAL_HANDLER_REOPEN_REASON;

extern int (*HAL_init_handlers[] )(void* my_if);
extern int (*HAL_rx_handlers[] )(void* my_if, void* data_v, int buffer_size);
extern int (*HAL_tx_handlers[] )(void* my_if, void* data_v, int data_size);
extern int (*HAL_reopen_handlers[])(void* my_if, int reason);
extern int (*HAL_init_handlers[] )(void* config);
extern int (*HAL_rx_handlers[] )(void* config, void* buffer, int buffer_size);
extern int (*HAL_tx_handlers[] )(void* config, void* data, int data_size);
extern int (*HAL_reopen_handlers[])(void* config, int reason);

#endif
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/component_driver/aocs/aobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static CDS_ERR_CODE AOBC_load_driver_super_init_settings_(ComponentDriverSuper*
{
CDS_StreamConfig* p_stream_config;

p_super->hal_handler_id = UART;
p_super->hal_handler_id = HAL_HANDLER_ID_UART;

// stream は 0 のみ
p_stream_config = &(p_super->stream_config[AOBC_STREAM_TLM_CMD]);
Expand Down
4 changes: 2 additions & 2 deletions examples/mobc/src/src_user/component_driver/com/gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ CDS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver,

static CDS_ERR_CODE GS_load_ccsds_driver_super_init_settings_(ComponentDriverSuper* p_super)
{
p_super->hal_handler_id = CCSDS;
p_super->hal_handler_id = HAL_HANDLER_ID_CCSDS;
GS_load_default_driver_super_init_settings_(p_super);

return CDS_ERR_CODE_OK;
}

static CDS_ERR_CODE GS_load_uart_driver_super_init_settings_(ComponentDriverSuper* p_super)
{
p_super->hal_handler_id = UART;
p_super->hal_handler_id = HAL_HANDLER_ID_UART;
GS_load_default_driver_super_init_settings_(p_super);

return CDS_ERR_CODE_OK;
Expand Down
2 changes: 1 addition & 1 deletion examples/mobc/src/src_user/component_driver/com/gs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef struct
struct
{
CDS_ERR_CODE rec_status; //!< ComponentDriverSuper からの受信結果
int ret_from_hal_rx; //!< UART or CCSDS からの返り値
int ret_from_hal_rx; //!< UART or CCSDS からの返り値
CCP_DEST_TYPE last_dest_type; //!< 最後に受信したパケットの dest type
cycle_t last_rec_time; //!< 最後に受信した時刻
PH_ACK cmd_ack; //!< 受信した CMD の実行結果
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static CDS_ERR_CODE UART_TEST_load_driver_super_init_settings_(ComponentDriverSu
{
CDS_StreamConfig* p_stream_config;

p_super->hal_handler_id = UART;
p_super->hal_handler_id = HAL_HANDLER_ID_UART;

// stream0の設定
p_stream_config = &(p_super->stream_config[UART_TEST_STREAM_FIX]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "./driver_super_params.h"

#define CDS_STREAM_REC_BUFFER_SIZE_DEFAULT (CDS_HAL_RX_BUFFER_SIZE * 2) /*!< CDS_StreamRecBuffer のバッファサイズのデフォルト値
#define CDS_STREAM_REC_BUFFER_SIZE_DEFAULT (CDS_HAL_RX_BUFFER_SIZE * 2) /*!< CDS_StreamRecBuffer のバッファサイズのデフォルト値
UART などの非同期通信はメモリに余力があれば CDS_HAL_RX_BUFFER_SIZE * 2 を推奨
詳細は dirver_super.c の @note を参照 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#include <stddef.h>

int (*HAL_init_handlers[])(void* my_if) = { UART_init};
int (*HAL_init_handlers[])(void* config) = { UART_init };

int (*HAL_rx_handlers[])(void* my_if, void* data_v, int buffer_size) = { UART_rx};
int (*HAL_rx_handlers[])(void* config, void* buffer, int buffer_size) = { UART_rx };

int (*HAL_tx_handlers[])(void* my_if, void* data_v, int data_size) = { UART_tx};
int (*HAL_tx_handlers[])(void* config, void* data, int data_size) = { UART_tx };

int (*HAL_reopen_handlers[])(void* my_if, int reason) = { UART_reopen};
int (*HAL_reopen_handlers[])(void* config, int reason) = { UART_reopen };

#pragma section
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

typedef enum
{
UART,
HAL_HANDLER_ID_UART,
HAL_HANDLER_ID_MAX
} HAL_HANDLER_ID;

Expand All @@ -16,9 +16,9 @@ typedef enum
IF_REOPEN_TLM_DISRUPTION = 100
} HAL_HANDLER_REOPEN_REASON;

extern int (*HAL_init_handlers[] )(void* my_if);
extern int (*HAL_rx_handlers[] )(void* my_if, void* data_v, int buffer_size);
extern int (*HAL_tx_handlers[] )(void* my_if, void* data_v, int data_size);
extern int (*HAL_reopen_handlers[])(void* my_if, int reason);
extern int (*HAL_init_handlers[] )(void* config);
extern int (*HAL_rx_handlers[] )(void* config, void* buffer, int buffer_size);
extern int (*HAL_tx_handlers[] )(void* config, void* data, int data_size);
extern int (*HAL_reopen_handlers[])(void* config, int reason);

#endif
2 changes: 1 addition & 1 deletion examples/subobc/src/src_user/component_driver/etc/mobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static CDS_ERR_CODE MOBC_load_driver_super_init_settings_(ComponentDriverSuper*
{
CDS_StreamConfig* p_stream_config;

p_super->hal_handler_id = UART;
p_super->hal_handler_id = HAL_HANDLER_ID_UART;

// stream は 0 のみ
p_stream_config = &(p_super->stream_config[MOBC_STREAM_TLM_CMD]);
Expand Down

0 comments on commit 8e99ba4

Please sign in to comment.