Hi,
Is there any programme or library in ruby to drive own hardware via
USB? Or do I have to implement my own C functions?
javra wrote:
Hi,
Is there any programme or library in ruby to drive own hardware via
USB? Or do I have to implement my own C functions?
Ruby doesn’t have the sort of close-to-the-hardware functions to do this
sort of thing, also Ruby programs are “better” when designed to be
cross-platform, so a driver approach might work out better overall.
Paul L. wrote:
–
Paul L.
http://www.arachnoid.com
javra:
Google for libusb.
The first two hits are for the *nix project and the Windows port of it.
Might help. You’d have to write a Ruby-C extension for it though.
Might turn out to be easier/faster than writing your own USB driver, if
that’s what you meant.
HTH
Vasudev
Vasudev Ram
Dancing Bison Enterprises
Software products, consulting and training
http://www.dancingbison.com
http://jugad.livejournal.com
http://dancingbison.blogspot.com
javra:
Google for libusb.
The first two hits are for the *nix project and the Windows port of it.
Might help. You’d have to write a Ruby-C extension for it though.
Might turn out to be easier/faster than writing your own USB driver, if
that’s what you meant.
Libusb is reasonably easy to use, but a big catch on *nix is that you
have to be running as root. Not a good idea for your entire
application. So I found it easier to write a small C daemon that
listens to a *nix domain socket and send through what it gets to the USB
device using appropriate libusb calls. You could also write some
Ruby-to-libusb wrappers and then write the daemon in Ruby instead of C
if you wanted to learn the Ruby-to-C interfaces, but in my view that’s
adding needless complexity. Depending on the type of USB device the
amount of device control vs. data that you need to make to talk to it
can be quite complex. I’m happy to share the daemon source if you send
me some private mail.
The best way to figure out how to talk to your device is to reverse
engineer what a manufacturer-provided Windows driver does unless you
happen to have good device-level USB documentation. You can do this by
looking at logs snapped by SnoopyPro.