Skip to content

Commit

Permalink
Merge pull request #135 from StephenCatsamas/master
Browse files Browse the repository at this point in the history
fixed issue in slave example where some commands sent slave into unresponsive state
  • Loading branch information
SRGDamia1 authored May 15, 2024
2 parents 5937307 + 4412e37 commit 3d7925e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 3d7925e

Please sign in to comment.