On Sat, 30 Jul 2005, Stephen Beaver wrote: > I'm writing a printer controller for an ARM (EP9301) embedded system. This > distro was provided by the chip manufacturer and uses compiled-in drivers. > Switching to modules would be very difficult at this point. > > The main task is to "listen" to the printer, capture and parse its status > messages. > > eg: @PJL STATUS DEVICE\n CODE=10001\nDISPLAY="ONLINE"\nONLINE=TRUE > > and then make the printer status known to other tasks. > > Opening /dev/usb/lp0 and polling for characters works fine with most > printers but there are a few (OKIDATA) that seem to run fine for some time > (minutes, hours - it varies) and then just die. I am no longer able to read > or write to the open device. The only cure for this that I have been able to > find (and I have spent a week trying) is to remove and replug the USB cable. > > My dumb newbie embarrassing question is: How can I simulate this > disconnect/reconnect from user space software? > > The Cirrus EP9301 chip uses an ohci host controller and an internal root > hub. Kernel is 2.4.21-rmk1-crs1
Depending on the host controller hardware of your embedded system, you may be able to use usbfs to tell the root hub to turn off power to the printer's port. This will be awkward as you will probably have to unbind the hub driver first and then rebind it afterward, and it may not work at all -- many host controllers don't have the ability to turn off port power. You can tell by enabling USB verbose debugging in the kernel configuration (CONFIG_USB_DEBUG) and checking the dmesg log for the root-hub characteristics. A somewhat weaker simulation would be to perform a USB port reset. However 2.4 doesn't support this -- even 2.6 didn't support it correctly until 2.6.7 or so. And since port resets don't involve turning off the port power, it might not have the desired effect. Alan Stern P.S.: Another possible cure that doesn't involve fooling around with the USB cable is to cycle the printer's power. Is there any possibility of plugging the printer into some sort of computer-controlled power switch? ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-users
