diff --git a/examples/mobc/CMakeLists.txt b/examples/mobc/CMakeLists.txt index 128c97323..626253f90 100644 --- a/examples/mobc/CMakeLists.txt +++ b/examples/mobc/CMakeLists.txt @@ -58,7 +58,7 @@ add_definitions("-DGIT_REVISION_C2A_USER_SHORT=0x${GIT_REVISION_C2A_USER_SHORT}" add_subdirectory(${C2A_CORE_DIR}) add_subdirectory(${C2A_USER_DIR}/applications) -add_subdirectory(${C2A_USER_DIR}/driver) +add_subdirectory(${C2A_USER_DIR}/component_driver) add_subdirectory(${C2A_USER_DIR}/hal) add_subdirectory(${C2A_USER_DIR}/library) add_subdirectory(${C2A_USER_DIR}/Settings) diff --git a/examples/mobc/src/src_user/Settings/DriverSuper/driver_super_params.h b/examples/mobc/src/src_user/Settings/DriverSuper/driver_super_params.h deleted file mode 100644 index 1599d14dc..000000000 --- a/examples/mobc/src/src_user/Settings/DriverSuper/driver_super_params.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @file - * @brief DriverSuperパラメタのオーバーライド用ヘッダー - */ -#ifndef DRIVER_SUPER_PARAMS_H_ -#define DRIVER_SUPER_PARAMS_H_ - -#undef DS_STREAM_MAX -#undef DS_IF_RX_BUFFER_SIZE - -#define DS_STREAM_MAX (3) -#define DS_IF_RX_BUFFER_SIZE (1024) - -#endif diff --git a/examples/mobc/src/src_user/Settings/Modes/Transitions/sl_initial.c b/examples/mobc/src/src_user/Settings/Modes/Transitions/sl_initial.c index 952e4e7a2..7b5fa6020 100644 --- a/examples/mobc/src/src_user/Settings/Modes/Transitions/sl_initial.c +++ b/examples/mobc/src/src_user/Settings/Modes/Transitions/sl_initial.c @@ -4,7 +4,7 @@ #include "../../../tlm_cmd/block_command_definitions.h" #include "../../../tlm_cmd/command_definitions.h" -#include "../../../driver/com/gs.h" +#include "../../../component_driver/com/gs.h" #include #include diff --git a/examples/mobc/src/src_user/Settings/DriverSuper/driver_buffer_define.h b/examples/mobc/src/src_user/Settings/component_driver_super/driver_buffer_define.h similarity index 69% rename from examples/mobc/src/src_user/Settings/DriverSuper/driver_buffer_define.h rename to examples/mobc/src/src_user/Settings/component_driver_super/driver_buffer_define.h index 03ef3305a..3ba66baed 100644 --- a/examples/mobc/src/src_user/Settings/DriverSuper/driver_buffer_define.h +++ b/examples/mobc/src/src_user/Settings/component_driver_super/driver_buffer_define.h @@ -7,8 +7,8 @@ #include "./driver_super_params.h" -#define DS_STREAM_REC_BUFFER_SIZE_DEFAULT (DS_IF_RX_BUFFER_SIZE * 2) /*!< DS_StreamRecBuffer のバッファサイズのデフォルト値 - UART などの非同期通信はメモリに余力があれば DS_IF_RX_BUFFER_SIZE * 2 を推奨 +#define CDS_STREAM_REC_BUFFER_SIZE_DEFAULT (CDS_IF_RX_BUFFER_SIZE * 2) /*!< CDS_StreamRecBuffer のバッファサイズのデフォルト値 + UART などの非同期通信はメモリに余力があれば CDS_IF_RX_BUFFER_SIZE * 2 を推奨 詳細は dirver_super.c の @note を参照 */ #endif diff --git a/examples/mobc/src/src_user/Settings/component_driver_super/driver_super_params.h b/examples/mobc/src/src_user/Settings/component_driver_super/driver_super_params.h new file mode 100644 index 000000000..e233183a1 --- /dev/null +++ b/examples/mobc/src/src_user/Settings/component_driver_super/driver_super_params.h @@ -0,0 +1,14 @@ +/** + * @file + * @brief ComponentDriverSuperパラメタのオーバーライド用ヘッダー + */ +#ifndef DRIVER_SUPER_PARAMS_H_ +#define DRIVER_SUPER_PARAMS_H_ + +#undef CDS_STREAM_MAX +#undef CDS_IF_RX_BUFFER_SIZE + +#define CDS_STREAM_MAX (3) +#define CDS_IF_RX_BUFFER_SIZE (1024) + +#endif diff --git a/examples/mobc/src/src_user/applications/driver_instances/di_aobc.c b/examples/mobc/src/src_user/applications/driver_instances/di_aobc.c index c84ba77c3..3b5521310 100644 --- a/examples/mobc/src/src_user/applications/driver_instances/di_aobc.c +++ b/examples/mobc/src/src_user/applications/driver_instances/di_aobc.c @@ -6,12 +6,12 @@ */ #include "di_aobc.h" -#include "../../driver/aocs/aobc.h" +#include "../../component_driver/aocs/aobc.h" #include "../../tlm_cmd/user_packet_handler.h" #include #include #include "../../Settings/port_config.h" -#include "../../Settings/DriverSuper/driver_buffer_define.h" +#include "../../Settings/component_driver_super/driver_buffer_define.h" #include static RESULT DI_AOBC_init_(void); @@ -27,8 +27,8 @@ static CommandDispatcher DI_AOBC_cdis_; const CommandDispatcher* const DI_AOBC_cdis = &DI_AOBC_cdis_; // バッファ -static DS_StreamRecBuffer DI_AOBC_rx_buffer_; -static uint8_t DI_AOBC_rx_buffer_allocation_[DS_STREAM_REC_BUFFER_SIZE_DEFAULT]; +static CDS_StreamRecBuffer DI_AOBC_rx_buffer_; +static uint8_t DI_AOBC_rx_buffer_allocation_[CDS_STREAM_REC_BUFFER_SIZE_DEFAULT]; AppInfo DI_AOBC_update(void) @@ -39,21 +39,21 @@ AppInfo DI_AOBC_update(void) static RESULT DI_AOBC_init_(void) { - DS_ERR_CODE ret1; - DS_INIT_ERR_CODE ret2; + CDS_ERR_CODE ret1; + CDS_INIT_ERR_CODE ret2; RESULT err = RESULT_OK; - ret1 = DS_init_stream_rec_buffer(&DI_AOBC_rx_buffer_, + ret1 = CDS_init_stream_rec_buffer(&DI_AOBC_rx_buffer_, DI_AOBC_rx_buffer_allocation_, sizeof(DI_AOBC_rx_buffer_allocation_)); - if (ret1 != DS_ERR_CODE_OK) + if (ret1 != CDS_ERR_CODE_OK) { Printf("AOBC buffer init Failed ! %d \n", ret1); err = RESULT_ERR; } ret2 = AOBC_init(&aobc_driver_, PORT_CH_RS422_AOBC, &DI_AOBC_rx_buffer_); - if (ret2 != DS_INIT_OK) + if (ret2 != CDS_INIT_OK) { Printf("AOBC init Failed ! %d \n", ret2); err = RESULT_ERR; @@ -98,7 +98,7 @@ static RESULT DI_AOBC_cmd_dispatcher_(void) CCP_CmdRet DI_AOBC_dispatch_command(const CommonCmdPacket* packet) { - DS_CMD_ERR_CODE ret; + CDS_CMD_ERR_CODE ret; CommonCmdPacket* pckt = (CommonCmdPacket*)packet; // const_cast // ここで CCP_DEST_TYPE を宛先で受理できるように変更(なので const cast が発生している...) @@ -121,7 +121,7 @@ CCP_CmdRet DI_AOBC_dispatch_command(const CommonCmdPacket* packet) ret = AOBC_send_cmd(&aobc_driver_, pckt); // FIXME: ここも一旦握りつぶす(後で直す) - return DS_conv_cmd_err_to_ccp_cmd_ret(ret); + return CDS_conv_cmd_err_to_ccp_cmd_ret(ret); } diff --git a/examples/mobc/src/src_user/applications/driver_instances/di_aobc.h b/examples/mobc/src/src_user/applications/driver_instances/di_aobc.h index 37350be5b..cbc227c0f 100644 --- a/examples/mobc/src/src_user/applications/driver_instances/di_aobc.h +++ b/examples/mobc/src/src_user/applications/driver_instances/di_aobc.h @@ -6,9 +6,9 @@ #ifndef DI_AOBC_H_ #define DI_AOBC_H_ -#include "../../driver/aocs/aobc.h" -#include "../../driver/aocs/aobc_command_definitions.h" -#include "../../driver/aocs/aobc_telemetry_definitions.h" +#include "../../component_driver/aocs/aobc.h" +#include "../../component_driver/aocs/aobc_command_definitions.h" +#include "../../component_driver/aocs/aobc_telemetry_definitions.h" #include #include #include @@ -36,7 +36,7 @@ AppInfo DI_AOBC_cmd_dispatcher(void); * @note この関数を呼んでも良いのは,user_packet_handler のみ! * @param packet: CommonCmdPacket packet * @retval CCP_CmdRet{CCP_EXEC_SUCCESS, *}: 無事に転送された - * @retval それ以外: 転送失敗(DS_CMD_ERR_CODE を CCP_EXEC_STS に変換して返す.詳細エラーは DriverSuper を参照) + * @retval それ以外: 転送失敗(CDS_CMD_ERR_CODE を CCP_EXEC_STS に変換して返す.詳細エラーは ComponentDriverSuper を参照) */ CCP_CmdRet DI_AOBC_dispatch_command(const CommonCmdPacket* packet); diff --git a/examples/mobc/src/src_user/applications/driver_instances/di_gs.c b/examples/mobc/src/src_user/applications/driver_instances/di_gs.c index b0333576b..bd7de62fc 100644 --- a/examples/mobc/src/src_user/applications/driver_instances/di_gs.c +++ b/examples/mobc/src/src_user/applications/driver_instances/di_gs.c @@ -8,9 +8,9 @@ #include #include #include -#include "../../driver/com/gs_validate.h" +#include "../../component_driver/com/gs_validate.h" #include "../../Settings/port_config.h" -#include "../../Settings/DriverSuper/driver_buffer_define.h" +#include "../../Settings/component_driver_super/driver_buffer_define.h" static RESULT DI_GS_init_(void); @@ -34,33 +34,33 @@ static DI_GS_TlmPacketHandler DI_GS_rp_tlm_packet_handler_; const DI_GS_TlmPacketHandler* const DI_GS_rp_tlm_packet_handler = &DI_GS_rp_tlm_packet_handler_; // バッファ -static DS_StreamRecBuffer DI_GS_ccsds_rx_buffer_[GS_RX_HEADER_NUM]; -static uint8_t DI_GS_ccsds_rx_buffer_allocation_[GS_RX_HEADER_NUM][DS_STREAM_REC_BUFFER_SIZE_DEFAULT]; -static DS_StreamRecBuffer DI_GS_uart_rx_buffer_[GS_RX_HEADER_NUM]; -static uint8_t DI_GS_uart_rx_buffer_allocation_[GS_RX_HEADER_NUM][DS_STREAM_REC_BUFFER_SIZE_DEFAULT]; +static CDS_StreamRecBuffer DI_GS_ccsds_rx_buffer_[GS_RX_HEADER_NUM]; +static uint8_t DI_GS_ccsds_rx_buffer_allocation_[GS_RX_HEADER_NUM][CDS_STREAM_REC_BUFFER_SIZE_DEFAULT]; +static CDS_StreamRecBuffer DI_GS_uart_rx_buffer_[GS_RX_HEADER_NUM]; +static uint8_t DI_GS_uart_rx_buffer_allocation_[GS_RX_HEADER_NUM][CDS_STREAM_REC_BUFFER_SIZE_DEFAULT]; static RESULT DI_GS_init_(void) { int stream; - DS_INIT_ERR_CODE ret; - DS_StreamRecBuffer* ccsds_rx_buffers[DS_STREAM_MAX]; - DS_StreamRecBuffer* uart_rx_buffers[DS_STREAM_MAX]; - DS_nullify_stream_rec_buffers(ccsds_rx_buffers); - DS_nullify_stream_rec_buffers(uart_rx_buffers); + CDS_INIT_ERR_CODE ret; + CDS_StreamRecBuffer* ccsds_rx_buffers[CDS_STREAM_MAX]; + CDS_StreamRecBuffer* uart_rx_buffers[CDS_STREAM_MAX]; + CDS_nullify_stream_rec_buffers(ccsds_rx_buffers); + CDS_nullify_stream_rec_buffers(uart_rx_buffers); - // GS_RX_HEADER_NUM > DS_STREAM_MAX のアサーションは gs.c でやっているのでここではしない + // GS_RX_HEADER_NUM > CDS_STREAM_MAX のアサーションは gs.c でやっているのでここではしない for (stream = 0; stream < GS_RX_HEADER_NUM; ++stream) { - DS_ERR_CODE ret1; - DS_ERR_CODE ret2; - ret1 = DS_init_stream_rec_buffer(&DI_GS_ccsds_rx_buffer_[stream], + CDS_ERR_CODE ret1; + CDS_ERR_CODE ret2; + ret1 = CDS_init_stream_rec_buffer(&DI_GS_ccsds_rx_buffer_[stream], DI_GS_ccsds_rx_buffer_allocation_[stream], sizeof(DI_GS_ccsds_rx_buffer_allocation_[stream])); - ret2 = DS_init_stream_rec_buffer(&DI_GS_uart_rx_buffer_[stream], + ret2 = CDS_init_stream_rec_buffer(&DI_GS_uart_rx_buffer_[stream], DI_GS_uart_rx_buffer_allocation_[stream], sizeof(DI_GS_uart_rx_buffer_allocation_[stream])); - if (ret1 != DS_ERR_CODE_OK || ret2 != DS_ERR_CODE_OK) + if (ret1 != CDS_ERR_CODE_OK || ret2 != CDS_ERR_CODE_OK) { Printf("GS buffer init Failed ! %d, %d \n", ret1, ret2); return RESULT_ERR; @@ -71,7 +71,7 @@ static RESULT DI_GS_init_(void) ret = GS_init(&gs_driver_, PORT_CH_RS422_MOBC_EXT, ccsds_rx_buffers, uart_rx_buffers); - if (ret != DS_INIT_OK) + if (ret != CDS_INIT_OK) { Printf("!! GS Init Error %d !!\n", ret); return RESULT_ERR; diff --git a/examples/mobc/src/src_user/applications/driver_instances/di_gs.h b/examples/mobc/src/src_user/applications/driver_instances/di_gs.h index ec9a2d934..f250675d4 100644 --- a/examples/mobc/src/src_user/applications/driver_instances/di_gs.h +++ b/examples/mobc/src/src_user/applications/driver_instances/di_gs.h @@ -7,7 +7,7 @@ #include -#include "../../driver/com/gs.h" +#include "../../component_driver/com/gs.h" #include "../../tlm_cmd/ccsds/tcp_to_m_pdu.h" #include "../../tlm_cmd/ccsds/vcdu.h" #include diff --git a/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.c b/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.c index ca8658359..dc7303deb 100644 --- a/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.c +++ b/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.c @@ -1,14 +1,14 @@ #pragma section REPRO /** * @file - * @brief UART と DriverSuper テスト用 + * @brief UART と ComponentDriverSuper テスト用 */ #include "di_uart_test.h" #include // for NULL #include #include #include "../../Settings/port_config.h" -#include "../../Settings/DriverSuper/driver_buffer_define.h" +#include "../../Settings/component_driver_super/driver_buffer_define.h" #include static RESULT UART_TEST_init_by_AM_(void); @@ -25,10 +25,10 @@ static UART_TEST_Driver uart_test_driver_; const UART_TEST_Driver* const uart_test_driver = &uart_test_driver_; // バッファ -static DS_StreamRecBuffer DI_UART_TEST_rx_buffer_0_; -static DS_StreamRecBuffer DI_UART_TEST_rx_buffer_1_; -static uint8_t DI_UART_TEST_rx_buffer_allocation_0_[DS_STREAM_REC_BUFFER_SIZE_DEFAULT]; -static uint8_t DI_UART_TEST_rx_buffer_allocation_1_[DS_STREAM_REC_BUFFER_SIZE_DEFAULT]; +static CDS_StreamRecBuffer DI_UART_TEST_rx_buffer_0_; +static CDS_StreamRecBuffer DI_UART_TEST_rx_buffer_1_; +static uint8_t DI_UART_TEST_rx_buffer_allocation_0_[CDS_STREAM_REC_BUFFER_SIZE_DEFAULT]; +static uint8_t DI_UART_TEST_rx_buffer_allocation_1_[CDS_STREAM_REC_BUFFER_SIZE_DEFAULT]; // !!!!!!!!!! 注意 !!!!!!!!!! @@ -49,27 +49,27 @@ static RESULT UART_TEST_init_by_AM_(void) static void UART_TEST_init_(void) { - DS_ERR_CODE ret1; - DS_INIT_ERR_CODE ret2; - DS_StreamRecBuffer* rx_buffers[DS_STREAM_MAX]; - DS_nullify_stream_rec_buffers(rx_buffers); + CDS_ERR_CODE ret1; + CDS_INIT_ERR_CODE ret2; + CDS_StreamRecBuffer* rx_buffers[CDS_STREAM_MAX]; + CDS_nullify_stream_rec_buffers(rx_buffers); - ret1 = DS_init_stream_rec_buffer(&DI_UART_TEST_rx_buffer_0_, + ret1 = CDS_init_stream_rec_buffer(&DI_UART_TEST_rx_buffer_0_, DI_UART_TEST_rx_buffer_allocation_0_, sizeof(DI_UART_TEST_rx_buffer_allocation_0_)); - if (ret1 != DS_ERR_CODE_OK) + if (ret1 != CDS_ERR_CODE_OK) { Printf("UART_TEST buffer0 init Failed ! %d \n", ret1); } - ret1 = DS_init_stream_rec_buffer(&DI_UART_TEST_rx_buffer_1_, + ret1 = CDS_init_stream_rec_buffer(&DI_UART_TEST_rx_buffer_1_, DI_UART_TEST_rx_buffer_allocation_1_, sizeof(DI_UART_TEST_rx_buffer_allocation_1_)); - if (ret1 != DS_ERR_CODE_OK) + if (ret1 != CDS_ERR_CODE_OK) { Printf("UART_TEST buffer1 init Failed ! %d \n", ret1); } - if (DS_STREAM_MAX < 2) + if (CDS_STREAM_MAX < 2) { Printf("UART_TEST init Failed ! Lack of streams \n"); return; @@ -79,7 +79,7 @@ static void UART_TEST_init_(void) rx_buffers[1] = &DI_UART_TEST_rx_buffer_1_; ret2 = UART_TEST_init(&uart_test_driver_, PORT_CH_UART_TEST, rx_buffers); - if (ret2 != DS_INIT_OK) + if (ret2 != CDS_INIT_OK) { Printf("UART_TEST init Failed! Err:%d \n", ret2); } @@ -92,7 +92,7 @@ static void UART_TEST_init_(void) static RESULT UART_TEST_update_(void) { - DS_REC_ERR_CODE ret; + CDS_REC_ERR_CODE ret; ret = UART_TEST_rec(&uart_test_driver_); @@ -126,12 +126,12 @@ CCP_CmdRet Cmd_UART_TEST_SEND_TEST(const CommonCmdPacket* packet) { const uint8_t* param = CCP_get_param_head(packet); uint8_t id; - DS_CMD_ERR_CODE ret; + CDS_CMD_ERR_CODE ret; id = param[0]; ret = UART_TEST_send(&uart_test_driver_, id); - return DS_conv_cmd_err_to_ccp_cmd_ret(ret); + return CDS_conv_cmd_err_to_ccp_cmd_ret(ret); } #pragma section diff --git a/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.h b/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.h index 496b87e7c..ac7d65dfa 100644 --- a/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.h +++ b/examples/mobc/src/src_user/applications/driver_instances/di_uart_test.h @@ -1,11 +1,11 @@ /** * @file - * @brief UART と DriverSuper テスト用 + * @brief UART と ComponentDriverSuper テスト用 */ #ifndef DI_UART_TEST_H_ #define DI_UART_TEST_H_ -#include "../../driver/etc/uart_test.h" +#include "../../component_driver/etc/uart_test.h" #include #include diff --git a/examples/mobc/src/src_user/driver/CMakeLists.txt b/examples/mobc/src/src_user/component_driver/CMakeLists.txt similarity index 100% rename from examples/mobc/src/src_user/driver/CMakeLists.txt rename to examples/mobc/src/src_user/component_driver/CMakeLists.txt diff --git a/examples/mobc/src/src_user/driver/aocs/aobc.c b/examples/mobc/src/src_user/component_driver/aocs/aobc.c similarity index 58% rename from examples/mobc/src/src_user/driver/aocs/aobc.c rename to examples/mobc/src/src_user/component_driver/aocs/aobc.c index 84e85c6b3..8e8d2c310 100644 --- a/examples/mobc/src/src_user/driver/aocs/aobc.c +++ b/examples/mobc/src/src_user/component_driver/aocs/aobc.c @@ -9,8 +9,8 @@ #include "./aobc_telemetry_buffer.h" #include #include -#include -#include +#include +#include #include #define AOBC_STREAM_TLM_CMD (0) //!< テレコマで使うストリーム @@ -19,13 +19,13 @@ static uint8_t AOBC_tx_frame_[EB90_FRAME_HEADER_SIZE + CTCP_MAX_LEN + EB90_FRAME_FOOTER_SIZE]; -static DS_ERR_CODE AOBC_load_driver_super_init_settings_(DriverSuper* p_super); -static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, +static CDS_ERR_CODE AOBC_load_driver_super_init_settings_(ComponentDriverSuper* p_super); +static CDS_ERR_CODE AOBC_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver); -DS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer) +CDS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, CDS_StreamRecBuffer* rx_buffer) { - DS_ERR_CODE ret; + CDS_ERR_CODE ret; memset(aobc_driver, 0x00, sizeof(*aobc_driver)); AOBC_init_tlm_buffer(aobc_driver); @@ -36,65 +36,65 @@ DS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, DS_StreamRecBuf aobc_driver->driver.uart_config.data_length = UART_DATA_LENGTH_8BIT; aobc_driver->driver.uart_config.stop_bit = UART_STOP_BIT_1BIT; - ret = DS_init(&(aobc_driver->driver.super), + ret = CDS_init(&(aobc_driver->driver.super), &(aobc_driver->driver.uart_config), rx_buffer, AOBC_load_driver_super_init_settings_); - if (ret != DS_ERR_CODE_OK) return DS_INIT_DS_INIT_ERR; - return DS_INIT_OK; + if (ret != CDS_ERR_CODE_OK) return CDS_INIT_CDS_INIT_ERR; + return CDS_INIT_OK; } -static DS_ERR_CODE AOBC_load_driver_super_init_settings_(DriverSuper* p_super) +static CDS_ERR_CODE AOBC_load_driver_super_init_settings_(ComponentDriverSuper* p_super) { - DS_StreamConfig* p_stream_config; + CDS_StreamConfig* p_stream_config; p_super->interface = UART; // stream は 0 のみ p_stream_config = &(p_super->stream_config[AOBC_STREAM_TLM_CMD]); - CTCP_init_dssc(p_stream_config, AOBC_tx_frame_, sizeof(AOBC_tx_frame_), AOBC_analyze_rec_data_); + CTCP_init_cdssc(p_stream_config, AOBC_tx_frame_, sizeof(AOBC_tx_frame_), AOBC_analyze_rec_data_); // 定期 TLM の監視機能の有効化しない → ので設定上書きなし - DSSC_enable(p_stream_config); + CDSSC_enable(p_stream_config); - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -DS_REC_ERR_CODE AOBC_rec(AOBC_Driver* aobc_driver) +CDS_REC_ERR_CODE AOBC_rec(AOBC_Driver* aobc_driver) { - DS_ERR_CODE ret; - DS_StreamConfig* p_stream_config; + CDS_ERR_CODE ret; + CDS_StreamConfig* p_stream_config; - ret = DS_receive(&(aobc_driver->driver.super)); + ret = CDS_receive(&(aobc_driver->driver.super)); - if (ret != DS_ERR_CODE_OK) return DS_REC_DS_RECEIVE_ERR; + if (ret != CDS_ERR_CODE_OK) return CDS_REC_CDS_RECEIVE_ERR; p_stream_config = &(aobc_driver->driver.super.stream_config[AOBC_STREAM_TLM_CMD]); - if (DSSC_get_rec_status(p_stream_config)->status_code != DS_STREAM_REC_STATUS_FIXED_FRAME) return DS_REC_OK; // 受信せず([TODO] 詳細なエラー処理は一旦しない) + if (CDSSC_get_rec_status(p_stream_config)->status_code != CDS_STREAM_REC_STATUS_FIXED_FRAME) return CDS_REC_OK; // 受信せず([TODO] 詳細なエラー処理は一旦しない) - ret = DS_analyze_rec_data(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD, aobc_driver); + ret = CDS_analyze_rec_data(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD, aobc_driver); - if (ret != DS_ERR_CODE_OK) return DS_REC_ANALYZE_ERR; + if (ret != CDS_ERR_CODE_OK) return CDS_REC_ANALYZE_ERR; - return DS_REC_OK; + return CDS_REC_OK; } -static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, +static CDS_ERR_CODE AOBC_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver) { AOBC_Driver* aobc_driver = (AOBC_Driver*)p_driver; aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_OK; - if (!EB90_FRAME_is_valid_crc_of_dssc(p_stream_config)) + if (!EB90_FRAME_is_valid_crc_of_cdssc(p_stream_config)) { aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_CRC_ERR; - return DS_ERR_CODE_ERR; + return CDS_ERR_CODE_ERR; } return AOBC_buffer_tlm_packet(p_stream_config, aobc_driver); @@ -104,11 +104,11 @@ static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, // TODO: DS protocol 改修にともなって古くなったので治す #if 0 // 非C2A系列はこのように書く -static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver) +static CDS_ERR_CODE AOBC_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver) { AOBC_Driver* aobc_driver = (AOBC_Driver*)p_driver; - uint32_t tlm_ver = DS_ISSLFMT_get_tlm_version(p_stream_config); - uint32_t tlm_id = DS_ISSLFMT_get_tlm_id(tlm_ver, p_stream_config); + uint32_t tlm_ver = CDS_ISSLFMT_get_tlm_version(p_stream_config); + uint32_t tlm_id = CDS_ISSLFMT_get_tlm_id(tlm_ver, p_stream_config); aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_OK; @@ -119,22 +119,22 @@ static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void return AOBC_analyze_tlm_hk_(p_stream_config, aobc_driver); default: aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_TLM_NOT_FOUND; - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } } #endif -DS_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet) +CDS_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet) { - DS_ERR_CODE ret; - DS_StreamConfig* p_stream_config; + CDS_ERR_CODE ret; + CDS_StreamConfig* p_stream_config; AOBC_CMD_CODE cmd_code; p_stream_config = &(aobc_driver->driver.super.stream_config[AOBC_STREAM_TLM_CMD]); // tx_frameの設定 - CCP_set_tx_frame_to_dssc(p_stream_config, packet); + CCP_set_tx_frame_to_cdssc(p_stream_config, packet); cmd_code = (AOBC_CMD_CODE)CCP_get_id(packet); @@ -151,21 +151,21 @@ DS_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* p case AOBC_Cmd_CODE_TG_FORWARD_AS_HP_TLM: // FALLTHROUGH case AOBC_Cmd_CODE_TG_FORWARD_AS_RT_TLM: // FALLTHROUGH case AOBC_Cmd_CODE_TG_FORWARD_AS_ST_TLM: - ret = DS_send_req_tlm_cmd(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD); + ret = CDS_send_req_tlm_cmd(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD); break; default: - ret = DS_send_general_cmd(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD); + ret = CDS_send_general_cmd(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD); break; } - if (ret == DS_ERR_CODE_OK) + if (ret == CDS_ERR_CODE_OK) { - return DS_CMD_OK; + return CDS_CMD_OK; } else { // TODO: エラー処理? - return DS_CMD_DRIVER_SUPER_ERR; + return CDS_CMD_DRIVER_SUPER_ERR; } } diff --git a/examples/mobc/src/src_user/driver/aocs/aobc.h b/examples/mobc/src/src_user/component_driver/aocs/aobc.h similarity index 82% rename from examples/mobc/src/src_user/driver/aocs/aobc.h rename to examples/mobc/src/src_user/component_driver/aocs/aobc.h index 57fd18991..1f6475c0a 100644 --- a/examples/mobc/src/src_user/driver/aocs/aobc.h +++ b/examples/mobc/src/src_user/component_driver/aocs/aobc.h @@ -6,7 +6,7 @@ #define AOBC_H_ #include -#include +#include #include #include #include "./aobc_telemetry_data_definitions.h" @@ -64,7 +64,7 @@ struct AOBC_Driver { struct { - DriverSuper super; //!< DriverSuper class + ComponentDriverSuper super; //!< ComponentDriverSuper class UART_Config uart_config; //!< RS422 class } driver; AOBC_Info info; @@ -80,24 +80,24 @@ struct AOBC_Driver * @param aobc_driver: 初期化する AOBC_Driver 構造体へのポインタ * @param ch: AOBC が接続されている UART ポート番号 * @param rx_buffer: 受信バッファ - * @return DS_INIT_ERR_CODE + * @return CDS_INIT_ERR_CODE */ -DS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer); +CDS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, CDS_StreamRecBuffer* rx_buffer); /** * @brief AOBC のデータ(テレメ)受信 * @param aobc_driver: AOBC_Driver 構造体へのポインタ - * @return DS_REC_ERR_CODE + * @return CDS_REC_ERR_CODE */ -DS_REC_ERR_CODE AOBC_rec(AOBC_Driver* aobc_driver); +CDS_REC_ERR_CODE AOBC_rec(AOBC_Driver* aobc_driver); /** * @brief AOBC へのコマンド送信 * @param aobc_driver: AOBC_Driver 構造体へのポインタ * @param packet: 送信する packet - * @return DS_CMD_ERR_CODE + * @return CDS_CMD_ERR_CODE * @note これを受信した AOBC C2A は, packet をそのまま PH_analyze_cmd_packet に流せばよい. */ -DS_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet); +CDS_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet); #endif diff --git a/examples/mobc/src/src_user/driver/aocs/aobc_command_definitions.h b/examples/mobc/src/src_user/component_driver/aocs/aobc_command_definitions.h similarity index 100% rename from examples/mobc/src/src_user/driver/aocs/aobc_command_definitions.h rename to examples/mobc/src/src_user/component_driver/aocs/aobc_command_definitions.h diff --git a/examples/mobc/src/src_user/driver/aocs/aobc_telemetry_buffer.c b/examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_buffer.c similarity index 96% rename from examples/mobc/src/src_user/driver/aocs/aobc_telemetry_buffer.c rename to examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_buffer.c index f72f16b45..cbf9c92f6 100644 --- a/examples/mobc/src/src_user/driver/aocs/aobc_telemetry_buffer.c +++ b/examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_buffer.c @@ -4,14 +4,14 @@ * @brief テレメトリバッファー(テレメ中継) * @note このコードは自動生成されています! */ -#include +#include #include "./aobc_telemetry_definitions.h" #include "./aobc_telemetry_buffer.h" #include "./aobc.h" #include -static DS_ERR_CODE AOBC_analyze_tlm_aobc_aobc_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver); -static DS_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver); +static CDS_ERR_CODE AOBC_analyze_tlm_aobc_aobc_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver); +static CDS_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver); static CommonTlmPacket AOBC_ctp_; @@ -25,13 +25,13 @@ void AOBC_init_tlm_buffer(AOBC_Driver* aobc_driver) } } -DS_ERR_CODE AOBC_buffer_tlm_packet(DS_StreamConfig* p_stream_config, AOBC_Driver* aobc_driver) +CDS_ERR_CODE AOBC_buffer_tlm_packet(CDS_StreamConfig* p_stream_config, AOBC_Driver* aobc_driver) { AOBC_TLM_CODE tlm_id; - DS_ERR_CODE ret; + CDS_ERR_CODE ret; - ret = CTP_get_ctp_from_dssc(p_stream_config, &AOBC_ctp_); - if (ret != DS_ERR_CODE_OK) return ret; + ret = CTP_get_ctp_from_cdssc(p_stream_config, &AOBC_ctp_); + if (ret != CDS_ERR_CODE_OK) return ret; tlm_id = (AOBC_TLM_CODE)CTP_get_id(&AOBC_ctp_); @@ -43,11 +43,11 @@ DS_ERR_CODE AOBC_buffer_tlm_packet(DS_StreamConfig* p_stream_config, AOBC_Driver return AOBC_analyze_tlm_aobc_hk_(&AOBC_ctp_, tlm_id, aobc_driver); default: aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_TLM_NOT_FOUND; - return DS_ERR_CODE_ERR; + return CDS_ERR_CODE_ERR; } } -static DS_ERR_CODE AOBC_analyze_tlm_aobc_aobc_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver) +static CDS_ERR_CODE AOBC_analyze_tlm_aobc_aobc_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver) { const uint8_t* f = packet->packet; int8_t temp_i8 = 0; @@ -192,10 +192,10 @@ static DS_ERR_CODE AOBC_analyze_tlm_aobc_aobc_(const CommonTlmPacket* packet, AO (void)temp_f; (void)temp_d; - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -static DS_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver) +static CDS_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver) { const uint8_t* f = packet->packet; int8_t temp_i8 = 0; @@ -421,7 +421,7 @@ static DS_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC (void)temp_f; (void)temp_d; - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } TF_TLM_FUNC_ACK AOBC_pick_up_tlm_buffer(const AOBC_Driver* aobc_driver, AOBC_TLM_CODE tlm_id, uint8_t* packet, uint16_t* len, uint16_t max_len) diff --git a/examples/mobc/src/src_user/driver/aocs/aobc_telemetry_buffer.h b/examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_buffer.h similarity index 86% rename from examples/mobc/src/src_user/driver/aocs/aobc_telemetry_buffer.h rename to examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_buffer.h index d02d77062..fe5317042 100644 --- a/examples/mobc/src/src_user/driver/aocs/aobc_telemetry_buffer.h +++ b/examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_buffer.h @@ -7,7 +7,7 @@ #define AOBC_TELEMETRY_BUFFER_H_ #include "./aobc_telemetry_definitions.h" -#include +#include #include #include @@ -28,7 +28,7 @@ typedef struct void AOBC_init_tlm_buffer(AOBC_Driver* aobc_driver); -DS_ERR_CODE AOBC_buffer_tlm_packet(DS_StreamConfig* p_stream_config, AOBC_Driver* aobc_driver); +CDS_ERR_CODE AOBC_buffer_tlm_packet(CDS_StreamConfig* p_stream_config, AOBC_Driver* aobc_driver); TF_TLM_FUNC_ACK AOBC_pick_up_tlm_buffer(const AOBC_Driver* aobc_driver, AOBC_TLM_CODE tlm_id, uint8_t* packet, uint16_t* len, uint16_t max_len); diff --git a/examples/mobc/src/src_user/driver/aocs/aobc_telemetry_data_definitions.h b/examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_data_definitions.h similarity index 100% rename from examples/mobc/src/src_user/driver/aocs/aobc_telemetry_data_definitions.h rename to examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_data_definitions.h diff --git a/examples/mobc/src/src_user/driver/aocs/aobc_telemetry_definitions.h b/examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_definitions.h similarity index 100% rename from examples/mobc/src/src_user/driver/aocs/aobc_telemetry_definitions.h rename to examples/mobc/src/src_user/component_driver/aocs/aobc_telemetry_definitions.h diff --git a/examples/mobc/src/src_user/driver/cdh/.gitkeep b/examples/mobc/src/src_user/component_driver/cdh/.gitkeep similarity index 100% rename from examples/mobc/src/src_user/driver/cdh/.gitkeep rename to examples/mobc/src/src_user/component_driver/cdh/.gitkeep diff --git a/examples/mobc/src/src_user/driver/com/gs.c b/examples/mobc/src/src_user/component_driver/com/gs.c similarity index 62% rename from examples/mobc/src/src_user/driver/com/gs.c rename to examples/mobc/src/src_user/component_driver/com/gs.c index 6cf8654d1..cfe44fab2 100644 --- a/examples/mobc/src/src_user/driver/com/gs.c +++ b/examples/mobc/src/src_user/component_driver/com/gs.c @@ -11,7 +11,7 @@ #include "../../hal/ccsds_user.h" #include "../../tlm_cmd/ccsds/tc_transfer_frame.h" -#include +#include #include #include @@ -20,7 +20,7 @@ #define GS_RX_FRAMELENGTH_TYPE_SIZE (2) #define GS_TX_STREAM (0) // どれでも良いがとりあえず 0 で -#if GS_RX_HEADER_NUM > DS_STREAM_MAX +#if GS_RX_HEADER_NUM > CDS_STREAM_MAX #error GS RX HEADER NUM TOO MANY #endif @@ -30,38 +30,38 @@ static uint8_t GS_tx_frame_[VCDU_LEN]; /** * @brief CCSDS 側 Driver の DS 上での初期化設定 - * @param[in] p_super: DriverSuper - * @return DS_ERR_CODE + * @param[in] p_super: ComponentDriverSuper + * @return CDS_ERR_CODE */ -static DS_ERR_CODE GS_load_ccsds_driver_super_init_settings_(DriverSuper* p_super); +static CDS_ERR_CODE GS_load_ccsds_driver_super_init_settings_(ComponentDriverSuper* p_super); /** * @brief UART 側 Driver の DS 上での初期化設定 - * @param[in] p_super: DriverSuper - * @return DS_ERR_CODE + * @param[in] p_super: ComponentDriverSuper + * @return CDS_ERR_CODE */ -static DS_ERR_CODE GS_load_uart_driver_super_init_settings_(DriverSuper* p_super); +static CDS_ERR_CODE GS_load_uart_driver_super_init_settings_(ComponentDriverSuper* p_super); /** * @brief 上記初期化の共通部分をまとめた関数 - * @param[in] p_super: DriverSuper + * @param[in] p_super: ComponentDriverSuper */ -static void GS_load_default_driver_super_init_settings_(DriverSuper* p_super); +static void GS_load_default_driver_super_init_settings_(ComponentDriverSuper* p_super); /** * @brief 地上からの受信データ解析関数 - * @param[in] p_stream_config: DS_StreamConfig + * @param[in] p_stream_config: CDS_StreamConfig * @param[in] p_driver: GS_Driver * @param[in] */ -static DS_ERR_CODE GS_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver); +static CDS_ERR_CODE GS_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver); -DS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver, +CDS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver, uint8_t uart_ch, - DS_StreamRecBuffer* ccsds_rx_buffers[DS_STREAM_MAX], - DS_StreamRecBuffer* uart_rx_buffers[DS_STREAM_MAX]) + CDS_StreamRecBuffer* ccsds_rx_buffers[CDS_STREAM_MAX], + CDS_StreamRecBuffer* uart_rx_buffers[CDS_STREAM_MAX]) { - DS_ERR_CODE ret_uart, ret_ccsds; + CDS_ERR_CODE ret_uart, ret_ccsds; int i; int stream; @@ -88,21 +88,21 @@ DS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver, GS_rx_header_[stream][1] |= (uint8_t)(TCTF_SCID_SAMPLE_SATELLITE & 0xff); } - ret_ccsds = DS_init_streams(&gs_driver->driver_ccsds.super, + ret_ccsds = CDS_init_streams(&gs_driver->driver_ccsds.super, &gs_driver->driver_ccsds.ccsds_config, ccsds_rx_buffers, GS_load_ccsds_driver_super_init_settings_); - ret_uart = DS_init_streams(&gs_driver->driver_uart.super, + ret_uart = CDS_init_streams(&gs_driver->driver_uart.super, &gs_driver->driver_uart.uart_config, uart_rx_buffers, GS_load_uart_driver_super_init_settings_); - if (ret_ccsds != DS_ERR_CODE_OK || ret_uart != DS_ERR_CODE_OK) return DS_INIT_DS_INIT_ERR; + if (ret_ccsds != CDS_ERR_CODE_OK || ret_uart != CDS_ERR_CODE_OK) return CDS_INIT_CDS_INIT_ERR; gs_driver->latest_info = &gs_driver->info[GS_PORT_TYPE_CCSDS]; gs_driver->tlm_tx_port_type = GS_PORT_TYPE_CCSDS; for (i = 0; i < GS_PORT_TYPE_NUM; ++i) { - gs_driver->info[i].rx.rec_status = DS_ERR_CODE_OK; + gs_driver->info[i].rx.rec_status = CDS_ERR_CODE_OK; gs_driver->info[i].rx.ret_from_if_rx = 0; gs_driver->info[i].rx.last_dest_type = CCP_DEST_TYPE_TO_UNKOWN; gs_driver->info[i].rx.last_rec_time = 0; @@ -121,55 +121,55 @@ DS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver, gs_driver->ccsds_info.buffer_num = 8; gs_driver->driver_uart.is_tlm_on = 1; - return DS_INIT_OK; + return CDS_INIT_OK; } -static DS_ERR_CODE GS_load_ccsds_driver_super_init_settings_(DriverSuper* p_super) +static CDS_ERR_CODE GS_load_ccsds_driver_super_init_settings_(ComponentDriverSuper* p_super) { p_super->interface = CCSDS; GS_load_default_driver_super_init_settings_(p_super); - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -static DS_ERR_CODE GS_load_uart_driver_super_init_settings_(DriverSuper* p_super) +static CDS_ERR_CODE GS_load_uart_driver_super_init_settings_(ComponentDriverSuper* p_super) { p_super->interface = UART; GS_load_default_driver_super_init_settings_(p_super); - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -static void GS_load_default_driver_super_init_settings_(DriverSuper* p_super) +static void GS_load_default_driver_super_init_settings_(ComponentDriverSuper* p_super) { - DS_StreamConfig* p_stream_config; + CDS_StreamConfig* p_stream_config; int stream; for (stream = 0; stream < GS_RX_HEADER_NUM; ++stream) { p_stream_config = &(p_super->stream_config[stream]); - DSSC_enable(p_stream_config); - DSSC_enable_strict_frame_search(p_stream_config); // 複数ストリームがあり,かつ論理的な受信漏れを0にするため. - - DSSC_set_tx_frame(p_stream_config, GS_tx_frame_); // 全 stream, uart, ccsds に関わらず共通 - DSSC_set_tx_frame_size(p_stream_config, VCDU_LEN); // VCDU を送信 - - DSSC_set_rx_header(p_stream_config, GS_rx_header_[stream], GS_RX_HEADER_SIZE); - DSSC_set_rx_frame_size(p_stream_config, -1); // 可変長 - DSSC_set_rx_framelength_pos(p_stream_config, GS_RX_HEADER_SIZE); - DSSC_set_rx_framelength_type_size(p_stream_config, GS_RX_FRAMELENGTH_TYPE_SIZE); - DSSC_set_rx_framelength_offset(p_stream_config, 1); // TCTF の framelength は 0 起算 - DSSC_set_data_analyzer(p_stream_config, GS_analyze_rec_data_); + CDSSC_enable(p_stream_config); + CDSSC_enable_strict_frame_search(p_stream_config); // 複数ストリームがあり,かつ論理的な受信漏れを0にするため. + + CDSSC_set_tx_frame(p_stream_config, GS_tx_frame_); // 全 stream, uart, ccsds に関わらず共通 + CDSSC_set_tx_frame_size(p_stream_config, VCDU_LEN); // VCDU を送信 + + CDSSC_set_rx_header(p_stream_config, GS_rx_header_[stream], GS_RX_HEADER_SIZE); + CDSSC_set_rx_frame_size(p_stream_config, -1); // 可変長 + CDSSC_set_rx_framelength_pos(p_stream_config, GS_RX_HEADER_SIZE); + CDSSC_set_rx_framelength_type_size(p_stream_config, GS_RX_FRAMELENGTH_TYPE_SIZE); + CDSSC_set_rx_framelength_offset(p_stream_config, 1); // TCTF の framelength は 0 起算 + CDSSC_set_data_analyzer(p_stream_config, GS_analyze_rec_data_); } } -DS_REC_ERR_CODE GS_rec_tctf(GS_Driver* gs_driver) +CDS_REC_ERR_CODE GS_rec_tctf(GS_Driver* gs_driver) { uint8_t i, stream; for (i = 0; i < GS_PORT_TYPE_NUM; ++i) { - DriverSuper* ds; + ComponentDriverSuper* ds; if (i == GS_PORT_TYPE_CCSDS) { @@ -181,29 +181,29 @@ DS_REC_ERR_CODE GS_rec_tctf(GS_Driver* gs_driver) } // TODO: これはエラー情報をきちんと把握したいので,アノマリ発行を入れる - gs_driver->info[i].rx.rec_status = DS_receive(ds); - gs_driver->info[i].rx.ret_from_if_rx = DSC_get_rec_status(ds)->ret_from_if_rx; + gs_driver->info[i].rx.rec_status = CDS_receive(ds); + gs_driver->info[i].rx.ret_from_if_rx = CDSC_get_rec_status(ds)->ret_from_if_rx; - if (gs_driver->info[i].rx.rec_status != DS_ERR_CODE_OK) continue; + if (gs_driver->info[i].rx.rec_status != CDS_ERR_CODE_OK) continue; for (stream = 0; stream < GS_RX_HEADER_NUM; ++stream) { - DS_StreamConfig* p_stream_config; + CDS_StreamConfig* p_stream_config; p_stream_config = &ds->stream_config[stream]; - if (DSSC_get_rec_status(p_stream_config)->status_code != DS_STREAM_REC_STATUS_FIXED_FRAME) continue; + if (CDSSC_get_rec_status(p_stream_config)->status_code != CDS_STREAM_REC_STATUS_FIXED_FRAME) continue; - gs_driver->info[i].rx.rec_status = DS_analyze_rec_data(ds, stream, gs_driver); + gs_driver->info[i].rx.rec_status = CDS_analyze_rec_data(ds, stream, gs_driver); } } // TODO: 常に OK を返すのでいいのか検討 - return DS_REC_OK; + return CDS_REC_OK; } -static DS_ERR_CODE GS_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver) +static CDS_ERR_CODE GS_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver) { - const uint8_t* gs_rx_data = DSSC_get_rx_frame(p_stream_config); + const uint8_t* gs_rx_data = CDSSC_get_rx_frame(p_stream_config); const TcTransferFrame* tctf = TCTF_convert_from_bytes_to_tctf(gs_rx_data); GS_Driver* gs_driver = (GS_Driver*)p_driver; GS_PORT_TYPE driver_index; @@ -243,7 +243,7 @@ static DS_ERR_CODE GS_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* break; } - if (tctf_validate_status != GS_VALIDATE_ERR_OK) return DS_ERR_CODE_ERR; + if (tctf_validate_status != GS_VALIDATE_ERR_OK) return CDS_ERR_CODE_ERR; tcs = TCTF_get_tc_segment(tctf); csp = TCS_get_command_space_packet(tcs); @@ -251,26 +251,26 @@ static DS_ERR_CODE GS_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* gs_driver->info[driver_index].rx.last_rec_time = TMGR_get_master_total_cycle(); gs_driver->info[driver_index].rx.cmd_ack = PH_analyze_cmd_packet(csp); // 受信コマンドパケット解析 - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -DS_CMD_ERR_CODE GS_send_vcdu(GS_Driver* gs_driver, const VCDU* vcdu) +CDS_CMD_ERR_CODE GS_send_vcdu(GS_Driver* gs_driver, const VCDU* vcdu) { - DS_ERR_CODE ret_ccsds = DS_ERR_CODE_OK; - DS_ERR_CODE ret_uart = DS_ERR_CODE_OK; + CDS_ERR_CODE ret_ccsds = CDS_ERR_CODE_OK; + CDS_ERR_CODE ret_uart = CDS_ERR_CODE_OK; size_t vcdu_size = sizeof(VCDU); // パディングが無ければ元を GS_tx_frame_ にコピーさせる (444Byte) のコピーが無駄 if (vcdu_size == VCDU_LEN) { - DSSC_set_tx_frame(&gs_driver->driver_ccsds.super.stream_config[GS_TX_STREAM], (uint8_t*)vcdu); - DSSC_set_tx_frame(&gs_driver->driver_uart.super.stream_config[GS_TX_STREAM], (uint8_t*)vcdu); + CDSSC_set_tx_frame(&gs_driver->driver_ccsds.super.stream_config[GS_TX_STREAM], (uint8_t*)vcdu); + CDSSC_set_tx_frame(&gs_driver->driver_uart.super.stream_config[GS_TX_STREAM], (uint8_t*)vcdu); } else { VCDU_generate_byte_stream(vcdu, GS_tx_frame_); // 送信元にセット 消したいなぁ... - DSSC_set_tx_frame(&gs_driver->driver_ccsds.super.stream_config[GS_TX_STREAM], GS_tx_frame_); - DSSC_set_tx_frame(&gs_driver->driver_uart.super.stream_config[GS_TX_STREAM], GS_tx_frame_); + CDSSC_set_tx_frame(&gs_driver->driver_ccsds.super.stream_config[GS_TX_STREAM], GS_tx_frame_); + CDSSC_set_tx_frame(&gs_driver->driver_uart.super.stream_config[GS_TX_STREAM], GS_tx_frame_); } // CCSDS @@ -282,7 +282,7 @@ DS_CMD_ERR_CODE GS_send_vcdu(GS_Driver* gs_driver, const VCDU* vcdu) gs_driver->info[GS_PORT_TYPE_CCSDS].tx.vcdu_counter = VCDU_get_vcdu_counter(vcdu); // DS 側の名称が cmd なだけで送信しているのは TLM - ret_ccsds = DS_send_general_cmd(&gs_driver->driver_ccsds.super, GS_TX_STREAM); + ret_ccsds = CDS_send_general_cmd(&gs_driver->driver_ccsds.super, GS_TX_STREAM); } // UART @@ -293,15 +293,15 @@ DS_CMD_ERR_CODE GS_send_vcdu(GS_Driver* gs_driver, const VCDU* vcdu) gs_driver->info[GS_PORT_TYPE_UART].tx.vcdu_counter = VCDU_get_vcdu_counter(vcdu); // DS 側の名称が cmd なだけで送信しているのは TLM - ret_uart = DS_send_general_cmd(&gs_driver->driver_uart.super, GS_TX_STREAM); + ret_uart = CDS_send_general_cmd(&gs_driver->driver_uart.super, GS_TX_STREAM); } - if (ret_ccsds != DS_ERR_CODE_OK || ret_uart != DS_ERR_CODE_OK) + if (ret_ccsds != CDS_ERR_CODE_OK || ret_uart != CDS_ERR_CODE_OK) { - return DS_CMD_DRIVER_SUPER_ERR; + return CDS_CMD_DRIVER_SUPER_ERR; } - return DS_CMD_OK; + return CDS_CMD_OK; } #pragma section diff --git a/examples/mobc/src/src_user/driver/com/gs.h b/examples/mobc/src/src_user/component_driver/com/gs.h similarity index 77% rename from examples/mobc/src/src_user/driver/com/gs.h rename to examples/mobc/src/src_user/component_driver/com/gs.h index 665d3f0cd..2907c2743 100644 --- a/examples/mobc/src/src_user/driver/com/gs.h +++ b/examples/mobc/src/src_user/component_driver/com/gs.h @@ -6,7 +6,7 @@ #define GS_H_ #include -#include +#include #include #include #include "../../hal/ccsds_user.h" @@ -35,7 +35,7 @@ typedef struct { struct { - DS_ERR_CODE rec_status; //!< DriverSuper からの受信結果 + CDS_ERR_CODE rec_status; //!< ComponentDriverSuper からの受信結果 int ret_from_if_rx; //!< UART or CCSDS からの返り値 CCP_DEST_TYPE last_dest_type; //!< 最後に受信したパケットの dest type cycle_t last_rec_time; //!< 最後に受信した時刻 @@ -67,14 +67,14 @@ typedef struct // CCSDS 側の Driver struct { - DriverSuper super; + ComponentDriverSuper super; CCSDS_Config ccsds_config; } driver_ccsds; // UART 側の Driver struct { - DriverSuper super; + ComponentDriverSuper super; UART_Config uart_config; uint8_t is_tlm_on; //!< UART に TLM を流すかどうか, CCSDS では許容でも UART に TLM を送りすぎると詰まってしまうため } driver_uart; @@ -91,28 +91,28 @@ typedef struct * @param[in] uart_ch: 有線通信時の CH * @param[in] ccsds_rx_buffers: CCSDS 用受信バッファ * @param[in] uart_rx_buffers: UART 用受信バッファ - * @return DS_INIT_ERR_CODE + * @return CDS_INIT_ERR_CODE */ -DS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver, +CDS_INIT_ERR_CODE GS_init(GS_Driver* gs_driver, uint8_t uart_ch, - DS_StreamRecBuffer* ccsds_rx_buffers[DS_STREAM_MAX], - DS_StreamRecBuffer* uart_rx_buffers[DS_STREAM_MAX]); + CDS_StreamRecBuffer* ccsds_rx_buffers[CDS_STREAM_MAX], + CDS_StreamRecBuffer* uart_rx_buffers[CDS_STREAM_MAX]); /** * @brief 地上から CMD を受信する. 形式は TC Transer Frame * @param[in] gs_driver: ドライバー - * @return DS_REC_ERR_CODE + * @return CDS_REC_ERR_CODE */ -DS_REC_ERR_CODE GS_rec_tctf(GS_Driver* gs_driver); +CDS_REC_ERR_CODE GS_rec_tctf(GS_Driver* gs_driver); /** * @brief 地上に向けて TLM を送信. 形式は VCDU - * @note DS_send_general_cmd が使われているが, これは DS は MOBC コンポ間を想定しているため, MOBC から見るとコンポに cmd を送信している様に見える, が 今回は MOBC から地上に TLM を送信している + * @note CDS_send_general_cmd が使われているが, これは DS は MOBC コンポ間を想定しているため, MOBC から見るとコンポに cmd を送信している様に見える, が 今回は MOBC から地上に TLM を送信している * @note TLM 送信, 形式は VCDU * @param[in] gs_driver: ドライバー * @param[in] vcdu: 送信する VCDU. 場合によってはそのまま DS に渡すので, local変数ではなくstaticな変数を渡すこと - * @return DS_CMD_ERR_CODE: 送信結果 + * @return CDS_CMD_ERR_CODE: 送信結果 */ -DS_CMD_ERR_CODE GS_send_vcdu(GS_Driver* gs_driver, const VCDU* vcdu); +CDS_CMD_ERR_CODE GS_send_vcdu(GS_Driver* gs_driver, const VCDU* vcdu); #endif diff --git a/examples/mobc/src/src_user/driver/com/gs_validate.c b/examples/mobc/src/src_user/component_driver/com/gs_validate.c similarity index 100% rename from examples/mobc/src/src_user/driver/com/gs_validate.c rename to examples/mobc/src/src_user/component_driver/com/gs_validate.c diff --git a/examples/mobc/src/src_user/driver/com/gs_validate.h b/examples/mobc/src/src_user/component_driver/com/gs_validate.h similarity index 100% rename from examples/mobc/src/src_user/driver/com/gs_validate.h rename to examples/mobc/src/src_user/component_driver/com/gs_validate.h diff --git a/examples/mobc/src/src_user/component_driver/etc/uart_test.c b/examples/mobc/src/src_user/component_driver/etc/uart_test.c new file mode 100644 index 000000000..b6815ef9f --- /dev/null +++ b/examples/mobc/src/src_user/component_driver/etc/uart_test.c @@ -0,0 +1,209 @@ +#pragma section REPRO +/** + * @file + * @brief テスト用UARTのDriver + */ + +#include "uart_test.h" +#include +#include +#include "../../Settings/sils_define.h" +#include "string.h" // for memcpy +#include // SILSでのprint + +// ヘッダーフッター +#define UART_TEST_HEADER_SIZE (8) +#define UART_TEST_FOOTER_SIZE (2) +#define UART_TEST_TX_FRAME_SIZE_MAX (16) + +static const uint8_t UART_TEST_header_[UART_TEST_HEADER_SIZE] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7}; +static const uint8_t UART_TEST_footer_[UART_TEST_FOOTER_SIZE] = {0xBF, 0xBE}; + +#define UART_TEST_STREAM_FIX (0) //!< 固定長 +#define UART_TEST_STREAM_VAR (1) //!< 可変長 + +static uint8_t UART_TEST_tx_frame_[UART_TEST_TX_FRAME_SIZE_MAX]; + +static CDS_ERR_CODE UART_TEST_load_driver_super_init_settings_(ComponentDriverSuper* p_super); +static CDS_ERR_CODE UART_TEST_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver); + + +CDS_INIT_ERR_CODE UART_TEST_init(UART_TEST_Driver* uart_test_driver, uint8_t ch, CDS_StreamRecBuffer* rx_buffers[CDS_STREAM_MAX]) +{ + CDS_ERR_CODE ret; + + uart_test_driver->driver.uart_config.ch = ch; + uart_test_driver->driver.uart_config.baudrate = 38400; + uart_test_driver->driver.uart_config.parity_settings = PARITY_SETTINGS_NONE; + uart_test_driver->driver.uart_config.data_length = UART_DATA_LENGTH_8BIT; + uart_test_driver->driver.uart_config.stop_bit = UART_STOP_BIT_1BIT; + + ret = CDS_init_streams(&(uart_test_driver->driver.super), + &(uart_test_driver->driver.uart_config), + rx_buffers, + UART_TEST_load_driver_super_init_settings_); + if (ret != CDS_ERR_CODE_OK) return CDS_INIT_CDS_INIT_ERR; + return CDS_INIT_OK; +} + + +static CDS_ERR_CODE UART_TEST_load_driver_super_init_settings_(ComponentDriverSuper* p_super) +{ + CDS_StreamConfig* p_stream_config; + + p_super->interface = UART; + + // stream0の設定 + p_stream_config = &(p_super->stream_config[UART_TEST_STREAM_FIX]); + CDSSC_enable(p_stream_config); + CDSSC_enable_strict_frame_search(p_stream_config); + + // 送信はする + CDSSC_set_tx_frame(p_stream_config, UART_TEST_tx_frame_); // 送る直前に中身をmemcpyする + CDSSC_set_tx_frame_size(p_stream_config, 0); // 送る直前に値をセットする + + // 定期的な受信はする + CDSSC_set_rx_header(p_stream_config, UART_TEST_header_, UART_TEST_HEADER_SIZE); + CDSSC_set_rx_footer(p_stream_config, UART_TEST_footer_, UART_TEST_FOOTER_SIZE); + CDSSC_set_rx_frame_size(p_stream_config, 12); + CDSSC_set_data_analyzer(p_stream_config, UART_TEST_analyze_rec_data_); + + // stream1の設定 + p_stream_config = &(p_super->stream_config[UART_TEST_STREAM_VAR]); + CDSSC_enable(p_stream_config); + CDSSC_enable_strict_frame_search(p_stream_config); + + // 送信はしない + + // 定期的な受信はする + CDSSC_set_rx_header(p_stream_config, UART_TEST_header_, UART_TEST_HEADER_SIZE); + CDSSC_set_rx_footer(p_stream_config, UART_TEST_footer_, UART_TEST_FOOTER_SIZE); + CDSSC_set_rx_frame_size(p_stream_config, -1); // 可変 + CDSSC_set_rx_framelength_pos(p_stream_config, UART_TEST_HEADER_SIZE); + CDSSC_set_rx_framelength_type_size(p_stream_config, 2); + CDSSC_set_rx_framelength_offset(p_stream_config, UART_TEST_HEADER_SIZE + UART_TEST_FOOTER_SIZE); + CDSSC_set_data_analyzer(p_stream_config, UART_TEST_analyze_rec_data_); + + // 定期TLMの監視機能の有効化しない → ので設定上書きなし + + return CDS_ERR_CODE_OK; +} + + +CDS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_driver) +{ + CDS_ERR_CODE ret; + CDS_StreamConfig* p_stream_config; + + ret = CDS_receive(&(uart_test_driver->driver.super)); + + if (ret != CDS_ERR_CODE_OK) return CDS_REC_CDS_RECEIVE_ERR; + + p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_FIX]); + if (CDSSC_get_rec_status(p_stream_config)->status_code == CDS_STREAM_REC_STATUS_FIXED_FRAME) + { + ret = CDS_analyze_rec_data(&(uart_test_driver->driver.super), UART_TEST_STREAM_FIX, uart_test_driver); + } + + p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_VAR]); + if (CDSSC_get_rec_status(p_stream_config)->status_code == CDS_STREAM_REC_STATUS_FIXED_FRAME) + { + ret = CDS_analyze_rec_data(&(uart_test_driver->driver.super), UART_TEST_STREAM_VAR, uart_test_driver); + } + + // 返り値ぐだぐだだけど,まあテストコードなので... + if (ret != CDS_ERR_CODE_OK) return CDS_REC_ANALYZE_ERR; + + return CDS_REC_OK; +} + + +static CDS_ERR_CODE UART_TEST_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver) +{ + UART_TEST_Driver* uart_test_driver = (UART_TEST_Driver*)p_driver; + uint16_t i; + + (void)(uart_test_driver); + +#ifndef SILS_FW + Printf("DEC DATA: %d\n", CDSSC_get_rec_status(p_stream_config)->fixed_frame_len); + for (i = 0; i < CDSSC_get_rec_status(p_stream_config)->fixed_frame_len; i++) + { + Printf("%02x ", CDSSC_get_rx_frame(p_stream_config)[i]); + } + Printf(" \n"); +#else + printf("DEC DATA: %d\n", CDSSC_get_rec_status(p_stream_config)->fixed_frame_len); + for (i = 0; i < CDSSC_get_rec_status(p_stream_config)->fixed_frame_len; i++) + { + printf("%02x ", CDSSC_get_rx_frame(p_stream_config)[i]); + } + printf(" \n"); +#endif + return CDS_ERR_CODE_OK; +} + + +CDS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_driver, uint8_t id) +{ + CDS_ERR_CODE ret; + CDS_StreamConfig* p_stream_config; + + p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_FIX]); + + switch (id) + { + case 0: + UART_TEST_tx_frame_[0] = 'i'; + UART_TEST_tx_frame_[1] = 'd'; + UART_TEST_tx_frame_[2] = '0'; + UART_TEST_tx_frame_[3] = 'a'; + UART_TEST_tx_frame_[4] = 'b'; + UART_TEST_tx_frame_[5] = 0x0d; + UART_TEST_tx_frame_[6] = 0x0a; + CDSSC_set_tx_frame_size(p_stream_config, 7); + break; + case 1: + UART_TEST_tx_frame_[0] = 'i'; + UART_TEST_tx_frame_[1] = 'd'; + UART_TEST_tx_frame_[2] = '1'; + UART_TEST_tx_frame_[3] = 'A'; + UART_TEST_tx_frame_[4] = 'B'; + UART_TEST_tx_frame_[5] = 0x0d; + UART_TEST_tx_frame_[6] = 0x0a; + CDSSC_set_tx_frame_size(p_stream_config, 7); + break; + case 2: + UART_TEST_tx_frame_[0] = 'i'; + UART_TEST_tx_frame_[1] = 'd'; + UART_TEST_tx_frame_[2] = '2'; + UART_TEST_tx_frame_[3] = 0x0d; + UART_TEST_tx_frame_[4] = 0x0a; + CDSSC_set_tx_frame_size(p_stream_config, 5); + break; + default: + UART_TEST_tx_frame_[0] = 'd'; + UART_TEST_tx_frame_[1] = 'e'; + UART_TEST_tx_frame_[2] = 'f'; + UART_TEST_tx_frame_[3] = 'a'; + UART_TEST_tx_frame_[4] = 'u'; + UART_TEST_tx_frame_[5] = 'l'; + UART_TEST_tx_frame_[6] = 't'; + UART_TEST_tx_frame_[7] = 0x0d; + UART_TEST_tx_frame_[8] = 0x0a; + CDSSC_set_tx_frame_size(p_stream_config, 9); + break; + } + + ret = CDS_send_general_cmd(&(uart_test_driver->driver.super), UART_TEST_STREAM_FIX); + if (ret == CDS_ERR_CODE_OK) + { + return CDS_CMD_OK; + } + else + { + return CDS_CMD_DRIVER_SUPER_ERR; + } +} + +#pragma section diff --git a/examples/mobc/src/src_user/driver/etc/uart_test.h b/examples/mobc/src/src_user/component_driver/etc/uart_test.h similarity index 69% rename from examples/mobc/src/src_user/driver/etc/uart_test.h rename to examples/mobc/src/src_user/component_driver/etc/uart_test.h index 193be545c..f10c2379f 100644 --- a/examples/mobc/src/src_user/driver/etc/uart_test.h +++ b/examples/mobc/src/src_user/component_driver/etc/uart_test.h @@ -6,7 +6,7 @@ #define UART_TEST_H_ #include -#include +#include /** * @struct UART_TEST_Info @@ -25,7 +25,7 @@ typedef struct { struct { - DriverSuper super; //!< DriverSuper class + ComponentDriverSuper super; //!< ComponentDriverSuper class UART_Config uart_config; //!< RS422 class } driver; UART_TEST_Info info; @@ -41,23 +41,23 @@ typedef struct * @param uart_test_driver: 初期化するUART_TEST_Driver構造体へのポインタ * @param ch: UART_TESTが接続されているUARTポート番号 * @param rx_buffers: 受信バッファ - * @return DS_INIT_ERR_CODE + * @return CDS_INIT_ERR_CODE */ -DS_INIT_ERR_CODE UART_TEST_init(UART_TEST_Driver* uart_test_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffers[DS_STREAM_MAX]); +CDS_INIT_ERR_CODE UART_TEST_init(UART_TEST_Driver* uart_test_driver, uint8_t ch, CDS_StreamRecBuffer* rx_buffers[CDS_STREAM_MAX]); /** * @brief UART_TESTのデータ(テレメ)受信 * @param uart_test_driver: UART_TEST_Driver構造体へのポインタ - * @return DS_REC_ERR_CODE + * @return CDS_REC_ERR_CODE */ -DS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_driver); +CDS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_driver); /** * @brief UART_TESTへのコマンド送信 * @param uart_test_driver: UART_TEST_Driver構造体へのポインタ * @param id: Cmd id - * @return DS_CMD_ERR_CODE + * @return CDS_CMD_ERR_CODE */ -DS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_driver, uint8_t id); +CDS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_driver, uint8_t id); #endif diff --git a/examples/mobc/src/src_user/driver/mission/.gitkeep b/examples/mobc/src/src_user/component_driver/mission/.gitkeep similarity index 100% rename from examples/mobc/src/src_user/driver/mission/.gitkeep rename to examples/mobc/src/src_user/component_driver/mission/.gitkeep diff --git a/examples/mobc/src/src_user/driver/power/.gitkeep b/examples/mobc/src/src_user/component_driver/power/.gitkeep similarity index 100% rename from examples/mobc/src/src_user/driver/power/.gitkeep rename to examples/mobc/src/src_user/component_driver/power/.gitkeep diff --git a/examples/mobc/src/src_user/driver/prop/.gitkeep b/examples/mobc/src/src_user/component_driver/prop/.gitkeep similarity index 100% rename from examples/mobc/src/src_user/driver/prop/.gitkeep rename to examples/mobc/src/src_user/component_driver/prop/.gitkeep diff --git a/examples/mobc/src/src_user/driver/thermal/.gitkeep b/examples/mobc/src/src_user/component_driver/thermal/.gitkeep similarity index 100% rename from examples/mobc/src/src_user/driver/thermal/.gitkeep rename to examples/mobc/src/src_user/component_driver/thermal/.gitkeep diff --git a/examples/mobc/src/src_user/driver/etc/uart_test.c b/examples/mobc/src/src_user/driver/etc/uart_test.c deleted file mode 100644 index 1cbfe124f..000000000 --- a/examples/mobc/src/src_user/driver/etc/uart_test.c +++ /dev/null @@ -1,209 +0,0 @@ -#pragma section REPRO -/** - * @file - * @brief テスト用UARTのDriver - */ - -#include "uart_test.h" -#include -#include -#include "../../Settings/sils_define.h" -#include "string.h" // for memcpy -#include // SILSでのprint - -// ヘッダーフッター -#define UART_TEST_HEADER_SIZE (8) -#define UART_TEST_FOOTER_SIZE (2) -#define UART_TEST_TX_FRAME_SIZE_MAX (16) - -static const uint8_t UART_TEST_header_[UART_TEST_HEADER_SIZE] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7}; -static const uint8_t UART_TEST_footer_[UART_TEST_FOOTER_SIZE] = {0xBF, 0xBE}; - -#define UART_TEST_STREAM_FIX (0) //!< 固定長 -#define UART_TEST_STREAM_VAR (1) //!< 可変長 - -static uint8_t UART_TEST_tx_frame_[UART_TEST_TX_FRAME_SIZE_MAX]; - -static DS_ERR_CODE UART_TEST_load_driver_super_init_settings_(DriverSuper* p_super); -static DS_ERR_CODE UART_TEST_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver); - - -DS_INIT_ERR_CODE UART_TEST_init(UART_TEST_Driver* uart_test_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffers[DS_STREAM_MAX]) -{ - DS_ERR_CODE ret; - - uart_test_driver->driver.uart_config.ch = ch; - uart_test_driver->driver.uart_config.baudrate = 38400; - uart_test_driver->driver.uart_config.parity_settings = PARITY_SETTINGS_NONE; - uart_test_driver->driver.uart_config.data_length = UART_DATA_LENGTH_8BIT; - uart_test_driver->driver.uart_config.stop_bit = UART_STOP_BIT_1BIT; - - ret = DS_init_streams(&(uart_test_driver->driver.super), - &(uart_test_driver->driver.uart_config), - rx_buffers, - UART_TEST_load_driver_super_init_settings_); - if (ret != DS_ERR_CODE_OK) return DS_INIT_DS_INIT_ERR; - return DS_INIT_OK; -} - - -static DS_ERR_CODE UART_TEST_load_driver_super_init_settings_(DriverSuper* p_super) -{ - DS_StreamConfig* p_stream_config; - - p_super->interface = UART; - - // stream0の設定 - p_stream_config = &(p_super->stream_config[UART_TEST_STREAM_FIX]); - DSSC_enable(p_stream_config); - DSSC_enable_strict_frame_search(p_stream_config); - - // 送信はする - DSSC_set_tx_frame(p_stream_config, UART_TEST_tx_frame_); // 送る直前に中身をmemcpyする - DSSC_set_tx_frame_size(p_stream_config, 0); // 送る直前に値をセットする - - // 定期的な受信はする - DSSC_set_rx_header(p_stream_config, UART_TEST_header_, UART_TEST_HEADER_SIZE); - DSSC_set_rx_footer(p_stream_config, UART_TEST_footer_, UART_TEST_FOOTER_SIZE); - DSSC_set_rx_frame_size(p_stream_config, 12); - DSSC_set_data_analyzer(p_stream_config, UART_TEST_analyze_rec_data_); - - // stream1の設定 - p_stream_config = &(p_super->stream_config[UART_TEST_STREAM_VAR]); - DSSC_enable(p_stream_config); - DSSC_enable_strict_frame_search(p_stream_config); - - // 送信はしない - - // 定期的な受信はする - DSSC_set_rx_header(p_stream_config, UART_TEST_header_, UART_TEST_HEADER_SIZE); - DSSC_set_rx_footer(p_stream_config, UART_TEST_footer_, UART_TEST_FOOTER_SIZE); - DSSC_set_rx_frame_size(p_stream_config, -1); // 可変 - DSSC_set_rx_framelength_pos(p_stream_config, UART_TEST_HEADER_SIZE); - DSSC_set_rx_framelength_type_size(p_stream_config, 2); - DSSC_set_rx_framelength_offset(p_stream_config, UART_TEST_HEADER_SIZE + UART_TEST_FOOTER_SIZE); - DSSC_set_data_analyzer(p_stream_config, UART_TEST_analyze_rec_data_); - - // 定期TLMの監視機能の有効化しない → ので設定上書きなし - - return DS_ERR_CODE_OK; -} - - -DS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_driver) -{ - DS_ERR_CODE ret; - DS_StreamConfig* p_stream_config; - - ret = DS_receive(&(uart_test_driver->driver.super)); - - if (ret != DS_ERR_CODE_OK) return DS_REC_DS_RECEIVE_ERR; - - p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_FIX]); - if (DSSC_get_rec_status(p_stream_config)->status_code == DS_STREAM_REC_STATUS_FIXED_FRAME) - { - ret = DS_analyze_rec_data(&(uart_test_driver->driver.super), UART_TEST_STREAM_FIX, uart_test_driver); - } - - p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_VAR]); - if (DSSC_get_rec_status(p_stream_config)->status_code == DS_STREAM_REC_STATUS_FIXED_FRAME) - { - ret = DS_analyze_rec_data(&(uart_test_driver->driver.super), UART_TEST_STREAM_VAR, uart_test_driver); - } - - // 返り値ぐだぐだだけど,まあテストコードなので... - if (ret != DS_ERR_CODE_OK) return DS_REC_ANALYZE_ERR; - - return DS_REC_OK; -} - - -static DS_ERR_CODE UART_TEST_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver) -{ - UART_TEST_Driver* uart_test_driver = (UART_TEST_Driver*)p_driver; - uint16_t i; - - (void)(uart_test_driver); - -#ifndef SILS_FW - Printf("DEC DATA: %d\n", DSSC_get_rec_status(p_stream_config)->fixed_frame_len); - for (i = 0; i < DSSC_get_rec_status(p_stream_config)->fixed_frame_len; i++) - { - Printf("%02x ", DSSC_get_rx_frame(p_stream_config)[i]); - } - Printf(" \n"); -#else - printf("DEC DATA: %d\n", DSSC_get_rec_status(p_stream_config)->fixed_frame_len); - for (i = 0; i < DSSC_get_rec_status(p_stream_config)->fixed_frame_len; i++) - { - printf("%02x ", DSSC_get_rx_frame(p_stream_config)[i]); - } - printf(" \n"); -#endif - return DS_ERR_CODE_OK; -} - - -DS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_driver, uint8_t id) -{ - DS_ERR_CODE ret; - DS_StreamConfig* p_stream_config; - - p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_FIX]); - - switch (id) - { - case 0: - UART_TEST_tx_frame_[0] = 'i'; - UART_TEST_tx_frame_[1] = 'd'; - UART_TEST_tx_frame_[2] = '0'; - UART_TEST_tx_frame_[3] = 'a'; - UART_TEST_tx_frame_[4] = 'b'; - UART_TEST_tx_frame_[5] = 0x0d; - UART_TEST_tx_frame_[6] = 0x0a; - DSSC_set_tx_frame_size(p_stream_config, 7); - break; - case 1: - UART_TEST_tx_frame_[0] = 'i'; - UART_TEST_tx_frame_[1] = 'd'; - UART_TEST_tx_frame_[2] = '1'; - UART_TEST_tx_frame_[3] = 'A'; - UART_TEST_tx_frame_[4] = 'B'; - UART_TEST_tx_frame_[5] = 0x0d; - UART_TEST_tx_frame_[6] = 0x0a; - DSSC_set_tx_frame_size(p_stream_config, 7); - break; - case 2: - UART_TEST_tx_frame_[0] = 'i'; - UART_TEST_tx_frame_[1] = 'd'; - UART_TEST_tx_frame_[2] = '2'; - UART_TEST_tx_frame_[3] = 0x0d; - UART_TEST_tx_frame_[4] = 0x0a; - DSSC_set_tx_frame_size(p_stream_config, 5); - break; - default: - UART_TEST_tx_frame_[0] = 'd'; - UART_TEST_tx_frame_[1] = 'e'; - UART_TEST_tx_frame_[2] = 'f'; - UART_TEST_tx_frame_[3] = 'a'; - UART_TEST_tx_frame_[4] = 'u'; - UART_TEST_tx_frame_[5] = 'l'; - UART_TEST_tx_frame_[6] = 't'; - UART_TEST_tx_frame_[7] = 0x0d; - UART_TEST_tx_frame_[8] = 0x0a; - DSSC_set_tx_frame_size(p_stream_config, 9); - break; - } - - ret = DS_send_general_cmd(&(uart_test_driver->driver.super), UART_TEST_STREAM_FIX); - if (ret == DS_ERR_CODE_OK) - { - return DS_CMD_OK; - } - else - { - return DS_CMD_DRIVER_SUPER_ERR; - } -} - -#pragma section diff --git a/examples/mobc/src/src_user/tlm_cmd/normal_block_command_definition/nbc_test_bcl.c b/examples/mobc/src/src_user/tlm_cmd/normal_block_command_definition/nbc_test_bcl.c index 1df632cf5..a8fbb0448 100644 --- a/examples/mobc/src/src_user/tlm_cmd/normal_block_command_definition/nbc_test_bcl.c +++ b/examples/mobc/src/src_user/tlm_cmd/normal_block_command_definition/nbc_test_bcl.c @@ -8,7 +8,7 @@ #include #include "../command_definitions.h" -#include "../../driver/aocs/aobc_command_definitions.h" +#include "../../component_driver/aocs/aobc_command_definitions.h" #include "../block_command_definitions.h" void BCL_load_test_bcl(void) diff --git a/examples/mobc/src/src_user/tlm_cmd/telemetry_source.h b/examples/mobc/src/src_user/tlm_cmd/telemetry_source.h index 2f77b4e5b..424f849cf 100644 --- a/examples/mobc/src/src_user/tlm_cmd/telemetry_source.h +++ b/examples/mobc/src/src_user/tlm_cmd/telemetry_source.h @@ -17,8 +17,8 @@ #include #include #include "../applications/app_headers.h" -#include "../driver/aocs/aobc_telemetry_buffer.h" -#include "../driver/com/gs_validate.h" +#include "../component_driver/aocs/aobc_telemetry_buffer.h" +#include "../component_driver/com/gs_validate.h" #include "../Settings/build_settings.h" #endif diff --git a/examples/mobc/src/src_user/tlm_cmd/user_packet_handler.h b/examples/mobc/src/src_user/tlm_cmd/user_packet_handler.h index a2d075cf8..7f6da4ea9 100644 --- a/examples/mobc/src/src_user/tlm_cmd/user_packet_handler.h +++ b/examples/mobc/src/src_user/tlm_cmd/user_packet_handler.h @@ -47,7 +47,7 @@ PH_ACK PH_user_analyze_cmd(const CommonCmdPacket* packet); * ここから Driver を叩いて送信まで行うことになる(実行時間は CA_execute_cmd と同じだけ許容されているので OK) * @param packet: CCP * @retval CCP_CmdRet{CCP_EXEC_SUCCESS, *} など: 無事に転送された.転送先の結果を返す - * @retval CCP_CmdRet{CCP_EXEC_ROUTING_FAILED, *}: 転送失敗(詳細エラーは DriverSuper を参照) + * @retval CCP_CmdRet{CCP_EXEC_ROUTING_FAILED, *}: 転送失敗(詳細エラーは ComponentDriverSuper を参照) */ CCP_CmdRet PH_user_cmd_router(const CommonCmdPacket* packet); diff --git a/examples/subobc/CMakeLists.txt b/examples/subobc/CMakeLists.txt index 3fd380c80..410fb9aec 100644 --- a/examples/subobc/CMakeLists.txt +++ b/examples/subobc/CMakeLists.txt @@ -56,7 +56,7 @@ add_definitions("-DGIT_REVISION_C2A_USER_SHORT=0x${GIT_REVISION_C2A_USER_SHORT}" add_subdirectory(${C2A_CORE_DIR}) add_subdirectory(${C2A_USER_DIR}/applications) -add_subdirectory(${C2A_USER_DIR}/driver) +add_subdirectory(${C2A_USER_DIR}/component_driver) add_subdirectory(${C2A_USER_DIR}/hal) add_subdirectory(${C2A_USER_DIR}/library) add_subdirectory(${C2A_USER_DIR}/Settings) diff --git a/examples/subobc/README.md b/examples/subobc/README.md index 602e46c6d..7838ac570 100644 --- a/examples/subobc/README.md +++ b/examples/subobc/README.md @@ -8,4 +8,4 @@ C2A 間通信の開発のために, [`examples/mobc`](/examples/mobc) とセ - あくまで C2A 間通信開発のためなので,最小限の Tlm, Cmd などしか登録されてないなど,大幅に省略している. - したがって,C2A の User のサンプルとしては, [`examples/mobc`](/examples/mobc) を参照するほうが望ましい. - 一方で, MOBC との通信部分や, sub OBC としての振る舞いについてはこちらを参照すること. -- C2A 間通信については, [`docs/Driver/Communication with Components`](/docs/driver/communication_with_components.md) も参照すること. +- C2A 間通信については, [`docs/Driver/Communication with Components`](/docs/component_driver/communication_with_components.md) も参照すること. diff --git a/examples/subobc/src/src_user/Settings/DriverSuper/driver_buffer_define.h b/examples/subobc/src/src_user/Settings/component_driver_super/driver_buffer_define.h similarity index 69% rename from examples/subobc/src/src_user/Settings/DriverSuper/driver_buffer_define.h rename to examples/subobc/src/src_user/Settings/component_driver_super/driver_buffer_define.h index 03ef3305a..3ba66baed 100644 --- a/examples/subobc/src/src_user/Settings/DriverSuper/driver_buffer_define.h +++ b/examples/subobc/src/src_user/Settings/component_driver_super/driver_buffer_define.h @@ -7,8 +7,8 @@ #include "./driver_super_params.h" -#define DS_STREAM_REC_BUFFER_SIZE_DEFAULT (DS_IF_RX_BUFFER_SIZE * 2) /*!< DS_StreamRecBuffer のバッファサイズのデフォルト値 - UART などの非同期通信はメモリに余力があれば DS_IF_RX_BUFFER_SIZE * 2 を推奨 +#define CDS_STREAM_REC_BUFFER_SIZE_DEFAULT (CDS_IF_RX_BUFFER_SIZE * 2) /*!< CDS_StreamRecBuffer のバッファサイズのデフォルト値 + UART などの非同期通信はメモリに余力があれば CDS_IF_RX_BUFFER_SIZE * 2 を推奨 詳細は dirver_super.c の @note を参照 */ #endif diff --git a/examples/subobc/src/src_user/Settings/DriverSuper/driver_super_params.h b/examples/subobc/src/src_user/Settings/component_driver_super/driver_super_params.h similarity index 63% rename from examples/subobc/src/src_user/Settings/DriverSuper/driver_super_params.h rename to examples/subobc/src/src_user/Settings/component_driver_super/driver_super_params.h index c82fe0a33..6453fdf64 100644 --- a/examples/subobc/src/src_user/Settings/DriverSuper/driver_super_params.h +++ b/examples/subobc/src/src_user/Settings/component_driver_super/driver_super_params.h @@ -1,6 +1,6 @@ /** * @file - * @brief DriverSuperパラメタのオーバーライド用ヘッダー + * @brief ComponentDriverSuperパラメタのオーバーライド用ヘッダー */ #ifndef DRIVER_SUPER_PARAMS_H_ #define DRIVER_SUPER_PARAMS_H_ diff --git a/examples/subobc/src/src_user/applications/driver_instances/di_mobc.c b/examples/subobc/src/src_user/applications/driver_instances/di_mobc.c index 8db5eb741..8a5b244f0 100644 --- a/examples/subobc/src/src_user/applications/driver_instances/di_mobc.c +++ b/examples/subobc/src/src_user/applications/driver_instances/di_mobc.c @@ -8,7 +8,7 @@ #include #include #include "../../Settings/port_config.h" -#include "../../Settings/DriverSuper/driver_buffer_define.h" +#include "../../Settings/component_driver_super/driver_buffer_define.h" #include static RESULT DI_MOBC_init_(void); @@ -20,8 +20,8 @@ static MOBC_Driver mobc_driver_; const MOBC_Driver* const mobc_driver = &mobc_driver_; // バッファ -static DS_StreamRecBuffer DI_MOBC_rx_buffer_; -static uint8_t DI_MOBC_rx_buffer_allocation_[DS_STREAM_REC_BUFFER_SIZE_DEFAULT]; +static CDS_StreamRecBuffer DI_MOBC_rx_buffer_; +static uint8_t DI_MOBC_rx_buffer_allocation_[CDS_STREAM_REC_BUFFER_SIZE_DEFAULT]; static const uint8_t DI_MOBC_kRtTlmPhMaxNumOfProc_ = 4; //!< 一度に送出する最大テレメ数 @@ -33,21 +33,21 @@ AppInfo DI_MOBC_update(void) static RESULT DI_MOBC_init_(void) { - DS_ERR_CODE ret1; - DS_INIT_ERR_CODE ret2; + CDS_ERR_CODE ret1; + CDS_INIT_ERR_CODE ret2; RESULT err = RESULT_OK; - ret1 = DS_init_stream_rec_buffer(&DI_MOBC_rx_buffer_, + ret1 = CDS_init_stream_rec_buffer(&DI_MOBC_rx_buffer_, DI_MOBC_rx_buffer_allocation_, sizeof(DI_MOBC_rx_buffer_allocation_)); - if (ret1 != DS_ERR_CODE_OK) + if (ret1 != CDS_ERR_CODE_OK) { Printf("MOBC buffer init Failed ! %d \n", ret1); err = RESULT_ERR; } ret2 = MOBC_init(&mobc_driver_, PORT_CH_UART_MOBC, &DI_MOBC_rx_buffer_); - if (ret2 != DS_INIT_OK) + if (ret2 != CDS_INIT_OK) { Printf("MOBC init Failed ! %d \n", ret2); err = RESULT_ERR; @@ -58,7 +58,7 @@ static RESULT DI_MOBC_init_(void) static RESULT DI_MOBC_update_(void) { - DS_REC_ERR_CODE ret; + CDS_REC_ERR_CODE ret; ret = MOBC_rec(&mobc_driver_); // TODO: 必要があればここに処理を @@ -86,11 +86,11 @@ static RESULT DI_MOBC_rt_tlm_packet_handler_(void) CommonTlmPacket packet; // FIXME: これは static にする? // static のほうがコンパイル時にアドレスが確定して安全. Out of stack space を回避できる // 一方でメモリ使用量は増える. - mobc_driver_.info.c2a.send_tlm_err_code = DS_CMD_OK; + mobc_driver_.info.c2a.send_tlm_err_code = CDS_CMD_OK; for (i = 0; i < DI_MOBC_kRtTlmPhMaxNumOfProc_; i++) { - DS_CMD_ERR_CODE ret; + CDS_CMD_ERR_CODE ret; // TODO: ここは一部 MW に入れるべきなのかなぁ...? // 最近 C2A の MW の扱いが難しい.いっそなくすか? @@ -119,14 +119,14 @@ static RESULT DI_MOBC_rt_tlm_packet_handler_(void) // AOBC のアノマリ基準は? // 最後に起きたエラーを保存する - mobc_driver_.info.c2a.send_tlm_err_code = DS_CMD_ILLEGAL_PARAMETER; + mobc_driver_.info.c2a.send_tlm_err_code = CDS_CMD_ILLEGAL_PARAMETER; continue; } // TODO: TPC のヘッダを別途設定する必要はないか,ちゃんと確認する.多分ないと思うけど ret = MOBC_send(&mobc_driver_, &packet); - if (ret != DS_CMD_OK) + if (ret != CDS_CMD_OK) { // 最後に起きたエラーを保存する mobc_driver_.info.c2a.send_tlm_err_code = ret; diff --git a/examples/subobc/src/src_user/applications/driver_instances/di_mobc.h b/examples/subobc/src/src_user/applications/driver_instances/di_mobc.h index bb8110b48..1d08bbb02 100644 --- a/examples/subobc/src/src_user/applications/driver_instances/di_mobc.h +++ b/examples/subobc/src/src_user/applications/driver_instances/di_mobc.h @@ -5,7 +5,7 @@ #ifndef DI_MOBC_H_ #define DI_MOBC_H_ -#include "../../driver/etc/mobc.h" +#include "../../component_driver/etc/mobc.h" #include #include diff --git a/examples/subobc/src/src_user/driver/CMakeLists.txt b/examples/subobc/src/src_user/component_driver/CMakeLists.txt similarity index 100% rename from examples/subobc/src/src_user/driver/CMakeLists.txt rename to examples/subobc/src/src_user/component_driver/CMakeLists.txt diff --git a/examples/subobc/src/src_user/driver/etc/mobc.c b/examples/subobc/src/src_user/component_driver/etc/mobc.c similarity index 60% rename from examples/subobc/src/src_user/driver/etc/mobc.c rename to examples/subobc/src/src_user/component_driver/etc/mobc.c index 502d052e1..06723d309 100644 --- a/examples/subobc/src/src_user/driver/etc/mobc.c +++ b/examples/subobc/src/src_user/component_driver/etc/mobc.c @@ -8,8 +8,8 @@ #include "./mobc.h" #include -#include -#include +#include +#include #include #define MOBC_STREAM_TLM_CMD (0) //!< テレコマで使うストリーム @@ -18,14 +18,14 @@ static uint8_t MOBC_tx_frame_[EB90_FRAME_HEADER_SIZE + CTCP_MAX_LEN + EB90_FRAME_FOOTER_SIZE]; -static DS_ERR_CODE MOBC_load_driver_super_init_settings_(DriverSuper* p_super); -static DS_ERR_CODE MOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, +static CDS_ERR_CODE MOBC_load_driver_super_init_settings_(ComponentDriverSuper* p_super); +static CDS_ERR_CODE MOBC_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver); -DS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer) +CDS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, CDS_StreamRecBuffer* rx_buffer) { - DS_ERR_CODE ret; + CDS_ERR_CODE ret; memset(mobc_driver, 0x00, sizeof(MOBC_Driver)); @@ -35,62 +35,62 @@ DS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, DS_StreamRecBuf mobc_driver->driver.uart_config.data_length = UART_DATA_LENGTH_8BIT; mobc_driver->driver.uart_config.stop_bit = UART_STOP_BIT_1BIT; - ret = DS_init(&(mobc_driver->driver.super), + ret = CDS_init(&(mobc_driver->driver.super), &(mobc_driver->driver.uart_config), rx_buffer, MOBC_load_driver_super_init_settings_); - if (ret != DS_ERR_CODE_OK) return DS_INIT_DS_INIT_ERR; - return DS_INIT_OK; + if (ret != CDS_ERR_CODE_OK) return CDS_INIT_CDS_INIT_ERR; + return CDS_INIT_OK; } -static DS_ERR_CODE MOBC_load_driver_super_init_settings_(DriverSuper* p_super) +static CDS_ERR_CODE MOBC_load_driver_super_init_settings_(ComponentDriverSuper* p_super) { - DS_StreamConfig* p_stream_config; + CDS_StreamConfig* p_stream_config; p_super->interface = UART; // stream は 0 のみ p_stream_config = &(p_super->stream_config[MOBC_STREAM_TLM_CMD]); - CTCP_init_dssc(p_stream_config, MOBC_tx_frame_, sizeof(MOBC_tx_frame_), MOBC_analyze_rec_data_); + CTCP_init_cdssc(p_stream_config, MOBC_tx_frame_, sizeof(MOBC_tx_frame_), MOBC_analyze_rec_data_); // 定期 TLM の監視機能の有効化しない → ので設定上書きなし - DSSC_enable(p_stream_config); + CDSSC_enable(p_stream_config); - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -DS_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver) +CDS_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver) { - DS_ERR_CODE ret; - DS_StreamConfig* p_stream_config; + CDS_ERR_CODE ret; + CDS_StreamConfig* p_stream_config; - ret = DS_receive(&(mobc_driver->driver.super)); + ret = CDS_receive(&(mobc_driver->driver.super)); - if (ret != DS_ERR_CODE_OK) return DS_REC_DS_RECEIVE_ERR; + if (ret != CDS_ERR_CODE_OK) return CDS_REC_CDS_RECEIVE_ERR; p_stream_config = &(mobc_driver->driver.super.stream_config[MOBC_STREAM_TLM_CMD]); - if (DSSC_get_rec_status(p_stream_config)->status_code != DS_STREAM_REC_STATUS_FIXED_FRAME) return DS_REC_OK; // 受信せず(TODO: 詳細なエラー処理は一旦しない) + if (CDSSC_get_rec_status(p_stream_config)->status_code != CDS_STREAM_REC_STATUS_FIXED_FRAME) return CDS_REC_OK; // 受信せず(TODO: 詳細なエラー処理は一旦しない) - ret = DS_analyze_rec_data(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD, mobc_driver); + ret = CDS_analyze_rec_data(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD, mobc_driver); - if (ret != DS_ERR_CODE_OK) return DS_REC_ANALYZE_ERR; + if (ret != CDS_ERR_CODE_OK) return CDS_REC_ANALYZE_ERR; - return DS_REC_OK; + return CDS_REC_OK; } -static DS_ERR_CODE MOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver) +static CDS_ERR_CODE MOBC_analyze_rec_data_(CDS_StreamConfig* p_stream_config, void* p_driver) { MOBC_Driver* mobc_driver = (MOBC_Driver*)p_driver; CommonCmdPacket packet; // FIXME: これは static にする? // static のほうがコンパイル時にアドレスが確定して安全. Out of stack space を回避できる // 一方でメモリ使用量は増える. - DS_ERR_CODE ret = CCP_get_ccp_from_dssc(p_stream_config, &packet); - if (ret != DS_ERR_CODE_OK) + CDS_ERR_CODE ret = CCP_get_ccp_from_cdssc(p_stream_config, &packet); + if (ret != CDS_ERR_CODE_OK) { mobc_driver->info.comm.rx_err_code = MOBC_RX_ERR_CODE_INVALID_PACKET; return ret; @@ -98,10 +98,10 @@ static DS_ERR_CODE MOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void mobc_driver->info.comm.rx_err_code = MOBC_RX_ERR_CODE_OK; - if (!EB90_FRAME_is_valid_crc_of_dssc(p_stream_config)) + if (!EB90_FRAME_is_valid_crc_of_cdssc(p_stream_config)) { mobc_driver->info.comm.rx_err_code = MOBC_RX_ERR_CODE_CRC_ERR; - return DS_ERR_CODE_ERR; + return CDS_ERR_CODE_ERR; } // MOBC からのコマンドは以下のパターン @@ -120,30 +120,30 @@ static DS_ERR_CODE MOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void // FIXME: CTCP 大工事が終わったら,返り値をちゃんと見るようにする mobc_driver->info.c2a.ph_ack = PH_analyze_cmd_packet(&packet); - return DS_ERR_CODE_OK; + return CDS_ERR_CODE_OK; } -DS_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet) +CDS_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet) { - DS_ERR_CODE ret; - DS_StreamConfig* p_stream_config; + CDS_ERR_CODE ret; + CDS_StreamConfig* p_stream_config; p_stream_config = &(mobc_driver->driver.super.stream_config[MOBC_STREAM_TLM_CMD]); // tx_frameの設定 - CTP_set_tx_frame_to_dssc(p_stream_config, packet); + CTP_set_tx_frame_to_cdssc(p_stream_config, packet); - ret = DS_send_general_cmd(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD); + ret = CDS_send_general_cmd(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD); - if (ret == DS_ERR_CODE_OK) + if (ret == CDS_ERR_CODE_OK) { - return DS_CMD_OK; + return CDS_CMD_OK; } else { // TODO: エラー処理? - return DS_CMD_DRIVER_SUPER_ERR; + return CDS_CMD_DRIVER_SUPER_ERR; } } diff --git a/examples/subobc/src/src_user/driver/etc/mobc.h b/examples/subobc/src/src_user/component_driver/etc/mobc.h similarity index 72% rename from examples/subobc/src/src_user/driver/etc/mobc.h rename to examples/subobc/src/src_user/component_driver/etc/mobc.h index 8102ab58b..f2e908480 100644 --- a/examples/subobc/src/src_user/driver/etc/mobc.h +++ b/examples/subobc/src/src_user/component_driver/etc/mobc.h @@ -6,7 +6,7 @@ #define MOBC_H_ #include -#include +#include #include #include #include @@ -46,14 +46,14 @@ typedef struct // C2A 情報 struct { - DS_CMD_ERR_CODE send_tlm_err_code; //!< テレメトリ送信時のエラーコード + CDS_CMD_ERR_CODE send_tlm_err_code; //!< テレメトリ送信時のエラーコード PH_ACK ph_ack; //!< 受信したコマンドを PH に渡したときの返り値 } c2a; //!< C2A 情報 // 通信情報 struct { - MOBC_TX_ERR_CODE tx_err_code; //!< DriverSuper ではなく Driver が持つべき通信エラー情報 - MOBC_RX_ERR_CODE rx_err_code; //!< DriverSuper ではなく Driver が持つべき通信エラー情報 + MOBC_TX_ERR_CODE tx_err_code; //!< ComponentDriverSuper ではなく Driver が持つべき通信エラー情報 + MOBC_RX_ERR_CODE rx_err_code; //!< ComponentDriverSuper ではなく Driver が持つべき通信エラー情報 } comm; //!< 通信情報 } MOBC_Info; @@ -66,7 +66,7 @@ typedef struct { struct { - DriverSuper super; //!< DriverSuper class + ComponentDriverSuper super; //!< ComponentDriverSuper class UART_Config uart_config; //!< UART class } driver; MOBC_Info info; @@ -80,25 +80,25 @@ typedef struct * @param mobc_driver: 初期化する MOBC_Driver 構造体へのポインタ * @param ch: MOBC が接続されている UART ポート番号 * @param rx_buffer: 受信バッファ - * @return DS_INIT_ERR_CODE + * @return CDS_INIT_ERR_CODE */ -DS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer); +CDS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, CDS_StreamRecBuffer* rx_buffer); /** * @brief MOBC からのデータ( MOBC → AOBC のコマンド)受信 * @param mobc_driver: MOBC_Driver 構造体へのポインタ - * @return DS_REC_ERR_CODE + * @return CDS_REC_ERR_CODE */ -DS_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver); +CDS_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver); /** * @brief MOBC へのデータ(MOBC → AOBCのテレメ)送信 * @param mobc_driver: MOBC_Driver 構造体へのポインタ * @param packet: 送信する CTP packet - * @return DS_CMD_ERR_CODE + * @return CDS_CMD_ERR_CODE */ -DS_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet); +CDS_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet); #endif diff --git a/examples/subobc/src/src_user/tlm_cmd/user_packet_handler.h b/examples/subobc/src/src_user/tlm_cmd/user_packet_handler.h index d26c7c69e..73f853e9a 100644 --- a/examples/subobc/src/src_user/tlm_cmd/user_packet_handler.h +++ b/examples/subobc/src/src_user/tlm_cmd/user_packet_handler.h @@ -44,7 +44,7 @@ PH_ACK PH_user_analyze_cmd(const CommonCmdPacket* packet); * ここから Driver を叩いて送信まで行うことになる(実行時間は CA_execute_cmd と同じだけ許容されているので OK) * @param packet: CCP * @retval CCP_CmdRet{CCP_EXEC_SUCCESS, *} など: 無事に転送された.転送先の結果を返す - * @retval CCP_CmdRet{CCP_EXEC_ROUTING_FAILED, *}: 転送失敗(詳細エラーは DriverSuper を参照) + * @retval CCP_CmdRet{CCP_EXEC_ROUTING_FAILED, *}: 転送失敗(詳細エラーは ComponentDriverSuper を参照) */ CCP_CmdRet PH_user_cmd_router(const CommonCmdPacket* packet); diff --git a/examples/subobc/sync_with_mobc_example.bat b/examples/subobc/sync_with_mobc_example.bat index 16067ff76..e7f1af286 100644 --- a/examples/subobc/sync_with_mobc_example.bat +++ b/examples/subobc/sync_with_mobc_example.bat @@ -20,7 +20,7 @@ call :sync_file ".\src\src_user\hal\sils_mockup\README.md" "..\mobc\src\src_user call :sync_file ".\src\src_user\hal\sils_mockup\uart_sils.c" "..\mobc\src\src_user\hal\sils_mockup\uart_sils.c" call :sync_file ".\src\src_user\hal\sils_mockup\wdt_sils.c" "..\mobc\src\src_user\hal\sils_mockup\wdt_sils.c" call :sync_file ".\src\src_user\Settings\git_revision_config.h" "..\mobc\src\src_user\Settings\git_revision_config.h" -call :sync_file ".\src\src_user\Settings\DriverSuper\driver_buffer_define.h" "..\mobc\src\src_user\Settings\DriverSuper\driver_buffer_define.h" +call :sync_file ".\src\src_user\Settings\ComponentDriverSuper\driver_buffer_define.h" "..\mobc\src\src_user\Settings\ComponentDriverSuper\driver_buffer_define.h" call :sync_file ".\src\src_user\Settings\tlm_cmd\common_cmd_packet_define.c" "..\mobc\src\src_user\Settings\tlm_cmd\common_cmd_packet_define.c" call :sync_file ".\src\src_user\Settings\tlm_cmd\common_tlm_cmd_packet_define.h" "..\mobc\src\src_user\Settings\tlm_cmd\common_tlm_cmd_packet_define.h" call :sync_file ".\src\src_user\tlm_cmd\block_command_user_settings.c" "..\mobc\src\src_user\tlm_cmd\block_command_user_settings.c"