Skip to content

Commit

Permalink
examples/subobc: apply rename migration(DriverSuper -> Framing)
Browse files Browse the repository at this point in the history
  • Loading branch information
sksat committed Oct 5, 2023
1 parent 744b051 commit 9acea1e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 77 deletions.
72 changes: 36 additions & 36 deletions examples/subobc/src/src_user/Drivers/Etc/mobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "./mobc.h"
#include <src_core/tlm_cmd/common_tlm_cmd_packet.h>
#include <src_core/Drivers/Protocol/eb90_frame_for_driver_super.h>
#include <src_core/Drivers/Protocol/common_tlm_cmd_packet_for_driver_super.h>
#include <src_core/framing/framing_eb90_frame.h>
#include <src_core/framing/framing_common_tlm_cmd_packet.h>
#include <string.h>

#define MOBC_STREAM_TLM_CMD (0) //!< テレコマで使うストリーム
Expand All @@ -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 FRM_ERR_CODE MOBC_load_driver_super_init_settings_(Framing* p_framing);
static FRM_ERR_CODE MOBC_analyze_rec_data_(FRM_StreamConfig* p_stream_config,
void* p_driver);


DS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer)
FRM_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, FRM_StreamRecBuffer* rx_buffer)
{
DS_ERR_CODE ret;
FRM_ERR_CODE ret;

memset(mobc_driver, 0x00, sizeof(MOBC_Driver));

Expand All @@ -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 = FRM_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 != FRM_ERR_CODE_OK) return FRM_INIT_FRM_INIT_ERR;
return FRM_INIT_OK;
}


static DS_ERR_CODE MOBC_load_driver_super_init_settings_(DriverSuper* p_super)
static FRM_ERR_CODE MOBC_load_driver_super_init_settings_(Framing* p_framing)
{
DS_StreamConfig* p_stream_config;
FRM_StreamConfig* p_stream_config;

p_super->interface = UART;
p_framing->interface = UART;

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

CTCP_init_dssc(p_stream_config, MOBC_tx_frame_, sizeof(MOBC_tx_frame_), MOBC_analyze_rec_data_);

// 定期 TLM の監視機能の有効化しない → ので設定上書きなし

DSSC_enable(p_stream_config);
FRMSC_enable(p_stream_config);

return DS_ERR_CODE_OK;
return FRM_ERR_CODE_OK;
}


DS_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver)
FRM_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver)
{
DS_ERR_CODE ret;
DS_StreamConfig* p_stream_config;
FRM_ERR_CODE ret;
FRM_StreamConfig* p_stream_config;

ret = DS_receive(&(mobc_driver->driver.super));
ret = FRM_receive(&(mobc_driver->driver.super));

if (ret != DS_ERR_CODE_OK) return DS_REC_DS_RECEIVE_ERR;
if (ret != FRM_ERR_CODE_OK) return FRM_REC_FRM_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 (FRMSC_get_rec_status(p_stream_config)->status_code != FRM_STREAM_REC_STATUS_FIXED_FRAME) return FRM_REC_OK; // 受信せず(TODO: 詳細なエラー処理は一旦しない)

ret = DS_analyze_rec_data(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD, mobc_driver);
ret = FRM_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 != FRM_ERR_CODE_OK) return FRM_REC_ANALYZE_ERR;

return DS_REC_OK;
return FRM_REC_OK;
}


static DS_ERR_CODE MOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver)
static FRM_ERR_CODE MOBC_analyze_rec_data_(FRM_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)
FRM_ERR_CODE ret = CCP_get_ccp_from_dssc(p_stream_config, &packet);
if (ret != FRM_ERR_CODE_OK)
{
mobc_driver->info.comm.rx_err_code = MOBC_RX_ERR_CODE_INVALID_PACKET;
return ret;
Expand All @@ -101,7 +101,7 @@ static DS_ERR_CODE MOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config, void
if (!EB90_FRAME_is_valid_crc_of_dssc(p_stream_config))
{
mobc_driver->info.comm.rx_err_code = MOBC_RX_ERR_CODE_CRC_ERR;
return DS_ERR_CODE_ERR;
return FRM_ERR_CODE_ERR;
}

// MOBC からのコマンドは以下のパターン
Expand All @@ -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 FRM_ERR_CODE_OK;
}


DS_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet)
FRM_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet)
{
DS_ERR_CODE ret;
DS_StreamConfig* p_stream_config;
FRM_ERR_CODE ret;
FRM_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);

ret = DS_send_general_cmd(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD);
ret = FRM_send_general_cmd(&(mobc_driver->driver.super), MOBC_STREAM_TLM_CMD);

if (ret == DS_ERR_CODE_OK)
if (ret == FRM_ERR_CODE_OK)
{
return DS_CMD_OK;
return FRM_CMD_OK;
}
else
{
// TODO: エラー処理?
return DS_CMD_DRIVER_SUPER_ERR;
return FRM_CMD_DRIVER_SUPER_ERR;
}
}

Expand Down
22 changes: 11 additions & 11 deletions examples/subobc/src/src_user/Drivers/Etc/mobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define MOBC_H_

#include <src_core/hal/uart.h>
#include <src_core/Drivers/Super/driver_super.h>
#include <src_core/framing/framing.h>
#include <src_core/system/time_manager/obc_time.h>
#include <src_core/tlm_cmd/common_tlm_packet.h>
#include <src_core/tlm_cmd/packet_handler.h>
Expand Down Expand Up @@ -46,14 +46,14 @@ typedef struct
// C2A 情報
struct
{
DS_CMD_ERR_CODE send_tlm_err_code; //!< テレメトリ送信時のエラーコード
FRM_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; //!< Framing ではなく Driver が持つべき通信エラー情報
MOBC_RX_ERR_CODE rx_err_code; //!< Framing ではなく Driver が持つべき通信エラー情報
} comm; //!< 通信情報
} MOBC_Info;

