101100 / xbee-rx Goto Github PK
View Code? Open in Web Editor NEWRx.js library for XBee wireless modules based on xbee-api
License: MIT License
Rx.js library for XBee wireless modules based on xbee-api
License: MIT License
Hi, running your examples/simple-monitor.js with the changes below works fine for a frame with 2 digital outputs. However when 1 analog output is added (making the frame slightly bigger (by 16 bits? ) I get the uncaught exception as shown.
This occurs because mixed frames (digital and analog) when digital samples are event driven and analog are periodical contains the same channel mask (digital and analog) but there is sometimes no analog data. Each analog reading is 2 bytes and when they aren't there the frame parser still tries to read them - causing the uncought exception.*****************
It shows one frame translated but fails on the next. This error affects the node-red-contrib-xbee module and it potentially originates with xbee-api module. It might be that the frame parser buffer sizes is too small but the error isn't handled.
Thanks for your support.
var xbee = xbeeRx({
serialport: "/dev/ttyUSB0",
serialportOptions: {
baudRate: 115200
},
module: "802.15.4",
// turn on debugging to see what the library is doing
debug: true
});
and commenting out this line (couldn't run otherwise but no console output unless debug is on):
//stdin.setRawMode(true);
Connecting to serialport /dev/ttyUSB0
Monitoring incoming packets (press CTRL-C to stop)
Debug frame (in):
{
type: 131,
remote16: 'af2e',
rssi: 83,
receiveOptions: 0,
data: {
sampleQuantity: 1,
channelMask: 2051,
channels: { ADC2: 1, DIO0: 1, DIO1: 1 },
analogSamples: [ [Object] ],
digitalSamples: [ '11' ]
}
}
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
AssertionError [ERR_ASSERTION]: Out of Original Buffer's Boundary
at MAKE_NEXT_READER.BufferReader. [as nextUInt16BE] (/home/dowster64/projects/node-test/node_modules/buffer-reader/index.js:77:9)
at frame_parser.Recieved16BitPacketIO (/home/dowster64/projects/node-test/node_modules/xbee-api/lib/frame-parser.js:281:34)
at frame_parser. (/home/dowster64/projects/node-test/node_modules/xbee-api/lib/frame-parser.js:322:16)
at XBeeAPI.parseFrame (/home/dowster64/projects/node-test/node_modules/xbee-api/lib/xbee-api.js:134:27)
at XBeeAPI.parseRaw (/home/dowster64/projects/node-test/node_modules/xbee-api/lib/xbee-api.js:229:26)
at XBeeAPI.parser._transform (/home/dowster64/projects/node-test/node_modules/xbee-api/lib/xbee-api.js:48:19)
at Transform._write (node:internal/streams/transform:154:8)
at writeOrBuffer (node:internal/streams/writable:390:12)
at _write (node:internal/streams/writable:331:10)
at Writable.write (node:internal/streams/writable:335:10) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
Node.js v18.3.0
That is really great work but i can not figure out how to manage my problem.
I am sending transmit request to receiving node. after getting transmit ok message i have to get another message from recieving node to understand the status. The receiving node sends it but i can not get it.
Could you please help me?
First of all thank you for your nice work.
I would add a support for ND command, because when execute ND (node discovery) the response instead of having commandData, it has nodeIdentification.
in function _sendFrameStreamResponse
if (frame.commandStatus === xbee_api.constants.COMMAND_STATUS.OK) {
// return commandData; before
return frame.command === "ND" ? frame.nodeIdentification : commandData;
}
correct README.md
instructions, the real timeout option is defaultTimeoutMs
intead of defaultTimeout
I am running the simple-transmit sample to test transmission of my Xbee S2 module.
However, I am not getting the "Transmission Successful" response in the console.
Playing with the xbee-rx.js file, I found that in the _remoteTransmit
function, there is this block of code:
return _sendFrameStreamResponse(frame, timeoutMs, responseFrameType)
.flatMap(function (frame) {
if (frame.deliveryStatus === xbee_api.constants.DELIVERY_STATUS.SUCCESS) {
return rx.Observable.empty();
}
// if not OK, throw error
return rx.Observable.throw(new Error(xbee_api.constants.DELIVERY_STATUS[frame.deliveryStatus]));
});
If I change flatMap
to map
or If I return anything else instead of the empty Observable, then I start getting the "Transmission Successful" message.
What's the issue here? I haven't worked with RX before so I don't have any idea about it.
Hello,
I would like to thank you for developing and maintaining this package, we have been using it for a long time in production without any major issues.
But recently we wanted to upgrade from Raspbian w/ Debian 9 (Kernel 4.19) to Raspberry Pi OS w/ Debian 10 (Kernel 5.4), and suddenly it stopped sending data through the serial port.
I think that an update is required in the serialport library in order to support newer kernels, this project currently uses v6.0 and the latest is v9.0.2.
Thank you very much once again.
Update to serial port +5 breaks serial xbee-api parser. Does not return responses
https://github.com/jankolkmeier/xbee-api/blob/master/lib/xbee-api.js
Line 152 comment
Also, update breaks serial port option "baudrate", replace with "baudRate".
Will create a pull request to fix this issue shortly.
I am using your library xbee-rx in Node-Red project, temperature sensor through Xbee, where trying to inject the output to next node (debug-output) but I am unable to commit it. Specifically I have used temperature.js script as reference and after adapt to my environment (raspberryPi2) as per below with extra entry xbee.close() in first subscriber statement to avoid monitoring loop in background I can get temperature value in my Linux console but not in Node-Red.
var subscription = xbee
.monitorIODataPackets()
.pluck("analogSamples")
.pluck("AD3") // extract just the AD3 sample (in millivolts)
.map(function (mv) { return (mv) / 10; }) // convert millivolts to Centigrade
.subscribe(function (value) {
console.log(new Date(), "temperature:", value);
xbee.close();
}, function (error) {
console.log("Error during monitoring:\n", error);
xbee.close();
});
node.error("Error");
return (msg);
I am new with RxJS method and would like your help in this matter, Can you advice how to manage console.log data output and be capable to use as msg.payload, object or buffer in order to forward to next node ?.
I found a error with v5.0, when send and receibe data from remote xbee:
/home/pi/Templates/gw-companyDemo-fincaDemo1/bluegateway/node_modules/xbee-api/lib/xbee-api.js:220
var err = new Error("Checksum Mismatch " + JSON.stringify(S));
^
Error: Checksum Mismatch {"buffer":{"type":"Buffer","data":[126,0,38,144,0,123,4,108,87,127,236,66,89,148,67,142,83,53,170,156,197,79,82,93,186,140,255,15,142,20,31,130,80,255,15,170,26,56,131,0,155,191,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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":42,"length":38,"total":4061,"checksum":191,"b":191,"escape_next":false,"waiting":false}
at XBeeAPI.parseRaw (/home/pi/Templates/gw-companyDemo-fincaDemo1/bluegateway/node_modules/xbee-api/lib/xbee-api.js:220:19)
at Transform.XBeeAPI.parser._transform (/home/pi/Templates/gw-companyDemo-fincaDemo1/bluegateway/node_modules/xbee-api/lib/xbee-api.js:48:19)
at Transform._write (node:internal/streams/transform:184:23)
at writeOrBuffer (node:internal/streams/writable:388:12)
at Transform.Writable.write (node:internal/streams/writable:333:10)
at SerialPort.ondata (node:internal/streams/readable:715:22)
at SerialPort.emit (node:events:329:20)
at addChunk (node:internal/streams/readable:304:12)
at readableAddChunk (node:internal/streams/readable:279:9)
at SerialPort.Readable.push (node:internal/streams/readable:218:10)
Emitted 'error' event on XBeeAPI instance at:
at XBeeAPI.parseRaw (/home/pi/Templates/gw-companyDemo-fincaDemo1/bluegateway/node_modules/xbee-api/lib/xbee-api.js:221:14)
at Transform.XBeeAPI.parser._transform (/home/pi/Templates/gw-companyDemo-fincaDemo1/bluegateway/node_modules/xbee-api/lib/xbee-api.js:48:19)
[... lines matching original stack trace ...]
at SerialPort.Readable.push (node:internal/streams/readable:218:10)
This occurs sometimes, when making requests in group(loop) to remote Xbees and they respond:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.