ramonmata/node-red-contrib-xbee

UnhandledPromiseRejectionWarning: Error: Checksum Mismatch

Closed this issue · 6 comments

Hello,

im using the XBee-Nodes. My Setup is running like it should. Checking Waterlvl and sending it via XBee to Node-RED. But i get this error when my setup is running longer.

22 Mar 20:27:50 - [info] [mqtt-broker:2af3791d.faebd6] Connected to broker: mqtt ://localhost:1883
(node:1131) UnhandledPromiseRejectionWarning: Error: Checksum Mismatch {"buffer":{"type":"Buffer","data":[126,0,13,144,0,253,25,81,128,160,225,65,15,80,206,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"offset":17,"length":13,"total":1382,"checksum":4,"b":4,"escape_next":false,"waiting":false}
at XBeeAPI.parseRaw (/home/pi/.node-red/node_modules/xbee-api/lib/xbee-api.js:220:19)
at Transform.XBeeAPI.parser._transform (/home/pi/.node-red/node_modules/xbee-api/lib/xbee-api.js:48:19)
at Transform._read (_stream_transform.js:191:10)
at Transform._write (_stream_transform.js:179:12)
at doWrite (_stream_writable.js:403:12)
at writeOrBuffer (_stream_writable.js:387:5)
at Transform.Writable.write (_stream_writable.js:318:11)
at SerialPort.ondata (_stream_readable.js:718:22)
at SerialPort.emit (events.js:314:20)
at addChunk (_stream_readable.js:297:12)
(node:1131) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1131) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
D3An/Aus22

Anyone got an idea or knows this problem?

not sure what that means but -_>
"I see you have raised an issue. I would personally add to that issue and state (in case the author is not aware) that contrib nodes MUST handle errors to avoid crashing node-red." (Steve-Mcl, https://discourse.nodered.org/t/node-red-node-modules-xbee-api-lib-xbee-api-error/43039/5)

Hi @Rezcue Seems problem is with the data frame, because it says to have a "length = 13" for the data, but as we can see (bunch of 0s) in the output you sent, length is actually bigger.

regards,
Ramon

Hi
Yeah thats it. When i reach more then 255 for a longer duration it crashes.

`#include <SoftwareSerial.h>
#include <HCSR04.h>
#include <XBee.h>

XBee xbee = XBee();
SoftwareSerial my(4,2); // TX, RX
int triggerPin = 13;
int echoPin = 12;
UltraSonicDistanceSensor distanceSensor(triggerPin, echoPin);

uint8_t payload[] = { 0 };
// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x41C38580);

void setup () {
Serial.begin(115200);
my.begin(115200);
xbee.setSerial(my);
Serial.println("System Up!");
}

void loop () {

ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
double distance = distanceSensor.measureDistanceCm();
Serial.println(distance);
payload[0]= distance;
xbee.send(zbTx);
delay(5000);

}`

Any idea how i have to change the code to send end recive 16 bit?

Check this article about Maximum Payload Size by Product from DiGi.

I think you may have reached the limit and maybe need to rethink the message you are sending back.

Maybe casting the double as string?

Best regards

ok thank u very much.
ill try to send int distance as string. No idea how atm

`#include <SoftwareSerial.h>
#include <HCSR04.h>
#include <XBee.h>

XBee xbee = XBee();
SoftwareSerial my(4,2); // TX, RX
int triggerPin = 13;
int echoPin = 12;
UltraSonicDistanceSensor distanceSensor(triggerPin, echoPin);

char Buffer[255];
// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x41C38580);

void setup () {
Serial.begin(115200);
my.begin(115200);
xbee.setSerial(my);
Serial.println("System Up!");
}

void loop () {

int distance = distanceSensor.measureDistanceCm();
String d = String(distance);
d.toCharArray(Buffer, 255);
ZBTxRequest zbTx = ZBTxRequest(addr64, (uint8_t *)Buffer, strlen(Buffer));
Serial.println(d);
xbee.send(zbTx);
delay(2000);

}`

it works

Congrats! 👍🏼