From 5430711672ec716338b98e4cc4a73a6ca7883c20 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 5 Aug 2022 15:16:43 +0200 Subject: [PATCH] size send buffer for RMT channel including DCC checksum byte --- DCCRMT.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DCCRMT.cpp b/DCCRMT.cpp index dcf3ac7..cb28b10 100644 --- a/DCCRMT.cpp +++ b/DCCRMT.cpp @@ -24,7 +24,9 @@ #include "DCCWaveform.h" // for MAX_PACKET_SIZE #include "soc/gpio_sig_map.h" -#define DATA_LEN(X) ((X)*9+1) // Each byte has one bit extra and we have one EOF marker +// Number of bits resulting out of X bytes of DCC payload data +// Each byte has one bit extra and at the end we have one EOF marker +#define DATA_LEN(X) ((X)*9+1) #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4,2,0) #error wrong IDF version @@ -108,7 +110,7 @@ RMTChannel::RMTChannel(byte pin, bool isMain) { setEOT(idle + 27); // EOT marker // data: max packet size today is 5 + checksum - maxDataLen = DATA_LEN(MAX_PACKET_SIZE); + maxDataLen = DATA_LEN(MAX_PACKET_SIZE+1); // plus checksum data = (rmt_item32_t*)malloc(maxDataLen*sizeof(rmt_item32_t)); rmt_config_t config;