GEMakers / green-bean

An Adapter for the Appliance Maker Community
GNU General Public License v2.0
57 stars 23 forks source link

Error: Cannot write to HID device #8

Open DukeNukem49 opened 8 years ago

DukeNukem49 commented 8 years ago

Hello,

I am trying to communicate with a washer using the green bean and a Windows 7 notebook. I managed it to get everything installed but unfortunately it seems that there is no communication to the green bean at all.

If I run the following simple script in cmd.exe as admin I always get the same error message regardless of whether the washing machine is plugged to the green bean or not.

console.log("Program started.");
var greenBean = require("green-bean");
greenBean.connect("laundry", function (laundry)
{
   laundry.cycleStatus.read(function (value)
   {
      console.log("cycle status:", value);
   });
});

Program output:

Program started.
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: Cannot write to HID device
    at Error (native)
    at sendPacket (C:\green-bean\node_modules\gea-adapter-usb\index.js:52:17)
    at updateAddressList (C:\green-bean\node_modules\gea-adapter-usb\index.js:70:9)
    at ensureAddressExists (C:\green-bean\node_modules\gea-adapter-usb\index.js:82:9)
    at Adapter.send (C:\green-bean\node_modules\gea-adapter-usb\index.js:137:9)
    at Adapter.bus.send (C:\green-bean\node_modules\gea-sdk\src\command.js:46:9)
    at null._repeat (C:\green-bean\node_modules\gea-sdk\src\appliance.js:464:13)
    at wrapper [as _onTimeout] (timers.js:275:19)
    at Timer.listOnTimeout (timers.js:92:15)

I would be glad if somebody could tell me what to try to achieve a proper communication.

Thanks Duke Nukem

MylesCaley commented 8 years ago

@DukeNukem49 Do you have access to a linux, mac or raspberry pi? Its generally much easier to get going on the non-windows environments.

DukeNukem49 commented 8 years ago

At the Moment I would like to work with Windows because everything else here is set up with Windows.

To ensure that Windows is not blocking the HID communication I have tested a few things in the meantime like turning off the virus scanner/ firewall but unfortunately without any success. I also tried the green bean SDK on a PC with a “fresh” installed Windows 7 without any additional installed software. But there also comes exactly the same error message.

MylesCaley commented 8 years ago

@DukeNukem49 what version of node and node-hid are installed (run npm ls in the green-bean directory)?

DukeNukem49 commented 8 years ago

@MylesCaley These are the versions that are installed: node: 4.2.3 node-hid: 0.5.1

AndrewM19 commented 8 years ago

Hello I wander if there was a solution provided for this issue. I’m getting the same error on raspberry pi when running examples from green-bean. I have few additional comments:

  1. The error message is displayed about 2 minutes after the program is started.
  2. After the error message is displayed program hangs and has to be interrupted by ^C
  3. I downloaded the GeoSpringHack and can communicate with water heater using it
  4. After I’ve get the error message from green-bean example program I have to reboot raspberry pi to be able to connect to water heater using GeoSpringHack again. Version of my software: node: 4.4.0 node-hid: 0.5.1

Thanks Andrew Mysliwiec

stboch commented 8 years ago

I am having a similar problem with my program.

am using the subscribe function, after a few minutes Poof.

Can you subscribe to multiple elements at the same time?

running on a pi, with an older version of node 0.10.12 and node-hid 0.5.1

Hixie commented 8 years ago

I also get this. I've worked around it for now by running the script like this:

$ while (true); do (cd dishwasher; node --abort-on-uncaught-exception dishwasher-to-websocket-proxy.js

...where "dishwasher-to-websocket-proxy.js" is a script that just connects to my appliance (a dishwasher), subscribes to everything, continually polls everything, and forwards all the responses to a WebSocket server of another (long-running) script running on the same raspberry pi which then actually interprets the messages. (see https://github.com/Hixie/dishwasher/)

The "dishwasher-to-websocket-proxy.js" script connects, works for a while, then has the error reported in this issue, this causes node to abort (because of --abort-on-uncaught-exception) and that causes bash to restart the process. Since the restart is quick I don't generally miss anything.