From 4412e37b76005bf96ba39391165930db5a192476 Mon Sep 17 00:00:00 2001 From: Stephen Catsamas Date: Fri, 2 Feb 2024 09:48:04 +1100 Subject: [PATCH] fixed issue in slave example where some commands sent slave into unresponsive state --- .../h_SDI-12_slave_implementation.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino b/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino index 49c2236..33f10b3 100644 --- a/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino +++ b/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino @@ -39,6 +39,7 @@ int state = 0; #define WAIT 0 #define INITIATE_CONCURRENT 1 #define INITIATE_MEASUREMENT 2 +#define PROCESS_COMMAND 3 // Create object by which to communicate with the SDI-12 bus on SDIPIN SDI12 slaveSDI12(DATA_PIN); @@ -196,6 +197,7 @@ void loop() { // Character '!' indicates the end of an SDI-12 command; if the current // character is '!', stop listening and respond to the command if (charReceived == '!') { + state = PROCESS_COMMAND; // Command string is completed; do something with it parseSdi12Cmd(commandReceived, dValues); // Clear command string to reset for next command @@ -246,5 +248,9 @@ void loop() { slaveSDI12.forceListen(); // sets SDI-12 pin as input to prepare for incoming // message AGAIN break; + case PROCESS_COMMAND: + state = WAIT; + slaveSDI12.forceListen(); + break; } }