Skip to content

Commit

Permalink
Merge pull request #505 from ut-issl/feature/fix_name_of_uart_test_in…
Browse files Browse the repository at this point in the history
…stance

uart_test_instance のリネーム
  • Loading branch information
meltingrabbit authored Mar 4, 2023
2 parents 92ef862 + b63d987 commit 7bd88a9
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ static void UART_TEST_update_(void);
// static int UART_TEST_unset_rec_flag_(uint32_t no);
// static int UART_TEST_is_rec_flag_up_(uint32_t no);

// FIXME: インスタンス名
static UART_TEST_Driver uart_test_instance_;
const UART_TEST_Driver* const uart_test_instance = &uart_test_instance_;
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_;
Expand Down Expand Up @@ -77,7 +76,7 @@ static void UART_TEST_init_(void)
rx_buffers[0] = &DI_UART_TEST_rx_buffer_0_;
rx_buffers[1] = &DI_UART_TEST_rx_buffer_1_;

ret2 = UART_TEST_init(&uart_test_instance_, PORT_CH_UART_TEST, rx_buffers);
ret2 = UART_TEST_init(&uart_test_driver_, PORT_CH_UART_TEST, rx_buffers);
if (ret2 != DS_INIT_OK)
{
Printf("UART_TEST init Failed! Err:%d \n", ret2);
Expand All @@ -93,7 +92,7 @@ static void UART_TEST_update_(void)
{
DS_REC_ERR_CODE ret;

ret = UART_TEST_rec(&uart_test_instance_);
ret = UART_TEST_rec(&uart_test_driver_);

// TODO: エラー処理
(void)ret;
Expand Down Expand Up @@ -128,7 +127,7 @@ CCP_CmdRet Cmd_UART_TEST_SEND_TEST(const CommonCmdPacket* packet)

id = param[0];

ret = UART_TEST_send(&uart_test_instance_, id);
ret = UART_TEST_send(&uart_test_driver_, id);
return DS_conv_cmd_err_to_ccp_cmd_ret(ret);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <src_core/System/ApplicationManager/app_info.h>
#include <src_core/TlmCmd/common_cmd_packet.h>

extern const UART_TEST_Driver* const uart_test_instance;
extern const UART_TEST_Driver* const uart_test_driver;

// アプリケーション
AppInfo UART_TEST_update(void);
Expand Down
38 changes: 19 additions & 19 deletions Examples/minimum_user/src/src_user/Drivers/Etc/uart_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ static DS_ERR_CODE UART_TEST_load_driver_super_init_settings_(DriverSuper* p_sup
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_instance, uint8_t ch, DS_StreamRecBuffer* rx_buffers[DS_STREAM_MAX])
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_instance->driver.uart_config.ch = ch;
uart_test_instance->driver.uart_config.baudrate = 38400;
uart_test_instance->driver.uart_config.parity_settings = PARITY_SETTINGS_NONE;
uart_test_instance->driver.uart_config.data_length = UART_DATA_LENGTH_8BIT;
uart_test_instance->driver.uart_config.stop_bit = UART_STOP_BIT_1BIT;
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_instance->driver.super),
&(uart_test_instance->driver.uart_config),
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;
Expand Down Expand Up @@ -90,25 +90,25 @@ static DS_ERR_CODE UART_TEST_load_driver_super_init_settings_(DriverSuper* p_sup
}


DS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_instance)
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_instance->driver.super));
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_instance->driver.super.stream_config[UART_TEST_STREAM_FIX]);
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_instance->driver.super), UART_TEST_STREAM_FIX, uart_test_instance);
ret = DS_analyze_rec_data(&(uart_test_driver->driver.super), UART_TEST_STREAM_FIX, uart_test_driver);
}

