Author Topic: question : How python listen to Digispark (migrate from Arduino 2009)  (Read 6050 times)

bino

  • Newbie
  • *
  • Posts: 3
Dear All ..

I have existing project that run on arduino.
basically it just digital.Read and serial print.
Currently I Use python (twisted) to received what it sent.

I'm attracted by digispark .. and just buy it and I think it's on the way to my desk.

Problems are :
1. I just found that digispark is USB-HID aminute ago (thanks to my lame brain).
2. I could not find that python twisted can work with USB-HID.

Kindly please give me any clue to any work around ?

Sincerely
-bino-

dougal

  • Sr. Member
  • ****
  • Posts: 289
I don't have an experience with using the Twisted framework, but here's a project I found that's using Twisted and doing USB HID:


https://gist.github.com/claws/2464017


Maybe that will give you an idea of how to get started with it?


Personally, I've been trying to get some USB communication going with the spark from nodejs. I've run into problems that I *think* step from the slightly non-standard way that the DigiUSB library transfers data. It uses GetFeatureReport/SetFeatureReport to transfer one byte at a time, using the ReportID field to actually hold the data byte. I think that the hidapi library has trouble with this, and most python/ruby example code you'll find is using libusb to communicate at a lower level.


There's been some talk in another thread about updating DigiUSB to be more compliant, implement "real" Feature Reports, and possibly multi-byte data transfers. I don't have the C++ chops to work on that myself, but I'm hoping that others will have some new code for us to try out soon. (actually, there's some code done already, but I haven't had time to try it yet)




digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
There is some working python example code here: https://github.com/digistump/DigisparkExamplePrograms


Also you could call the receive executable from your code.


Both of these are for using the DigiUSB library - which there are examples of how to use in our version of the Arduino IDE

bino

  • Newbie
  • *
  • Posts: 3
Dear Dougal and DigiStump
I don't have an experience with using the Twisted framework, but here's a project I found that's using Twisted and doing USB HID:

There is some working python example code here: https://github.com/digistump/DigisparkExamplePrograms

I Really appreciate both enlightenment

Sincerely
-bino-