aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Lockwood2022-04-25 19:22:24 -0600
committerAlexis Lockwood2022-04-25 19:22:24 -0600
commit693cf58e1c054390f2028d6d086c14ebd9c33b45 (patch)
tree9ac9105ef257b89431eaaf16c20aa7a203d3b968
parent020ba8544b6836f1a496bcbedea2ed6d24de63a8 (diff)
debug24_fw: large packets for lower overheadtrunk
-rw-r--r--Debug24/Debug24_fw/dbgpkt.hpp5
-rw-r--r--Debug24/Debug24_fw/dbgpkt_cobs.cpp8
2 files changed, 6 insertions, 7 deletions
diff --git a/Debug24/Debug24_fw/dbgpkt.hpp b/Debug24/Debug24_fw/dbgpkt.hpp
index 44de755..d55b8a5 100644
--- a/Debug24/Debug24_fw/dbgpkt.hpp
+++ b/Debug24/Debug24_fw/dbgpkt.hpp
@@ -51,7 +51,8 @@ typedef enum
DBG_BAD,
} dbg_rx_status_t;
-#define DBG_PKT_MAX_DATA 64
+#define DBG_PKT_MAX_DATA 260
+#define PLUS_COBS_OVERHEAD(x) ((x) + ((x) + 253) / 254)
/// Packet buffer definition
typedef struct
@@ -63,7 +64,7 @@ typedef struct
/// Data received, decoded from hex. Byte 0 is always the length
/// of the actual data content (not including itself or the checksum).
- uint8_t data[DBG_PKT_MAX_DATA + 2];
+ uint8_t data[PLUS_COBS_OVERHEAD(DBG_PKT_MAX_DATA + 2)];
} dbg_pkt_t;
/// Transmit buffer. Put a message in here and call dbg_tx() to send it.
diff --git a/Debug24/Debug24_fw/dbgpkt_cobs.cpp b/Debug24/Debug24_fw/dbgpkt_cobs.cpp
index 1380e18..8066713 100644
--- a/Debug24/Debug24_fw/dbgpkt_cobs.cpp
+++ b/Debug24/Debug24_fw/dbgpkt_cobs.cpp
@@ -44,8 +44,6 @@ void dbg_tx_cobs(void)
uint8_t dbg_rx_cobs(int c)
{
- static uint8_t _rx_cobs_buffer[PACKET_LEN + COBS_OVERHEAD];
-
enum state {
CMD0,
CMD1,
@@ -75,7 +73,7 @@ uint8_t dbg_rx_cobs(int c)
return DBG_BAD;
default:
state = CMD0;
- n = cobsDecode(_rx_cobs_buffer, pos, dbg_rx_pkt.data);
+ n = cobsDecode(dbg_rx_pkt.data, pos, dbg_rx_pkt.data);
for (size_t i = 0; i < n; i++)
cksum += dbg_rx_pkt.data[i];
@@ -114,14 +112,14 @@ uint8_t dbg_rx_cobs(int c)
break;
case DATA:
- if (pos >= sizeof(_rx_cobs_buffer))
+ if (pos >= sizeof(dbg_rx_pkt.data))
{
// Overrun!
fail = true;
return DBG_IDLE;
}
- _rx_cobs_buffer[pos] = (uint8_t) c;
+ dbg_rx_pkt.data[pos] = (uint8_t) c;
pos++;
break;