This commit is contained in:
2025-02-19 20:00:14 +08:00
3 changed files with 79 additions and 28 deletions

View File

@@ -245,6 +245,8 @@ static PyObject *serial_send(PyObject *self, PyObject *args)
// 拷贝该帧对应数据段
memcpy(send_buffer + HEADER_SIZE, data + offset, data_len);
printf("Received frame: seq=%d, len=%d\r\n", frame_counter, data_len);
// 计算 CRC32 校验和
uint32_t crc = calculate_crc32(send_buffer, HEADER_SIZE + DATA_SIZE + FEC_SIZE);
memcpy(send_buffer + HEADER_SIZE + DATA_SIZE + FEC_SIZE, &crc, CHECKSUM_SIZE);