Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs API #15

Open
aartek opened this issue Dec 23, 2016 · 4 comments
Open

nodejs API #15

aartek opened this issue Dec 23, 2016 · 4 comments

Comments

@aartek
Copy link

aartek commented Dec 23, 2016

Hey, I've made a library for nodejs, based on your project (it uses your DLL), but I'm not sure if I can publish it to github and npm repository. I don't want to break the license...

@pavel-a
Copy link
Owner

pavel-a commented Jan 2, 2017

You can publish your files, and get my DLL from github using curl or whatever.
Sorry I don't know anything about nodejs.

@MaxNijholt
Copy link

@aartek if you can publish or share your files. I'm currently using node-hid to control the relay. A direct interface would be better.

@aartek
Copy link
Author

aartek commented Oct 2, 2017

@MaxNijholt I've made my repo public. The code is in the "develop" branch. https://github.com/aartek/usb-relay-hid-node-js/tree/develop

It's not well tested, so If you find any bugs, or will have ideas for improvements, feel free to make a pull request.

Let me know if that works for you ;)

@MaxNijholt
Copy link

MaxNijholt commented Oct 5, 2017

It works like a charm! Thanks @aartek!
Only one small note: I changed the x64 dll to the x32. Due to the fact that the system is in x32 still. We still need to test it on Windows 10, x64.

Perhaps download the file instead of having it in your repo?

var http = require('http');
var fs = require('fs');

var download = function(url, dest, cb) {
  var file = fs.createWriteStream(dest);
  var request = http.get(url, function(response) {
    response.pipe(file);
    file.on('finish', function() {
      file.close(cb);  // close() is async, call cb after close completes.
    });
  }).on('error', function(err) { // Handle errors
    fs.unlink(dest); // Delete the file async. (But we don't check the result)
    if (cb) cb(err.message);
  });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants