File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 SEARCHING_FOR_SOF ,
2424 RECEIVING_ID_CONTROL ,
2525 RECEIVING_SEQ ,
26- RECEIVING_LENGTH ,
26+ RECEIVING_LENGTH_MSB ,
27+ RECEIVING_LENGTH_LSB ,
2728 RECEIVING_PAYLOAD ,
2829 RECEIVING_CHECKSUM_3 ,
2930 RECEIVING_CHECKSUM_2 ,
@@ -493,15 +494,26 @@ static void rx_byte(struct min_context *self, uint8_t byte)
493494 }
494495 else {
495496 self -> rx_frame_seq = 0 ;
496- self -> rx_frame_state = RECEIVING_LENGTH ;
497+ self -> rx_frame_state = RECEIVING_LENGTH_MSB ;
497498 }
498499 break ;
499500 case RECEIVING_SEQ :
500501 self -> rx_frame_seq = byte ;
501502 crc32_step (& self -> rx_checksum , byte );
502- self -> rx_frame_state = RECEIVING_LENGTH ;
503+ self -> rx_frame_state = RECEIVING_LENGTH_MSB ;
503504 break ;
504- case RECEIVING_LENGTH :
505+ case RECEIVING_LENGTH_MSB :
506+ #if (MAX_PAYLOAD > UINT8_MAX )
507+ self -> rx_frame_length = ((uint16_t )byte ) << 8 ;
508+ crc32_step (& self -> rx_checksum , byte );
509+ self -> rx_frame_state = RECEIVING_LENGTH_LSB ;
510+ break ;
511+ #else
512+ // MSB == LSB if value is 8-bit
513+ self -> rx_frame_state = RECEIVING_LENGTH_LSB ;
514+ #endif
515+ // FALLTHRU
516+ case RECEIVING_LENGTH_LSB :
505517 self -> rx_frame_length = byte ;
506518 self -> rx_control = byte ;
507519 crc32_step (& self -> rx_checksum , byte );
Original file line number Diff line number Diff line change 8686#define TRANSPORT_FIFO_MAX_FRAMES (1U << TRANSPORT_FIFO_SIZE_FRAMES_BITS)
8787#define TRANSPORT_FIFO_MAX_FRAME_DATA (1U << TRANSPORT_FIFO_SIZE_FRAME_DATA_BITS)
8888
89- #if (MAX_PAYLOAD > 255 )
90- #error "MIN frame payloads can be no bigger than 255 bytes"
89+ #if (MAX_PAYLOAD > 0xFFFF )
90+ #error "MIN frame payloads can be no bigger than 65535 (0xFFFF) bytes"
9191#endif
9292
9393// Indices into the frames FIFO are uint8_t and so can't have more than 256 frames in a FIFO
@@ -149,7 +149,11 @@ struct min_context {
149149 uint8_t rx_frame_payload_bytes ; // Length of payload received so far
150150 uint8_t rx_frame_id_control ; // ID and control bit of frame being received
151151 uint8_t rx_frame_seq ; // Sequence number of frame being received
152+ #if (MAX_PAYLOAD > UINT8_MAX )
153+ uint16_t rx_frame_length ; // Length of frame
154+ #else
152155 uint8_t rx_frame_length ; // Length of frame
156+ #endif
153157 uint8_t rx_control ; // Control byte
154158 uint8_t tx_header_byte_countdown ; // Count out the header bytes
155159 uint8_t port ; // Number of the port associated with the context
You can’t perform that action at this time.
0 commit comments