I would like to write an iPhone/iPad app that can communicate through a USB connection with a Mac or PC program (that I would also write). Does anyone know how I could go about doing this? (I realize that I may have to jailbreak my iPad)
Socket communication via USB (USBMux) might meet your needs. When an iPad or iPhone plug in to a Mac, there will be a device description /var/run/usbmuxd. You can create a socket and connect it to /var/run/usbmuxd and send/receive packaged data to/or from iOS device. The data should be wrapped.
Here is a brief reference from theiphonewiki http://theiphonewiki.com/wiki/index.php?title=Usbmux. What I can provide is the sample code for connect to usbmuxd.
struct sockaddr_un endpoint;
size_t size;
_usbMuxSocket = socket(PF_LOCAL, SOCK_STREAM, 0);
endpoint.sun_family = AF_LOCAL;
strncpy(endpoint.sun_path, "/var/run/usbmuxd", 17);
size = (offsetof (struct sockaddr_un, sun_path)
+ strlen (endpoint.sun_path) + 1);
connect(_usbMuxSocket, (struct sockaddr *) &endpoint, size);
After that you have to "connect" to the port your App listen on iPad. The "connect" process discussed in the wiki page list above in section Sequence of Events. After the preparing work done, you can use the socket to send and read data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With