gbishop/cython-hidapi — pull request #2 by claws (2012-02-17 23:52:29+00:00)
Title: add close, readme and try.py updated

Hi,
Firstly, thanks for making this code available.

This pull request contains a few minor changes - mostly for clarity of install and testing.

I recently got a USB weather station and wanted to communicate with it using Mac OS X. Your software was recommended but the install instructions (at least for Mac OS X) were not clear enough for me. I found some instructions on a pywws issues page and followed those. I have updated the readme in line with those instructions, added software dependencies and changed it to .rst so that it displays nicely on github (but it still readable in text format too). Hopefully this can be of use to other following the same path.

After installing cython-hidapi I ran the try script but it didn't work - because I don't have the hard coded hid. I have updated the try script to indicate this to the user and advise the user of how to possibly fix this. The try script output has been updated to produce slightly more human friendly output.

The third change is related to making the close function available to the Python wrapper. I'm writing a long running service which can start and stop (without shutting down and restarting) and in the service stop section I wanted to be able to cleanly close the hid device.

The hid close change compiles and runs fine on OS X. The same call also appears in the linux and windows .c files so I expect would work identically there too.

I now call the hid.close function in my software but it does not return anything (it's void) so it's hard to tell from the Python layer if it really works. But it doesn't blow up, so assuming that the underlying hidapi actually does a close when I call its close function, it appears to work as intended.

Regards,
Chris