From e3cf55d9e55fba44b0e074714264d174becd1410 Mon Sep 17 00:00:00 2001 From: Satoshi Ikari Date: Thu, 12 Dec 2024 17:14:41 +0900 Subject: [PATCH] Fix C2A interface --- src/components/real/cdh/c2a_communication.hpp | 4 -- .../real/cdh/on_board_computer_with_c2a.cpp | 45 ++++++++++--------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/components/real/cdh/c2a_communication.hpp b/src/components/real/cdh/c2a_communication.hpp index ea7afef13..c749d90e3 100644 --- a/src/components/real/cdh/c2a_communication.hpp +++ b/src/components/real/cdh/c2a_communication.hpp @@ -6,8 +6,6 @@ #ifndef C2A_COMMUNICATION_H_ #define C2A_COMMUNICATION_H_ -namespace s2e::components { - // If the character encoding of C2A is UTF-8, the following functions are not necessary, // and users can directory use SendFromObc_C2A and ReceivedByObc_C2A UART // TODO: Delete these functions since C2A is changed to use UTF-8 @@ -25,6 +23,4 @@ int OBC_C2A_I2cReadRegister(int port_id, const unsigned char i2c_address, unsign int OBC_C2A_GpioWrite(int port_id, const bool is_high); bool OBC_C2A_GpioRead(int port_id); // return false when the port_id is not used -} // namespace s2e::components - #endif // C2A_COMMUNICATION_H_ diff --git a/src/components/real/cdh/on_board_computer_with_c2a.cpp b/src/components/real/cdh/on_board_computer_with_c2a.cpp index 639e87f5e..407c39369 100644 --- a/src/components/real/cdh/on_board_computer_with_c2a.cpp +++ b/src/components/real/cdh/on_board_computer_with_c2a.cpp @@ -133,15 +133,6 @@ int ObcWithC2a::ReceivedByObc_C2A(int port_id, unsigned char* buffer, int offset return port->ReadRx(buffer, offset, length); } -// If the character encoding of C2A is UTF-8, these functions are not necessary, -// and users can directory use SendFromObc_C2A and ReceivedByObc_C2A -int OBC_C2A_SendFromObc(int port_id, unsigned char* buffer, int offset, int length) { - return ObcWithC2a::SendFromObc_C2A(port_id, buffer, offset, length); -} -int OBC_C2A_ReceivedByObc(int port_id, unsigned char* buffer, int offset, int length) { - return ObcWithC2a::ReceivedByObc_C2A(port_id, buffer, offset, length); -} - int ObcWithC2a::I2cConnectPort(int port_id, const unsigned char i2c_address) { if (i2c_com_ports_c2a_[port_id] != nullptr) { // Port already used @@ -212,16 +203,6 @@ int ObcWithC2a::I2cComponentReadCommand(int port_id, const unsigned char i2c_add return 0; } -int OBC_C2A_I2cWriteCommand(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length) { - return ObcWithC2a::I2cWriteCommand(port_id, i2c_address, data, length); -} -int OBC_C2A_I2cWriteRegister(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length) { - return ObcWithC2a::I2cWriteRegister(port_id, i2c_address, data, length); -} -int OBC_C2A_I2cReadRegister(int port_id, const unsigned char i2c_address, unsigned char* data, const unsigned char length) { - return ObcWithC2a::I2cReadRegister(port_id, i2c_address, data, length); -} - int ObcWithC2a::GpioConnectPort(int port_id) { if (gpio_ports_c2a_[port_id] != nullptr) { // Port already used @@ -255,8 +236,28 @@ bool ObcWithC2a::GpioRead_C2A(int port_id) { return port->DigitalRead(); } -int OBC_C2A_GpioWrite(int port_id, const bool is_high) { return ObcWithC2a::GpioWrite_C2A(port_id, is_high); } +} // namespace s2e::components -bool OBC_C2A_GpioRead(int port_id) { return ObcWithC2a::GpioRead_C2A(port_id); } +// C2A用 +// If the character encoding of C2A is UTF-8, these functions are not necessary, +// and users can directory use SendFromObc_C2A and ReceivedByObc_C2A +int OBC_C2A_SendFromObc(int port_id, unsigned char* buffer, int offset, int length) { + return s2e::components::ObcWithC2a::SendFromObc_C2A(port_id, buffer, offset, length); +} +int OBC_C2A_ReceivedByObc(int port_id, unsigned char* buffer, int offset, int length) { + return s2e::components::ObcWithC2a::ReceivedByObc_C2A(port_id, buffer, offset, length); +} -} // namespace s2e::components +int OBC_C2A_I2cWriteCommand(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length) { + return s2e::components::ObcWithC2a::I2cWriteCommand(port_id, i2c_address, data, length); +} +int OBC_C2A_I2cWriteRegister(int port_id, const unsigned char i2c_address, const unsigned char* data, const unsigned char length) { + return s2e::components::ObcWithC2a::I2cWriteRegister(port_id, i2c_address, data, length); +} +int OBC_C2A_I2cReadRegister(int port_id, const unsigned char i2c_address, unsigned char* data, const unsigned char length) { + return s2e::components::ObcWithC2a::I2cReadRegister(port_id, i2c_address, data, length); +} + +int OBC_C2A_GpioWrite(int port_id, const bool is_high) { return s2e::components::ObcWithC2a::GpioWrite_C2A(port_id, is_high); } + +bool OBC_C2A_GpioRead(int port_id) { return s2e::components::ObcWithC2a::GpioRead_C2A(port_id); }