sandeepmistry / node-powermate

A Node.js library for the Griffin PowerMate
41 stars 25 forks source link

added close method so it will play nice with Node-RED #5

Closed hardillb closed 9 years ago

hardillb commented 9 years ago

Hi,

I needed to add a close call so Node-RED can handle flow updates and shutdowns cleanly. If you can accept this and update the npmjs.org package it will save me having to point to the fork in the Node-RED Powermate node.

Thanks.

sandeepmistry commented 9 years ago

@hardillb would me happy to merge + publish to npm, a few things:

hardillb commented 9 years ago

@sandeepmistry we need to catch the error if closed because when the HID device is closed and there is a blocking read it always raises the error and I can't find a place to catch this higher up so it always kills the process.

I don't think we need an open method, once closed you just throw the existing powermate object away and create a new one, it may be worth adding a isClosed method to check and possibly wrapping all the set methods in tests to prevent trying to write to the device after closure.

I'll have a look at the tests and see if there is anything sensible to add

sandeepmistry commented 9 years ago

@hardillb thanks! Will make a few tweaks and publish to npm shortly ...

sandeepmistry commented 9 years ago

@hardillb v0.0.3 published to npm