#include <stdint.h>
#include <string.h>
#include <unistd.h>
+
+#undef DEBUG
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
#include "dtplug_protocol_host.h"
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 :) */
/* 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;
}
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++) {