some minor formating and naming

This commit is contained in:
Oskar Weigl
2017-11-07 20:10:34 -08:00
parent 8d4eca1145
commit 2069462354
2 changed files with 8 additions and 9 deletions
+2 -3
View File
@@ -210,8 +210,8 @@ public:
while (length) {
size_t chunk = length < USB_TX_DATA_SIZE ? length : USB_TX_DATA_SIZE;
while (CDC_Transmit_FS(
const_cast<uint8_t*>(buffer) /* casting this const away is safe because...
well... it's not actually. Stupid STM. */, chunk) != USBD_OK)
const_cast<uint8_t*>(buffer) /* casting this const away is safe because...
well... it's not actually. Stupid STM. */, chunk) != USBD_OK)
osDelay(1);
buffer += chunk;
length -= chunk;
@@ -300,7 +300,6 @@ void communication_task(void const * argument) {
// We dont use interrupts to fetch the data, instead we periodically read
// data out of the circular buffer into a parse buffer, controlled by a state machine
HAL_UART_Receive_DMA(&huart4, dma_circ_buffer, sizeof(dma_circ_buffer));
uint32_t last_rcv_idx = UART_RX_BUFFER_SIZE - huart4.hdmarx->Instance->NDTR;
// Re-run state-machine forever
+6 -6
View File
@@ -209,16 +209,16 @@ int BidirectionalPacketBasedChannel::process_packet(const uint8_t* buffer, size_
if (!endpoint)
return -1;
// Verify packet footer. The expected footer value depends on the selected endpoint.
// Verify packet trailer. The expected trailer value depends on the selected endpoint.
// For endpoint 0 this is just the protocol version, for all other endpoints it's a
// CRC over the entire JSON descriptor tree (this may change in future versions).
uint16_t expected_footer = endpoint_id ? json_crc_ : PROTOCOL_VERSION;
uint16_t actual_footer = buffer[length - 2] | (buffer[length - 1] << 8);
if (expected_footer != actual_footer) {
LOG_PROTO("footer mismatch for endpoint %d: expected %04x, got %04x\r\n", endpoint_id, expected_footer, actual_footer);
uint16_t expected_trailer = endpoint_id ? json_crc_ : PROTOCOL_VERSION;
uint16_t actual_trailer = buffer[length - 2] | (buffer[length - 1] << 8);
if (expected_trailer != actual_trailer) {
LOG_PROTO("trailer mismatch for endpoint %d: expected %04x, got %04x\r\n", endpoint_id, expected_trailer, actual_trailer);
return -1;
}
LOG_PROTO("footer ok\r\n");
LOG_PROTO("trailer ok\r\n");
// TODO: if more bytes than the MTU were requested, should we abort or just return as much as possible?