USB host to host communication
Hi,
here's my problem:
I have 2 linux boxes and they need to send and receive some messages to each other. I have usb host2host cable, but I don't know how to write the software for usb communication.
I tried libusb and wrote some code that can detect the cable, determine endpoint direction from bEndpointAddress, then call usb_bulk_read or usb_bulk_write. I get errors from usb_set_configuration, usb_claim_interface, and then usb_bulk_read (or usb_bulk_write, whatever I call).
I searched the forum, read libusb documentation and some programming guides, like the one on usb.cs.tum.edu and O'Reilly's Linux Device Drivers, chapter 13.
As I understand, this can be programmed also without libusb and including linux/usb.h instead of usb.h. I haven't tried that yet and would like to avoid it, because:
1. my program would then not be portable, and
2. the linux distro I'm using for developing doesn't even have all the necessary functions (usb_bulk_msg, interface_to_usbdev ...) declared in headers /usr/include/linux/usb*.h, so with this approach I'd have to use another distro for developing. Besides, this shows my program would then not be portable even to all linux systems.
What I'm looking for is some small and simple example code that reads or writes something to usb. What I found so far is the example on libusb homepage that does just things I already understand and have successfully programmed (searches through all devices, interfaces, etc., but does not read nor write anything). Other code I found is way too big and has its own complex routines for read/write. Any help appreciated.
|