p_stream_config = &(uart_test_instance->driver.super.stream_config[UART_TEST_STREAM_VAR]);
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_instance->driver.super), UART_TEST_STREAM_VAR, uart_test_instance);
ret = DS_analyze_rec_data(&(uart_test_driver->driver.super), UART_TEST_STREAM_VAR, uart_test_driver);
}

// 返り値ぐだぐだだけど,まあテストコードなので...
Expand All @@ -120,10 +120,10 @@ DS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_instance)

static DS_ERR_CODE UART_TEST_analyze_rec_data_(DS_StreamConfig* p_stream_config, void* p_driver)
{
UART_TEST_Driver* uart_test_instance = (UART_TEST_Driver*)p_driver;
UART_TEST_Driver* uart_test_driver = (UART_TEST_Driver*)p_driver;
uint16_t i;

(void)(uart_test_instance);
(void)(uart_test_driver);

#ifndef SILS_FW
Printf("DEC DATA: %d\n", DSSC_get_rec_status(p_stream_config)->fixed_frame_len);
Expand All @@ -144,12 +144,12 @@ static DS_ERR_CODE UART_TEST_analyze_rec_data_(DS_StreamConfig* p_stream_config,
}


DS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_instance, uint8_t id)
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_instance->driver.super.stream_config[UART_TEST_STREAM_FIX]);
p_stream_config = &(uart_test_driver->driver.super.stream_config[UART_TEST_STREAM_FIX]);

switch (id)
{
Expand Down Expand Up @@ -195,7 +195,7 @@ DS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_instance, uint8_t id)
break;
}

ret = DS_send_general_cmd(&(uart_test_instance->driver.super), UART_TEST_STREAM_FIX);
ret = DS_send_general_cmd(&(uart_test_driver->driver.super), UART_TEST_STREAM_FIX);
if (ret == DS_ERR_CODE_OK)
{
return DS_CMD_OK;
Expand Down
18 changes: 9 additions & 9 deletions Examples/minimum_user/src/src_user/Drivers/Etc/uart_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ typedef struct
* @brief UART_TEST初期化
*
* UART_TEST_Driver構造体のポインタを渡すことでポートを初期化し,UART_TEST_Driverの各メンバも初期化する
* @param uart_test_instance: 初期化するUART_TEST_Driver構造体へのポインタ
* @param ch: UART_TESTが接続されているUARTポート番号
* @param rx_buffers: 受信バッファ
* @param uart_test_driver: 初期化するUART_TEST_Driver構造体へのポインタ
* @param ch: UART_TESTが接続されているUARTポート番号
* @param rx_buffers: 受信バッファ
* @return DS_INIT_ERR_CODE
*/
DS_INIT_ERR_CODE UART_TEST_init(UART_TEST_Driver* uart_test_instance, uint8_t ch, DS_StreamRecBuffer* rx_buffers[DS_STREAM_MAX]);
DS_INIT_ERR_CODE UART_TEST_init(UART_TEST_Driver* uart_test_driver, uint8_t ch, DS_StreamRecBuffer* rx_buffers[DS_STREAM_MAX]);

/**
* @brief UART_TESTのデータ(テレメ)受信
* @param uart_test_instance: UART_TEST_Driver構造体へのポインタ
* @param uart_test_driver: UART_TEST_Driver構造体へのポインタ
* @return DS_REC_ERR_CODE
*/
DS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_instance);
DS_REC_ERR_CODE UART_TEST_rec(UART_TEST_Driver* uart_test_driver);

/**
* @brief UART_TESTへのコマンド送信
* @param uart_test_instance: UART_TEST_Driver構造体へのポインタ
* @param id: Cmd id
* @param uart_test_driver: UART_TEST_Driver構造体へのポインタ
* @param id: Cmd id
* @return DS_CMD_ERR_CODE
*/
DS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_instance, uint8_t id);
DS_CMD_ERR_CODE UART_TEST_send(UART_TEST_Driver* uart_test_driver, uint8_t id);

#endif
Loading

0 comments on commit 7bd88a9

Please sign in to comment.