Skip to content

Commit bd718e4

Browse files
committed
Check for matching sub index when receiving data item response
1 parent e928892 commit bd718e4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/oi_can.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ bool SendJson(WiFiClient client) {
338338
if (result != DeserializationError::Ok) {
339339
SPIFFS.remove(jsonFileName); //if json file is invalid, remove it and trigger re-download
340340
updstate == REQUEST_JSON;
341+
retries = 50;
342+
DBG_OUTPUT_PORT.println("JSON file invalid, re-downloading");
341343
return false;
342344
}
343345

@@ -350,7 +352,7 @@ bool SendJson(WiFiClient client) {
350352
if (id > 0) {
351353
requestSdoElement(SDO_INDEX_PARAM_UID | (id >> 8), id & 0xff);
352354

353-
if (twai_receive(&rxframe, pdMS_TO_TICKS(10)) == ESP_OK) {
355+
if (twai_receive(&rxframe, pdMS_TO_TICKS(10)) == ESP_OK && rxframe.data[3] == (id & 0xFF)) {
354356
kv.value()["value"] = ((double)*(int32_t*)&rxframe.data[4]) / 32;
355357
} else {
356358
failed++;

0 commit comments

Comments
 (0)