@@ -37,7 +37,7 @@ void slip_send_packet(const uint8_t* data, uint16_t data_len, uint8_t cmd, void
3737
3838 /* Write header to buffer */
3939 uint8_t * buffer = (uint8_t * )& hdr ;
40- for (uint16_t byte = 0 ; byte < sizeof (hdr ); byte ++ ) { send_byte (buffer [byte ]); }
40+ for (uint16_t byte = 0 ; byte < sizeof (slip_header_t ); byte ++ ) { send_byte (buffer [byte ]); }
4141
4242 /* Update packet count */
4343 packet_count ++ ;
@@ -87,11 +87,12 @@ uint16_t crc16_ccitt_false(const uint8_t* data, uint16_t len) {
8787 * @param read_byte A function to read a byte from the input stream.
8888 */
8989void slip_receive_packet (uint8_t input_byte , slip_packet_t * decoded_packet , uint8_t (* read_byte )(void )) {
90- if (!decoded_packet || !read_byte ) { return ; }
90+ uint8_t temp ;
91+ while ((temp = read_byte ()) != SLIP_END );
9192
9293 /* Read header from buffer */
9394 uint8_t * buffer = (uint8_t * )decoded_packet ;
94- for (uint16_t byte = 0 ; byte < sizeof (* decoded_packet ); byte ++ ) { buffer [byte ] = read_byte (); }
95+ for (uint16_t byte = 0 ; byte < sizeof (slip_header_t ); byte ++ ) { buffer [byte ] = read_byte (); }
9596
9697 /* Update packet count */
9798 packet_count = decoded_packet -> header .id + 1 ;
@@ -119,4 +120,6 @@ void slip_receive_packet(uint8_t input_byte, slip_packet_t* decoded_packet, uint
119120 decoded_packet -> payload [i ] = c ;
120121 }
121122 }
123+
124+ while ((read_byte ()) != SLIP_END );
122125}
0 commit comments