Skip to content

Commit

Permalink
fix jvsio_node bug on unexpected status report for reset
Browse files Browse the repository at this point in the history
  • Loading branch information
toyoshim committed Oct 13, 2023
1 parent 7cbf99e commit fc9c6db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jvsio_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "jvsio_common_impl.h"

static uint8_t new_address;
static bool no_status;
static enum JVSIO_CommSupMode comm_mode;

static void senseNotReady(void) {
Expand All @@ -24,7 +25,8 @@ static void senseReady(void) {

static void sendStatus(void) {
// Should not reply if the rx_receiving is reset, e.g. for broadcast commands.
if (rx_receiving) {
if (no_status) {
no_status = false;
return;
}

Expand Down Expand Up @@ -106,6 +108,7 @@ static bool receiveCommand(uint8_t node,
address[i] = kBroadcastAddress;
}
rx_receiving = false;
no_status = true;
JVSIO_Client_dump("reset", NULL, 0);
JVSIO_Client_receiveCommand(node, command, len, commit);
break;
Expand All @@ -116,6 +119,7 @@ static bool receiveCommand(uint8_t node,
JVSIO_Node_pushReport(kReportOk);
} else {
rx_receiving = false;
no_status = true;
}
break;
case kCmdCommandRev:
Expand Down Expand Up @@ -249,6 +253,7 @@ void JVSIO_Node_init(uint8_t given_nodes) {
rx_available = false;
rx_error = false;
new_address = kBroadcastAddress;
no_status = false;
tx_report_size = 0;
downstream_ready = false;
comm_mode = k115200;
Expand Down
2 changes: 2 additions & 0 deletions test/node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ TEST_F(ClientTest, Reset) {
EXPECT_EQ(true, GetReceivedCommands()[0].commit);

EXPECT_FALSE(IsReady());

EXPECT_TRUE(IsOutgoingDataEmpty());
}

TEST_F(ClientTest, AddressSet) {
Expand Down

0 comments on commit fc9c6db

Please sign in to comment.