On Sun, 4 Nov 2001, Massimiliano Mirra wrote:
> How can I output a bit to /dev/lp0 like I would with outb( 0x1, 0x378
> ) in C?  I have tried with p=open('/dev/lp0','w') and p.print(0b1),
> p.write(0b1) and variants with no success.

IO#print and IO#write use Object#to_s to convert non-strings to strings.

You want IO#putc(c), which is basically the same as putc(c,io) in C. When
you do so, remember putc() is buffered (by default) and so only sends the
data every 4096 bytes; this means you have to call #flush or #sync=,

In Linux, you normally wouldn't use outb() to access the parallel port
hardware. Instead you would use the read/write interface of /dev/lp0 for
normal data I/O (this includes #putc and such), and you'd use the ioctl()
interface for all the parallel-port-specific features.

To make hardware-specific features easier for Ruby programmers, I have
written a package called LinuxDevices (see RAA), which supports most
features of /dev/lp, /dev/dsp, and /dev/mixer.

________________________________________________________________
Mathieu Bouchard                   http://hostname.2y.net/~matju