rentzsch.com: tales from the red shed

JRUSBInterface: Easy Userland USB Device Access

Code

It’s cool how IOUSBLib allows your to interact with USB devices from userland (look ma, no kernel extensions!). Less cool is the amount of code required.

Enter JRUSBInterface. Don’t look at JRUSBInterface.m — there lies madness (yes the dtr[0-7] comments are me manually scoreboarding resource lifetimes). Instead, look at JRUSBInterface.h’s lovely interface. Three core methods: init, read and write. Ahhh, tranquility. Why, you can almost hear the babbling brook in the background and the soft lush grass underfoot.

Anyone know why IOUSBInterfaceStruct182’s ReadPipeTO() fails if you attempt to read less than what’s available? I had to throw a circular buffer on top to deal with that.

Sneaky bonus: #define JRUSBInterfaceDEBUG to get debug hex dumps of read/write traffic.

Friday, May 26, 2006
01:23 AM