[Twisted-Python] question : How to listen to USB-HID

Dear All ... Currently I have a twistd script that listen to arduino dev board. Arduino recognized as plain usb-serial, so I can do it using LineReceiver as simple as : --> class ArduinoReceiver(LineReceiver) And make it SerialService as told by http://www.mentby.com/lucas-taylor/serialport-protocol-as-a-service.html But I plan to replace arduino with digispark ( http://digistump.com/products/1 ) Problem is I just realize that this device will recognized as USB-HID Kindly please give me any enlightenment on how to handle USB-HID device with twistd ? Sincerely -bino-

On Fri, May 17, 2013 at 02:54:47PM +0700, bino@indoakses-online.com wrote:
But I plan to replace arduino with digispark ( http://digistump.com/products/1 )
Problem is I just realize that this device will recognized as USB-HID
From this page: http://digistump.com/wiki/digispark/tutorials/linuxtroubleshooting ...it sounds like the device implements the USB serial protocol (because it mentions 'KERNEL=="ttyACM*"' and 'tty' is what Linux calls a serial port). However, this page: http://digistump.com/wiki/digispark/tutorials/basics says "The Digispark does not have a hardware serial port nor a hardware serial to USB converter. An example library (DigiUSB) is provided, as well as some example code and a serial monitor like program", and the wiki-page for the DigiUSB driver suggests you can use it to implement any USB protocol you like, including USB Serial, USB-HID, USB Mass Storage, etc. There's no (easy) way to hook a Twisted program up to an arbitrary USB-HID device; the best you could do would be to write a Twisted program that communicates with stdin/stdout, then run that program in a window and remember not to Alt-Tab to another program while your Digistump is doing stuff. It sounds like a better solution would be to make sure you use the DigiUSB library to implement the standard USB Serial protocol and then continue using your existing code.

Dear All C/Q Tim Allen I really appreciate your response
There's no (easy) way to hook a Twisted program up to an arbitrary USB-HID device; the best you could do would be to write a Twisted program that communicates with stdin/stdout, then run that program in a window and remember not to Alt-Tab to another program while your Digistump is doing stuff.
It sounds like a better solution would be to make sure you use the DigiUSB library to implement the standard USB Serial protocol and then continue using your existing code.
well ... There is two clue that I got from digistump forum 1. https://gist.github.com/claws/2464017 I think that is the nearest to twisted , but not the most easy. 2. https://github.com/digistump/DigisparkExamplePrograms/blob/master/Python/Dig... With this one I thing I can rout the output to UDP and receive it easily in twistd Sincerely -bino-

Hi Maybe you get some clues about twisted with USB/serial stuff from http://code.google.com/p/pywws/source/browse/trunk/pywws/WeatherStation.py?r... which is a twistification of the pywws weather station code. HTH, Werner On 5/18/13 10:50 AM, bino@indoakses-online.com wrote:
Dear All C/Q Tim Allen I really appreciate your response
There's no (easy) way to hook a Twisted program up to an arbitrary USB-HID device; the best you could do would be to write a Twisted program that communicates with stdin/stdout, then run that program in a window and remember not to Alt-Tab to another program while your Digistump is doing stuff.
It sounds like a better solution would be to make sure you use the DigiUSB library to implement the standard USB Serial protocol and then continue using your existing code.
well ...
There is two clue that I got from digistump forum 1. https://gist.github.com/claws/2464017 I think that is the nearest to twisted , but not the most easy.
2. https://github.com/digistump/DigisparkExamplePrograms/blob/master/Python/Dig... With this one I thing I can rout the output to UDP and receive it easily in twistd
Sincerely -bino-
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (3)
-
bino@indoakses-online.com
-
Tim Allen
-
Werner Thie