-
Notifications
You must be signed in to change notification settings - Fork 11
Run-time error in Adapter.sendPacket() #2
Description
I was running my first trivial green been application this morning (source included below) on a Raspberry Pi (Raspbian GNU Linux 7 / Linux redbox-raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux), and it appeared to be working fine -- it immediately reported a bunch of values from my Hawk dryer:
$ sudo /home/pi/nodejs-local/bin/node status.js
machine status changed: 0
machine sub-cycle changed: 0
cycle count changed: 611
time remaining changed: 0
selected cycle changed: 8
operating mode changed: 0I left it running and walked away from my computer. About 1.5 hours later, I returned to see the following stack trace on the screen:
events.js:74
throw TypeError('Uncaught, unspecified "error" event.');
^
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at Adapter.emit (events.js:74:15)
at sendPacket (/home/pi/node_modules/green-bean/node_modules/gea-adapter-usb/index.js:55:18)
at Adapter.send (/home/pi/node_modules/green-bean/node_modules/gea-adapter-usb/index.js:150:9)
at Adapter.bus.send (/home/pi/node_modules/green-bean/node_modules/gea-sdk/src/command.js:46:9)
at null.<anonymous> (/home/pi/node_modules/green-bean/node_modules/gea-sdk/src/appliance.js:464:13)
at wrapper [as _onTimeout] (timers.js:261:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)I'm out of time to dig deeper right now, but I'm curious to know if you have seen such errors before. Are there typical causes / bozo errors that cause this kind of thing?
More detail
You'll have to forgive me; I'm entirely new to Javascript (I'm a C dev in my day job); what's the typical way to get more information from a sub-module that emits an amorphous error?
I notice that the error occurs in Adaper.send at this block (https://github.com/GEMakers/gea-adapter-usb/blob/master/index.js#L51):
try {
hid.write(writer.toArray());
}
catch (error) {
self.emit("error", error);
}It's unfortunate that it's not more descriptive on what the error is, but clearly it erred in trying to write to the GB device.
It looks like node-hid is a dependent module; I see C++ source code for HID::write() (i.e., Javascript hid.write()) under ~/node_modules/green-bean/node_modules/gea-adapter-usb/node_modules/node-hid. The only error I see occurring in there is at https://github.com/node-hid/node-hid/blob/master/src/HID.cc#L172, where hid_write() fails. Looking into the source for node-hid, it looks like on Linux, hid_write() is essentially a wrapper around write(2) (see https://github.com/signal11/hidapi/blob/master/linux/hid.c#L666).
On my RPi, I simply used "npm install green-bean", which installed all the GEA sub-modules for me, to include node-hid (which seems to have sub-included hidapi). I see the source under ~/node_modules/.../node-hid, but it doesn't look like it was compiled there, so it's not just a trivial "add errno to the JSException string" and recompile.
I can figure out to compile hidapi for myself later (e.g., to see the errno value), but I'm out of time for now. Hence, I'm just curious as to whether you've seen this kind of error before, and if it's due to a bozo user error. :-)
The trivial application is below.
var greenBean = require("green-bean");
greenBean.connect("laundry", function(laundry) {
laundry.machineStatus.subscribe(function (value) {
console.log("machine status changed:", value);
});
laundry.machineSubCycle.subscribe(function (value) {
console.log("machine sub-cycle changed:", value);
});
laundry.endOfCycle.subscribe(function (value) {
console.log("end of cycle changed:", value);
});
laundry.cycleCount.subscribe(function (value) {
console.log("cycle count changed:", value);
});
laundry.dryerServiceErrorCodes.subscribe(function (value) {
console.log("dryer service error codes changed:", value);
});
laundry.maximumWaterTemperature.subscribe(function (value) {
console.log("maximum water temperature changed:", value);
});
laundry.timeRemainingInSeconds.subscribe(function (value) {
console.log("time remaining changed:", value);
});
laundry.tankStatus.subscribe(function (value) {
console.log("tank status changed:", value);
});
laundry.tankSelected.subscribe(function (value) {
console.log("selected tank changed:", value);
});
laundry.cycleSelected.subscribe(function (value) {
console.log("selected cycle changed:", value);
});
laundry.operatingMode.subscribe(function (value) {
console.log("operating mode changed:", value);
});
laundry.delayTimeRemainingInMinutes.subscribe(function (value) {
console.log("delay time remaining changed:", value);
});
});