From: Nathael Pajani Date: Fri, 12 Jun 2020 10:35:25 +0000 (+0200) Subject: Fixes related to dtplug protocol for hostside udpbridge X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=8aac8073babbcd10f06731c47e15ebccd712633d;p=soft%2Flpc122x%2Fexamples Fixes related to dtplug protocol for hostside udpbridge --- diff --git a/host/udpbridge/dtplug_protocol_host.c b/host/udpbridge/dtplug_protocol_host.c index b891269..1505d31 100644 --- a/host/udpbridge/dtplug_protocol_host.c +++ b/host/udpbridge/dtplug_protocol_host.c @@ -26,6 +26,13 @@ #include #include #include + +#undef DEBUG + +#ifdef DEBUG +#include +#endif + #include "dtplug_protocol_host.h" @@ -114,8 +121,12 @@ next_packet: rx_data->packet_rx_count, rx_data->errors_count); if (rx_data->rx_ptr >= sizeof(struct header)) { struct header* h = info; - printf("Pkt: type: %d, seq: %d, err: %d, quick: %d\n", h->type, h->seq_num, + printf("Pkt: type: %d, seq: %d, err: %d, quick: %d\n", h->type, (h->seq_num & 0x1F), (h->seq_num & PACKET_IS_ERROR), (h->seq_num & QUICK_DATA_PACKET)); + if (!(h->seq_num & QUICK_DATA_PACKET) && !(h->seq_num & PACKET_IS_ERROR)) { + printf("Pkt: data_size: %d, data_cksum: 0x%02x\n", h->data.size, h->data.checksum); + printf("rx_data_cksum: 0x%02x\n", rx_data->sum); + } } #endif /* Wether the packet was OK or not doesn't matter, go on for a new one :) */ @@ -140,6 +151,7 @@ int host_send_packet(struct line_transceiver* slave, uint8_t type, uint32_t size /* Loop to send all data, possibly split in several packets */ do { + memset(&cmd, 0, sizeof(struct packet)); if (data_send_size > PACKET_DATA_SIZE) { data_send_size = PACKET_DATA_SIZE; } @@ -157,7 +169,10 @@ int host_send_packet(struct line_transceiver* slave, uint8_t type, uint32_t size if (size && (size <= 2)) { cmd_info->seq_num |= QUICK_DATA_PACKET; cmd_info->quick_data[0] = data[0]; - cmd_info->quick_data[1] = data[1]; + if (size == 2) { + cmd_info->seq_num |= QUICK_DATA_PACKET_TWO_BYTES; + cmd_info->quick_data[1] = data[1]; + } } else { /* Copy data, compute checksum (also OK for a data_send_size of 0) */ for (i = 0; i < data_send_size; i++) {