Expand All @@ -66,7 +66,7 @@ typedef struct
{
struct
{
DriverSuper super; //!< DriverSuper class
Framing super; //!< Framing class
UART_Config uart_config; //!< UART class
} driver;
MOBC_Info info;
Expand All @@ -80,25 +80,25 @@ typedef struct
* @param mobc_driver: 初期化する MOBC_Driver 構造体へのポインタ
* @param ch: MOBC が接続されている UART ポート番号
* @param rx_buffer: 受信バッファ
* @return DS_INIT_ERR_CODE
* @return FRM_INIT_ERR_CODE
*/
DS_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer);
FRM_INIT_ERR_CODE MOBC_init(MOBC_Driver* mobc_driver, uint8_t ch, FRM_StreamRecBuffer* rx_buffer);


/**
* @brief MOBC からのデータ( MOBC → AOBC のコマンド)受信
* @param mobc_driver: MOBC_Driver 構造体へのポインタ
* @return DS_REC_ERR_CODE
* @return FRM_REC_ERR_CODE
*/
DS_REC_ERR_CODE MOBC_rec(MOBC_Driver* mobc_driver);
FRM_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 FRM_CMD_ERR_CODE
*/
DS_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet);
FRM_CMD_ERR_CODE MOBC_send(MOBC_Driver* mobc_driver, const CommonTlmPacket* packet);

#endif

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* @file
* @brief Driver の各種バッファサイズなどの定義
*/
#ifndef DRIVER_BUFFER_DEFINE_H_
#define DRIVER_BUFFER_DEFINE_H_
#ifndef FRAMING_BUFFER_DEFINE_H_
#define FRAMING_BUFFER_DEFINE_H_

#include "./driver_super_params.h"
#include "./framing_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 FRM_STREAM_REC_BUFFER_SIZE_DEFAULT (FRM_IF_RX_BUFFER_SIZE * 2) /*!< FRM_StreamRecBuffer のバッファサイズのデフォルト値
UART などの非同期通信はメモリに余力があれば FRM_IF_RX_BUFFER_SIZE * 2 を推奨
詳細は dirver_super.c @note を参照 */

#endif
10 changes: 10 additions & 0 deletions examples/subobc/src/src_user/Settings/framing/framing_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @file
* @brief Framingパラメタのオーバーライド用ヘッダー
*/
#ifndef FRAMING_PARAMS_H_
#define FRAMING_PARAMS_H_

// Core のデフォルト設定をそのまま使う

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <src_core/tlm_cmd/packet_handler.h>
#include <src_core/library/print.h>
#include "../../Settings/port_config.h"
#include "../../Settings/DriverSuper/driver_buffer_define.h"
#include "../../Settings/framing/framing_buffer_define.h"
#include <src_core/library/result.h>

static RESULT DI_MOBC_init_(void);
Expand All @@ -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 FRM_StreamRecBuffer DI_MOBC_rx_buffer_;
static uint8_t DI_MOBC_rx_buffer_allocation_[FRM_STREAM_REC_BUFFER_SIZE_DEFAULT];

static const uint8_t DI_MOBC_kRtTlmPhMaxNumOfProc_ = 4; //!< 一度に送出する最大テレメ数

Expand All @@ -33,21 +33,21 @@ AppInfo DI_MOBC_update(void)

static RESULT DI_MOBC_init_(void)
{
DS_ERR_CODE ret1;
DS_INIT_ERR_CODE ret2;
FRM_ERR_CODE ret1;
FRM_INIT_ERR_CODE ret2;
RESULT err = RESULT_OK;

ret1 = DS_init_stream_rec_buffer(&DI_MOBC_rx_buffer_,
ret1 = FRM_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 != FRM_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 != FRM_INIT_OK)
{
Printf("MOBC init Failed ! %d \n", ret2);
err = RESULT_ERR;
Expand All @@ -58,7 +58,7 @@ static RESULT DI_MOBC_init_(void)

static RESULT DI_MOBC_update_(void)
{
DS_REC_ERR_CODE ret;
FRM_REC_ERR_CODE ret;
ret = MOBC_rec(&mobc_driver_);

// TODO: 必要があればここに処理を
Expand Down Expand Up @@ -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 = FRM_CMD_OK;

for (i = 0; i < DI_MOBC_kRtTlmPhMaxNumOfProc_; i++)
{
DS_CMD_ERR_CODE ret;
FRM_CMD_ERR_CODE ret;

// TODO: ここは一部 MW に入れるべきなのかなぁ...?
// 最近 C2A の MW の扱いが難しい.いっそなくすか?
Expand Down Expand Up @@ -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 = FRM_CMD_ILLEGAL_PARAMETER;
continue;
}

// TODO: TPC のヘッダを別途設定する必要はないか,ちゃんと確認する.多分ないと思うけど

ret = MOBC_send(&mobc_driver_, &packet);
if (ret != DS_CMD_OK)
if (ret != FRM_CMD_OK)
{
// 最後に起きたエラーを保存する
mobc_driver_.info.c2a.send_tlm_err_code = ret;
Expand Down
2 changes: 1 addition & 1 deletion examples/subobc/src/src_user/tlm_cmd/user_packet_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, *}: 転送失敗(詳細エラーは Framing を参照)
*/
CCP_CmdRet PH_user_cmd_router(const CommonCmdPacket* packet);

Expand Down
2 changes: 1 addition & 1 deletion examples/subobc/sync_with_mobc_example.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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\framing\driver_buffer_define.h" "..\mobc\src\src_user\Settings\framing\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"
Expand Down

0 comments on commit 9acea1e

Please sign in to comment.