diff options
Diffstat (limited to 'src/slip.c')
| -rw-r--r-- | src/slip.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -37,8 +37,8 @@ slip_decode_inframe(struct slip *slip, uint8_t rx_byte) if (rx_byte == slip->end) { /* end of packet */ - slip->rx_packet(slip, slip->rx_packet_userdata, - slip->rx_buf, slip->rx_index); + slip->rx_packet(slip, slip->rx_buf, slip->rx_index, + slip->rx_packet_userdata); slip->rx_state = SLIPDEC_START_STATE; } else if (rx_byte == slip->start) { /* malformed packet */ @@ -65,16 +65,16 @@ slip_decode_escseq(struct slip *slip, uint8_t rx_byte) int rc; dec = slip->esc_dec[rx_byte]; - if (!slip->esc_active[dec]) { - /* invalid contents, restart */ + if (slip->esc_active[dec]) { + rc = slip_decode_store(slip, dec); + if (rc) return rc; + slip->rx_state = SLIPDEC_IN_FRAME_STATE; + } else { + /* invalid contents */ if (slip->rx_restart) slip->rx_restart(slip, rx_byte); slip->rx_state = SLIPDEC_START_STATE; slip->rx_index = 0; - } else { - rc = slip_decode_store(slip, dec); - if (rc) return rc; - slip->rx_state = SLIPDEC_IN_FRAME_STATE; } return 0; @@ -91,14 +91,14 @@ slip_init(struct slip *slip) slip->rx_buflen = 0; slip->rx_buf = NULL; - if (slip->rx_packet) return -EINVAL; - if (slip->realloc) return -EINVAL; - if (slip->esc != slip->start) return -EINVAL; - if (slip->esc != slip->end) return -EINVAL; + if (!slip->rx_packet) return -EINVAL; + if (!slip->realloc) return -EINVAL; + if (slip->esc == slip->start) return -EINVAL; + if (slip->esc == slip->end) return -EINVAL; /* build decode table */ for (i = 0; i < 256; i++) - slip->esc_dec[slip->esc_enc[i]] = i; + slip->esc_dec[slip->esc_enc[i]] = (uint8_t) i; return 0; } @@ -181,7 +181,7 @@ slip_encode(struct slip *slip, uint8_t* out, size_t *outlen, size_t outcap, if (pos >= end) return -ENOBUFS; - *outlen = pos - out; + *outlen = (size_t) (pos - out); return 0; } |
