hybridgroup / node-bebop

A Node.js client for controlling Parrot Bebop & Bebop2 quadcopters.
http://nodebebop.com
MIT License
146 stars 61 forks source link

After updating Bebop 2 to the v4.3.0 firmware, a BD_NET_DC_EVENT_ID is received with an undefined data element #61

Open MichaelFitzurka opened 6 years ago

MichaelFitzurka commented 6 years ago

Using the feature/firmware-4.0 branch, And the v4.3.0 firmware on the Bebop 2 drone, I started to receive an error on starting up the node app.

Cannot read property 'readUInt8' of undefined at Bebop._packetReceiver (/home/michael.fitzurka/Projects/IoT_Demo/IoT-Demo_Drone/node_modules/node-bebop/lib/bebop.js:307:43)

line 307 is: var commandProject = networkFrame.data.readUInt8(0),

I added a clause to the if statement above it, to check for undefined, to get me running again, but I do not know if that has any unforeseen circumstances. Added logs to be sure and the networkFrame.id was 126, which is the BD_NET_DC_EVENT_ID.

lines 304-306 (adding line 306): if ((networkFrame.id === constants.BD_NET_DC_EVENT_ID || networkFrame.id === constants.BD_NET_DC_NAVDATA_ID) && networkFrame.data != undefined) {

FYI

karlhsu commented 6 years ago

me too node-bebop crash ,upgrade to V4.3 D:\Node\FlyAuto\node_modules\node-bebop\lib\bebop.js:301 var commandProject = networkFrame.data.readUInt8(0), ^ TypeError: Cannot read property 'readUInt8' of undefined at Bebop._packetReceiver (D:\Node\FlyAuto\node_modules\node-bebop\lib\bebop.js:301:43) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:548:8)

I can fix the following fix the problem if (networkFrame.id === constants.BD_NET_DC_EVENT_ID || networkFrame.id === constants.BD_NET_DC_NAVDATA_ID) {

var commandProject = 0,
    commandClass = 0,
    commandId = 0;

if(networkFrame.data != null)
{       
    commandProject = networkFrame.data.readUInt8(0),
    commandClass = networkFrame.data.readUInt8(1),
    commandId = networkFrame.data.readUInt16LE(2);
}