Add link parameter
This commit is contained in:
parent
419908e5ef
commit
5a1600e24f
8 changed files with 171 additions and 162 deletions
|
@ -102,19 +102,19 @@ static uint32_t crc32_byte(uint8_t *p, uint32_t bytelength)
|
|||
return (crc ^ 0xffffffff);
|
||||
}
|
||||
|
||||
void validator_recv_frame(uint8_t* data, uint16_t size) {
|
||||
void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size) {
|
||||
if (size > 4) {
|
||||
uint32_t frame_crc;
|
||||
memcpy(&frame_crc, data + size -4, 4);
|
||||
uint32_t expected_crc = crc32_byte(data, size - 4);
|
||||
if (frame_crc == expected_crc) {
|
||||
route_incoming_frame(data, size-4);
|
||||
route_incoming_frame(link, data, size-4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void validator_send_frame(uint8_t* data, uint16_t size) {
|
||||
void validator_send_frame(uint8_t link, uint8_t* data, uint16_t size) {
|
||||
uint32_t crc = crc32_byte(data, size);
|
||||
memcpy(data + size, &crc, 4);
|
||||
send_frame(data, size + 4);
|
||||
send_frame(link, data, size + 4);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue