EmbeddedRelated.com
Forums
Memfault Beyond the Launch

USB printer on embeded linux

Started by John Huntington January 27, 2008
Dear all,
    I want to transplant the programs to embeded linux on S3C2410 arm
platform,but the original filesystem have no  "usb/lp0" node,so I make a
node using:

#mknod /dev/usb/lp0 c 180 0

    In kernel config I set "usb printer" option on,so how can I opration the
printer? just use open,write? how can I know the commands to drive the
printer? I'm not sure there's drivers in linux kernel or not,but I can use
it on redhat linux 9.The printer is HP laserjet 1300.
    Anyone help me?
        Best regards!


John Huntington wrote:
> Dear all, > I want to transplant the programs to embeded linux on S3C2410 arm > platform,but the original filesystem have no "usb/lp0" node,so I make a > node using: > > #mknod /dev/usb/lp0 c 180 0 > > In kernel config I set "usb printer" option on,so how can I opration the > printer? just use open,write? how can I know the commands to drive the > printer? I'm not sure there's drivers in linux kernel or not,but I can use > it on redhat linux 9.The printer is HP laserjet 1300.
Printer drivers in linux are done in user space. Check out www.cups.org for one way to do it.
"Arlet Ottens" <usenet+5@c-scape.nl> 
??????:479d66a2$0$85796$e4fe514c@news.xs4all.nl...
> John Huntington wrote: >> Dear all, >> I want to transplant the programs to embeded linux on S3C2410 arm >> platform,but the original filesystem have no "usb/lp0" node,so I make a >> node using: >> >> #mknod /dev/usb/lp0 c 180 0 >> >> In kernel config I set "usb printer" option on,so how can I opration >> the >> printer? just use open,write? how can I know the commands to drive the >> printer? I'm not sure there's drivers in linux kernel or not,but I can >> use >> it on redhat linux 9.The printer is HP laserjet 1300. > > Printer drivers in linux are done in user space. Check out www.cups.org > for one way to do it. >
Thank you! But I don't know how to transplant CUPS to a embeded linux based on limited resource. When I plug the USB printer to the platform, kernel prints: #ash-2.04# hub.c: USB new device connect on bus1/1, assigned device number 2 printer.c: usblp0: USB Bidirectional printer dev 2 if 0 alt 0 Do this means the driver is already exist? For a test, I typed these commands: #touch test.txt #echo "Hello boys!" > test.txt #cat test.txt > /dev/usb/lp0 but that's no effect, nothing printed. So, anyone who knows how to do this help me?
"John Huntington" <03132301@163.com> writes:

>>> I want to transplant the programs to embeded linux on S3C2410
>> Printer drivers in linux are done in user space. Check out >> www.cups.org for one way to do it.
> Thank you! But I don't know how to transplant CUPS to a embeded > linux based on limited resource.
Broadly speaking, you don't. CUPS is not appropriate for limited memory machines, and is at best a trick and a half for unattended automated operation. But then you don't especially mention how limited "limited" is in your case, so it's not necessarily a non-starter. For cases where CUPS wouldn't do, I have usually implemented a persistent task to manage the printer and stream application print data through the drivers and into the printer. (In fact, I have done this same thing a number of times under contract. I really ought to arrange the next time not to have it be work for hire.)
> When I plug the USB printer to the platform, kernel prints: > > hub.c: USB new device connect on bus1/1, assigned device number 2 > printer.c: usblp0: USB Bidirectional printer dev 2 if 0 alt 0 > > Do this means the driver is already exist?
This means that the USB printer device class driver in the kernel has taken hold of that USB device. You may now send print data (into the /dev node which hopefully appeared as well) or execute the handful of printer ioctls to get the out of band IEEE status. As the other poster mentioned, the kernel driver merely provides communication with the printer. The actual device-specific driver, in the sense of operating, say, an Epson vs an HP, resides in userspace. The canonical list of such drivers lives at www.linuxprinting.org.
> For a test, I typed these commands: > > #touch test.txt > #echo "Hello boys!" > test.txt > #cat test.txt > /dev/usb/lp0 > > but that's no effect, nothing printed. So, anyone who knows how to do this > help me?
Success here will depend on what the printer is. If I recall correctly, the average laserjet will print ASCII data, but it will require cr-lf style line endings on tha data, a page feed or other end of data marker, and may require a PJL wrapper around the job as well to work at all smoothly. I don't recall if the lj1300 in particular will do ASCII jobs, even though I've actually driven one from an embedded device before... -- Grant Taylor Embedded Linux Consultant http://www.picante.com/

Memfault Beyond the Launch