Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C2A interface #724

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/components/real/cdh/c2a_communication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_
45 changes: 23 additions & 22 deletions src/components/real/cdh/on_board_computer_with_c2a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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); }
Loading