From fc5851c9fd16082b0f91ed830ffea84bca29d6be Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Wed, 12 Aug 2026 14:36:39 +1200 Subject: [PATCH] Return packet type processed in process() --- src/CMRI.cpp | 10 ++++++---- src/CMRI.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/CMRI.cpp b/src/CMRI.cpp index e359b1e..a057b3a 100644 --- a/src/CMRI.cpp +++ b/src/CMRI.cpp @@ -61,17 +61,19 @@ void CMRI::set_init_handler(void (*handler)(const uint8_t *, int)) // reads in serial data, decodes packets // automatically responds to POLL requests -// returns packet type so if we got a SET request you know to update your outputs -bool CMRI::process() +// returns the packet type (CMRI::INIT, CMRI::SET or CMRI::POLL) so if we got a +// SET request you know to update your outputs, or NULL if no valid packet was +// received +char CMRI::process() { while (_serial.available() > 0) { if (process_char(_serial.read())) { - return true; + return _rx_packet_type; } } - return false; + return NOOP; } bool CMRI::process_char(char c) diff --git a/src/CMRI.h b/src/CMRI.h index 52b453a..2ad2bb0 100644 --- a/src/CMRI.h +++ b/src/CMRI.h @@ -36,7 +36,7 @@ class CMRI void set_address(unsigned int address); void set_init_handler(void (*handler)(const uint8_t *data, int len)); - bool process(); + char process(); bool process_char(char c); void transmit();