parent
a42077bef8
commit
43c5c7ff83
|
@ -236,7 +236,7 @@ int sr5ReadData(ts_channel_s *tsChannel, uint8_t * buffer, int size) {
|
|||
}
|
||||
#endif // EFI_PROD_CODE || EFI_SIMULATOR
|
||||
|
||||
static void sr5WriteCrcPacketSmall(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size) {
|
||||
void sr5WriteCrcPacketSmall(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size) {
|
||||
auto scratchBuffer = tsChannel->scratchBuffer;
|
||||
|
||||
// don't transmit too large a buffer
|
||||
|
@ -265,7 +265,7 @@ static void sr5WriteCrcPacketSmall(ts_channel_s* tsChannel, uint8_t responseCode
|
|||
sr5WriteData(tsChannel, reinterpret_cast<uint8_t*>(scratchBuffer), size + 7);
|
||||
}
|
||||
|
||||
static void sr5WriteCrcPacketLarge(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size) {
|
||||
void sr5WriteCrcPacketLarge(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size) {
|
||||
uint8_t headerBuffer[3];
|
||||
uint8_t crcBuffer[4];
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ bool stopTsPort(ts_channel_s *tsChannel);
|
|||
#define SR5_READ_TIMEOUT TIME_MS2I(1000)
|
||||
|
||||
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size);
|
||||
void sr5WriteCrcPacketSmall(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size);
|
||||
void sr5WriteCrcPacketLarge(ts_channel_s* tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size);
|
||||
void sr5WriteCrcPacket(ts_channel_s *tsChannel, uint8_t responseCode, const uint8_t* buf, size_t size);
|
||||
void sr5SendResponse(ts_channel_s *tsChannel, ts_response_format_e mode, const uint8_t * buffer, int size);
|
||||
void sendOkResponse(ts_channel_s *tsChannel, ts_response_format_e mode);
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
extern int sr5TestWriteDataIndex;
|
||||
extern uint8_t st5TestBuffer[16000];
|
||||
|
||||
TEST(binary, testWriteCrc) {
|
||||
sr5TestWriteDataIndex = 0;
|
||||
|
||||
#define CODE 2
|
||||
#define PAYLOAD "123"
|
||||
#define SIZE strlen(PAYLOAD)
|
||||
|
||||
sr5WriteCrcPacket(nullptr, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
||||
static void assertCrcPacket() {
|
||||
ASSERT_EQ(sr5TestWriteDataIndex, SIZE + 7);
|
||||
|
||||
// todo: proper uint16 comparison
|
||||
|
@ -28,6 +26,21 @@ TEST(binary, testWriteCrc) {
|
|||
ASSERT_EQ(st5TestBuffer[7], 68);
|
||||
ASSERT_EQ(st5TestBuffer[8], 173);
|
||||
ASSERT_EQ(st5TestBuffer[9], 87);
|
||||
}
|
||||
|
||||
|
||||
TEST(binary, testWriteCrc) {
|
||||
|
||||
sr5TestWriteDataIndex = 0;
|
||||
sr5WriteCrcPacket(nullptr, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
||||
assertCrcPacket();
|
||||
|
||||
sr5TestWriteDataIndex = 0;
|
||||
sr5WriteCrcPacketLarge(nullptr, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
||||
assertCrcPacket();
|
||||
|
||||
sr5TestWriteDataIndex = 0;
|
||||
// sr5WriteCrcPacketSmall(nullptr, CODE, (const uint8_t * )PAYLOAD, SIZE);
|
||||
// assertCrcPacket();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue