Skip to content

Commit

Permalink
examples/mobc: 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 7844633 commit 60ae11b
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 276 deletions.
76 changes: 38 additions & 38 deletions examples/mobc/src/src_user/Drivers/Aocs/aobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "./aobc_telemetry_buffer.h"
#include <src_core/tlm_cmd/common_tlm_cmd_packet.h>
#include <src_core/tlm_cmd/common_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 AOBC_STREAM_TLM_CMD (0) //!< テレコマで使うストリーム
Expand All @@ -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 FRM_ERR_CODE AOBC_load_driver_super_init_settings_(Framing* p_framing);
static FRM_ERR_CODE AOBC_analyze_rec_data_(FRM_StreamConfig* p_stream_config,
void* p_driver);

DS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer)
FRM_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, FRM_StreamRecBuffer* rx_buffer)
{
DS_ERR_CODE ret;
FRM_ERR_CODE ret;

memset(aobc_driver, 0x00, sizeof(*aobc_driver));
AOBC_init_tlm_buffer(aobc_driver);
Expand All @@ -36,55 +36,55 @@ 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 = FRM_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 != FRM_ERR_CODE_OK) return FRM_INIT_FRM_INIT_ERR;
return FRM_INIT_OK;
}


static DS_ERR_CODE AOBC_load_driver_super_init_settings_(DriverSuper* p_super)
static FRM_ERR_CODE AOBC_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[AOBC_STREAM_TLM_CMD]);
p_stream_config = &(p_framing->stream_config[AOBC_STREAM_TLM_CMD]);

CTCP_init_dssc(p_stream_config, AOBC_tx_frame_, sizeof(AOBC_tx_frame_), AOBC_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 AOBC_rec(AOBC_Driver* aobc_driver)
FRM_REC_ERR_CODE AOBC_rec(AOBC_Driver* aobc_driver)
{
DS_ERR_CODE ret;
DS_StreamConfig* p_stream_config;
FRM_ERR_CODE ret;
FRM_StreamConfig* p_stream_config;

ret = DS_receive(&(aobc_driver->driver.super));
ret = FRM_receive(&(aobc_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 = &(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 (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(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD, aobc_driver);
ret = FRM_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 != FRM_ERR_CODE_OK) return FRM_REC_ANALYZE_ERR;

return DS_REC_OK;
return FRM_REC_OK;
}


static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config,
static FRM_ERR_CODE AOBC_analyze_rec_data_(FRM_StreamConfig* p_stream_config,
void* p_driver)
{
AOBC_Driver* aobc_driver = (AOBC_Driver*)p_driver;
Expand All @@ -94,7 +94,7 @@ static DS_ERR_CODE AOBC_analyze_rec_data_(DS_StreamConfig* p_stream_config,
if (!EB90_FRAME_is_valid_crc_of_dssc(p_stream_config))
{
aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_CRC_ERR;
return DS_ERR_CODE_ERR;
return FRM_ERR_CODE_ERR;
}

return AOBC_buffer_tlm_packet(p_stream_config, aobc_driver);
Expand All @@ -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 FRM_ERR_CODE AOBC_analyze_rec_data_(FRM_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 = FRM_ISSLFMT_get_tlm_version(p_stream_config);
uint32_t tlm_id = FRM_ISSLFMT_get_tlm_id(tlm_ver, p_stream_config);

aobc_driver->info.comm.rx_err_code = AOBC_RX_ERR_CODE_OK;

Expand All @@ -119,16 +119,16 @@ 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 FRM_ERR_CODE_OK;
}
}
#endif


DS_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet)
FRM_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet)
{
DS_ERR_CODE ret;
DS_StreamConfig* p_stream_config;
FRM_ERR_CODE ret;
FRM_StreamConfig* p_stream_config;
AOBC_CMD_CODE cmd_code;

p_stream_config = &(aobc_driver->driver.super.stream_config[AOBC_STREAM_TLM_CMD]);
Expand All @@ -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 = FRM_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 = FRM_send_general_cmd(&(aobc_driver->driver.super), AOBC_STREAM_TLM_CMD);
break;
}

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
16 changes: 8 additions & 8 deletions examples/mobc/src/src_user/Drivers/Aocs/aobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define AOBC_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_cmd_packet.h>
#include "./aobc_telemetry_data_definitions.h"
Expand Down Expand Up @@ -64,7 +64,7 @@ struct AOBC_Driver
{
struct
{
DriverSuper super; //!< DriverSuper class
Framing super; //!< Framing class
UART_Config uart_config; //!< RS422 class
} driver;
AOBC_Info info;
Expand All @@ -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 FRM_INIT_ERR_CODE
*/
DS_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffer);
FRM_INIT_ERR_CODE AOBC_init(AOBC_Driver* aobc_driver, uint8_t ch, FRM_StreamRecBuffer* rx_buffer);

/**
* @brief AOBC のデータ(テレメ)受信
* @param aobc_driver: AOBC_Driver 構造体へのポインタ
* @return DS_REC_ERR_CODE
* @return FRM_REC_ERR_CODE
*/
DS_REC_ERR_CODE AOBC_rec(AOBC_Driver* aobc_driver);
FRM_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 FRM_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);
FRM_CMD_ERR_CODE AOBC_send_cmd(AOBC_Driver* aobc_driver, const CommonCmdPacket* packet);

#endif
22 changes: 11 additions & 11 deletions examples/mobc/src/src_user/Drivers/Aocs/aobc_telemetry_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* @brief テレメトリバッファー(テレメ中継)
* @note このコードは自動生成されています!
*/
#include <src_core/Drivers/Protocol/common_tlm_cmd_packet_for_driver_super.h>
#include <src_core/framing/framing_common_tlm_cmd_packet.h>
#include "./aobc_telemetry_definitions.h"
#include "./aobc_telemetry_buffer.h"
#include "./aobc.h"
#include <string.h>

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 FRM_ERR_CODE AOBC_analyze_tlm_aobc_aobc_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver);
static FRM_ERR_CODE AOBC_analyze_tlm_aobc_hk_(const CommonTlmPacket* packet, AOBC_TLM_CODE tlm_id, AOBC_Driver* aobc_driver);

static CommonTlmPacket AOBC_ctp_;

Expand All @@ -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)
FRM_ERR_CODE AOBC_buffer_tlm_packet(FRM_StreamConfig* p_stream_config, AOBC_Driver* aobc_driver)
{
AOBC_TLM_CODE tlm_id;
DS_ERR_CODE ret;
FRM_ERR_CODE ret;

ret = CTP_get_ctp_from_dssc(p_stream_config, &AOBC_ctp_);
if (ret != DS_ERR_CODE_OK) return ret;
if (ret != FRM_ERR_CODE_OK) return ret;

tlm_id = (AOBC_TLM_CODE)CTP_get_id(&AOBC_ctp_);

Expand All @@ -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 FRM_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 FRM_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;
Expand Down Expand Up @@ -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 FRM_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 FRM_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;
Expand Down Expand Up @@ -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 FRM_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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define AOBC_TELEMETRY_BUFFER_H_

#include "./aobc_telemetry_definitions.h"
#include <src_core/Drivers/Super/driver_super.h>
#include <src_core/framing/framing.h>
#include <src_core/tlm_cmd/common_tlm_packet.h>
#include <src_core/tlm_cmd/telemetry_frame.h>

Expand All @@ -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);
FRM_ERR_CODE AOBC_buffer_tlm_packet(FRM_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);

Expand Down
Loading

0 comments on commit 60ae11b

Please sign in to comment.