Uncaught Exception: TypeError: Cannot call method 'parse'
TinajaLabs opened this issue · comments
Getting this error when I start up Node-Red.
Not sure who to direct this to as I'm confused whether you or freakent would know what the problem might be.
I am using xbee series 1 and as it seems to be a parsing issue, perhaps there's a unanticipated packet?
I appreciate any help,
Chris.
root@beaglebone:~/node-red# node red.js -v
Welcome to Node-RED
===================
30 Apr 07:50:36 - [red] Version: 0.7.1.git
30 Apr 07:50:36 - [red] Loading palette nodes
Registering xbee in node
30 Apr 07:50:40 - ------------------------------------------
1 May 06:20:14 - [74-js2xml.js] Error: Cannot find module 'js2xmlparser'
1 May 06:20:14 - [36-rpi-gpio.js] Info : Ignoring Raspberry Pi specific node.
1 May 06:20:14 - [23-watch.js] Error: Cannot find module 'fs.notify'
1 May 06:20:14 - [32-feedparse.js] Error: Cannot find module 'feedparser'
1 May 06:20:14 - [61-email.js] Error: Cannot find module 'nodemailer'
1 May 06:20:14 - [61-imap.js] Error: Cannot find module 'imap'
1 May 06:20:14 - [65-redisout.js] Error: Cannot find module 'redis'
1 May 06:20:14 - [66-mongodb.js] Error: Cannot find module 'mongodb'
30 Apr 07:50:40 - ------------------------------------------
30 Apr 07:50:40 - [red] Server now running at http://127.0.0.1:1880/
30 Apr 07:50:40 - [red] Loading flows : flows_beaglebone.json
30 Apr 07:50:40 - [red] Starting flows
30 Apr 07:51:37 - [red] Stopping flows
30 Apr 07:51:37 - [red] Starting flows
30 Apr 07:51:37 - [log] [xbee in:xbee in] Get XBee on /dev/ttyO2:9600 from pool...
30 Apr 07:51:37 - About to initialise the XBee on /dev/ttyO2:9600...
30 Apr 07:51:38 - [red] Uncaught Exception:
30 Apr 07:51:38 - TypeError: Cannot call method 'parse' of undefined
at PacketParser.parse (/root/node-red/node_modules/svd-xbee/lib/xbee-api.js:385:29)
at Object.parser (/root/node-red/node_modules/svd-xbee/lib/xbee-api.js:349:29)
at ReadStream.SerialPort.options.dataCallback (/root/node-red/node_modules/svd-xbee/node_modules/serialport/serialport.js:92:13)
at ReadStream.EventEmitter.emit (events.js:95:17)
at ReadStream.<anonymous> (_stream_readable.js:746:14)
at ReadStream.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at ReadStream.Readable.push (_stream_readable.js:127:10)
Chris, I'm not sure whether jouz knows much about node-red or my node that uses jouz great library, so I'll try to help. You posted a note on my blog that I replied to, if the problem is related specifically to my xbee-node I am happy to carry on the conversation over there.
1st things 1st. Which copy of my xbee node are you using? I have two git repositories with xbee nodes, the later version is in the freakent-nodes repository. https://github.com/freakent/freakent-nodes
2nd I only have series 2 xbees so I do not have any experience of series 1 xbees and have not done any testing on series 1. Jouz also states on his git page that "Development is done using Series 2 XBee modules with XB24-ZB (ZIGBEE) firmware."
I would suggest you try to isolate the problem by removing my code from the equation. Write a small standalone nodejs script that tries to define and initialise an xbee object using svd-xbee.
Something like,
var XBee = require('svd-xbee').XBee;
var xbee = new XBee({
port: '/dev/ttyO2',
baudrate: 9600
});
xbee.init();
I also don't have any experience of using beaglebone, is /dev/tty02 definitely the correct port name?
Regards
Martin
m: 07776 490601
On 1 May 2014, at 07:21, Chris Jefferies notifications@github.com wrote:
Getting this error when I start up Node-Red.
Not sure who to direct this to as I'm confused whether you or freakent would know what the problem might be.
I am using xbee series 1 and as it seems to be a parsing issue, perhaps there's a unanticipated packet?
I appreciate any help,
Chris.root@beaglebone:~/node-red# node red.js -v
Welcome to Node-RED
30 Apr 07:50:36 - [red] Version: 0.7.1.git
30 Apr 07:50:36 - [red] Loading palette nodes
Registering xbee in node
30 Apr 07:50:40 - ------------------------------------------
1 May 06:20:14 - [74-js2xml.js] Error: Cannot find module 'js2xmlparser'
1 May 06:20:14 - [36-rpi-gpio.js] Info : Ignoring Raspberry Pi specific node.
1 May 06:20:14 - [23-watch.js] Error: Cannot find module 'fs.notify'
1 May 06:20:14 - [32-feedparse.js] Error: Cannot find module 'feedparser'
1 May 06:20:14 - [61-email.js] Error: Cannot find module 'nodemailer'
1 May 06:20:14 - [61-imap.js] Error: Cannot find module 'imap'
1 May 06:20:14 - [65-redisout.js] Error: Cannot find module 'redis'
1 May 06:20:14 - [66-mongodb.js] Error: Cannot find module 'mongodb'
30 Apr 07:50:40 - ------------------------------------------
30 Apr 07:50:40 - [red] Server now running at http://127.0.0.1:1880/
30 Apr 07:50:40 - [red] Loading flows : flows_beaglebone.json
30 Apr 07:50:40 - [red] Starting flows
30 Apr 07:51:37 - [red] Stopping flows
30 Apr 07:51:37 - [red] Starting flows
30 Apr 07:51:37 - [log] [xbee in:xbee in] Get XBee on /dev/ttyO2:9600 from pool...
30 Apr 07:51:37 - About to initialise the XBee on /dev/ttyO2:9600...
30 Apr 07:51:38 - [red] Uncaught Exception:
30 Apr 07:51:38 - TypeError: Cannot call method 'parse' of undefined
at PacketParser.parse (/root/node-red/node_modules/svd-xbee/lib/xbee-api.js:385:29)
at Object.parser (/root/node-red/node_modules/svd-xbee/lib/xbee-api.js:349:29)
at ReadStream.SerialPort.options.dataCallback (/root/node-red/node_modules/svd-xbee/node_modules/serialport/serialport.js:92:13)
at ReadStream.EventEmitter.emit (events.js:95:17)
at ReadStream. (stream_readable.js:746:14)
at ReadStream.EventEmitter.emit (events.js:92:17)
at emitReadable (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at ReadStream.Readable.push (_stream_readable.js:127:10)
—
Reply to this email directly or view it on GitHub.
Martin,
Thanks for the help. Yes, I can see data flowing in on the Beaglebone Black on that port,/dev/ttyO2 using the serialport node. I'm using the UART2 GPIO pins. Sadly the data is unreadable; not structured into meaningful packets.
I see jouz' repo, xbee-api, and it has references to 802.15.4, the series 1 basic xbee protocol. Do you know how I might wire in that functionality.
I've done a little javascript in the context of web page development but I an very new to node.js and have been drawn in because of the framework of node-red. I currently have a hard coded python application (TinajaLabs/gateway_raspi/allsensors.py) that collects xbee based sensor data (up to 4 sensors per radio), averages the data over 5 to 10 minutes then sends it to a local data store (csv), to a C#/SQL Server web service, to Xively, to ThingSpeak, to Open.sen.se, And last project hooked it up to a socket for real-time charting using Whisper and Graphite.
Ideally I could wrap this kind of functionality into specialized nodes for sensor input, functional processing, and flexible routing. I would also like to route some globally averaged data to a thermostat and to dampers by the furnace to optimize which rooms get heated.
Anyway, for now I'm just interested in learning how to get a node-red flow to read and parse my 802.15.4 series 1 xbee radio packets.
Your help is appreciated.
Thanks,
Chris.
Chris,
Jouz's new xbee-api is basically a rewrite of the existing library. From the documentation, it does look like xbee-api does support series 1 and series 2 modules. The higher level xbee-nodes and xbee-stream libraries that sit on top of the new xbee-api and should be easier to use are not yet ready. I would like to look at updating my node-red xbee node to use these new libraries in the future but I can't see that happening anytime soon. Quickest, easiest thing you could do is to maybe pick up a couple of series 2 xbee modules instead?
Regards
Martin
m: 07776 490601
On 2 May 2014, at 10:10, Chris Jefferies notifications@github.com wrote:
Martin,
Thanks for the help. Yes, I can see data flowing in on the Beaglebone Black on that port,/dev/ttyO2 using the serialport node. I'm using the UART2 GPIO pins. Sadly the data is unreadable; not structured into meaningful packets.I see jouz' repo, xbee-api, and it has references to 802.15.4, the series 1 basic xbee protocol. Do you know how I might wire in that functionality.
I've done a little javascript in the context of web page development but I an very new to node.js and have been drawn in because of the framework of node-red. I currently have a hard coded python application (TinajaLabs/gateway_raspi/allsensors.py) that collects xbee based sensor data (up to 4 sensors per radio), averages the data over 5 to 10 minutes then sends it to a local data store (csv), to a C#/SQL Server web service, to Xively, to ThingSpeak, to Open.sen.se, And last project hooked it up to a socket for real-time charting using Whisper and Graphite.
Ideally I could wrap this kind of functionality into specialized nodes for sensor input, functional processing, and flexible routing. I would also like to route some globally averaged data to a thermostat and to dampers by the furnace to optimize which rooms get heated.
Anyway, for now I'm just interested in learning how to get a node-red flow to read and parse my 802.15.4 series 1 xbee radio packets.
Your help is appreciated.
Thanks,
Chris.—
Reply to this email directly or view it on GitHub.
Hey Chris & Martin - sorry I couldn't reply earlier,
At quick glance, I would say that svd-xbee not properly supporting series 1 modules is indeed the issue here.
Adding support for series 1 to svd-xbee is possible, but I would prefer the following solution: Rebuilding the svd-xbee module using the new (low level) xbee-api as backend. This way svd-xbee would profit from many advantages including series 1 support, future updates to xbee-api and direct compatibility with Martins node-red plugin!
If you know what you're doing, it would be a long afternoon's work to get a first working xbee-api enabled svd-xbee. If not, you will probably get lost ;). Sadly, I'm overloaded with work at the moment...
As far as I can tell, node-red seems a good fit for you, Chris. By the way, are you using the IO Data Samples packets to collect sensor data (through XBee digital/analog pins)? Or do you use data packets (text using the xbee serial connection)?
If you would really want to use node-red, maybe a quick, preliminary solution would be to hook up your python script to node-red using a tcp socket?
Jan
Oh yes, that is a good suggestion, use a socket to enable communication between the existing python code and node-red. If you don't fancy a socket, use HTTP GET or MQTT broker??
@chris, how is your Python? Can you do that?
Regards
Martin
m: 07776 490601
On 2 May 2014, at 20:51, Jan Kolkmeier notifications@github.com wrote:
Hey Chris & Martin - sorry I couldn't reply earlier,
At quick glance, I would say that svd-xbee not properly supporting series 1 modules is the issue indeed.
Adding support for series 1 to svd-xbee is possible, but I would prefer the following solution: Rebuilding the svd-xbee module using the new (low level) xbee-api as backend. This way svd-xbee would profit from many advantages including series 1 support, future updates to xbee-api and direct compatibility with Martins node-red plugin!
As far as I can tell, node-red seems a good fit for you, Chris. By the way, are you using the IO Data Samples packets to collect sensor data (through XBee digital/analog pins)? Or do you use data packets (text using the xbee serial connection)?
If you know what you're doing, it would be a long afternoon's work to get a first working xbee-api enabled svd-xbee. If not, you will probably get lost ;). Sadly, I'm overloaded with work at the moment...
If you would really want to use node-red, maybe a quick, preliminary solution would be to hook up your python script to node-red using a tcp socket?
Jan
—
Reply to this email directly or view it on GitHub.
Thank you both for being very helpful. I have a few XBee Series 2 radios, but looking at the setup this evening, it seems so very different. I have about 15 XBee Series 1 radios working so will probably stick with that for now.
I was considering using the Node-Red tcp socket module as I have some python code that I used to send xbee data, using the python socket library, to a whisper database for real-time charting with Graphite. I'll resurrect this code for the upcoming Maker Faire. BTW, I've been accepted for a booth at this year's Maker Faire (May 17, 18) to show what I've been doing. I've done it before and it's a great time to meet and talk with people about wireless sensor networks and home automation.
I'll watch for future updates and really want to thank you for sharing your efforts.