[lug] talking directly to a printer

Timothy C. Klein teece at silverklein.net
Thu Jan 9 02:22:58 MST 2003


* D. Stimits (stimits at attbi.com) wrote:
> Hugh Brown wrote:
> 
> >On Wed, 2003-01-08 at 19:34, Peter Hutnick wrote:
> >
> >>Hugh Brown said:
> >>
> >>>I have a printer that whose manual claims that if you send it a hex
> >>>number it will respond with a status byte.  Is there a way to do this
> >>>under linux and get the output (I can use cat to write to the device
> >>>file, or I can use cat to read from the device file but not both at the
> >>>same time) without hacking on the kernel?
> >>
> >>You certainly won't have to hack the kernel.  You might have to cut some
> >>code.  Check out http://www.elitecoders.de/mags/cscene/CS4/CS4-02.html .
> >>It leads in with a bunch of DOS stuff, but then brings in the UNIXy
> >>goodness.
> >>
> >>I'm not a systems programmer, but I would assume that there is some
> >>buffered I/O system function to allow you to just write to the port then
> >>read whatever comes back.
> >>
> >
> >
> >
> >It's a usb printer.  There isn't some sort of fun /proc interface or a
> >way to use a fifo or something like that is there?
> >
> 
> USB produces, via the HID kernel "stuff" (that's a technical term, it 
> inherits from "module" and "coffee" and "fuzzy brain" and "jeez, it is 
> after 1 AM, why the *#$% am I awake?"), /dev/input/, and within 
> /dev/input/, are various USB devices. If it were a mouse, you'd know it 
> is /dev/input/mouse0 or similar, ditto for keyboard and joystick. I have 
> to wonder what the device would be named for a USB printer? Maybe 
> /dev/lp0 is a sym link pointing to the right USB device (digging around 
> in /usr/src/linux-2.4/Documentation/ could give more clues). In any 
> case, it is likely accessed just like any other device special file, 
> with a few "standard" ioctl's, plus some custom to the kernel module 
> that supports it. Or at least that is a place to start.

On my Debian system, it looks like it would be /dev/usb/lp0.  Failing
that location, they seem to have major number 180.

> D. Stimits, stimits AT attbi DOT com
> 
> PS: Looks like I'll miss another meeting...sleep sounds awefully good 
> right now. Was that Robert Frost that had the poem about miles to go and 
> things to do before resting his weary feet?  :(
> 

Yup, Robert Frost, "Stopping by Woods on a Snowy Evening." The last
stanza reads:

The woods are lovely, dark, and deep
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.

:->

Tim
--
==============================================
==  Timothy Klein || teece at silverklein.net  ==
==  http://i148.denver.dsl.forethought.net  ==
== ---------------------------------------- ==
== "Hello, World" 17 Errors, 31 Warnings... ==
==============================================



More information about the LUG mailing list