Device::ParallelPort::Printer - Emulate a normal old style printer using Device::ParallelPort


Device-ParallelPort documentation Contained in the Device-ParallelPort distribution.

Index


Code Index:

NAME

Top

Device::ParallelPort::Printer - Emulate a normal old style printer using Device::ParallelPort

SYNOPSIS

Top

	use Device::ParallelPort::Printer;
	my $printer = Device::ParallelPort::Printer->new('parport:0');
	$printer->sendfile('demo.ps');

DESCRIPTION

Top

This is a demonstration only and does not have any real practical application. It has been written as a demonstration on how to write drivers for Device::ParallelPort.

Device::ParallelPort provides a raw interface to the parallel port. Printers actually expect a certain way of getting data. That is the Centronix Parallel Port Protocol.

Basically you set a byte you want to send to the printer on the first byte of the parallel device. You then raise and lower a pin on the control byte (3rd I think ???) which tells the printer to retrieve the data you put on the first byte.

COPYRIGHT

Top

AUTHOR

Top

Scott Penrose scottp@dd.com.au, http://linux.dd.com.au/

SEE ALSO

Top

Device::ParallelPort


Device-ParallelPort documentation Contained in the Device-ParallelPort distribution.

package Device::ParallelPort::Printer;
use strict;
use Carp;
use Device::ParallelPort;
use IO::File;

# XXX 1.0 - Make this work and test with simple printer.

sub new {
	my ($class, $parport) = @_;
	my $this = bless {}, ref($class) || $class;
	$this->{PP} = Device::ParallelPort->new($parport)
		or croak("Unable to create device - $parport");
	return $this;
}

sub sendfile {
}

sub _data {
	my ($this, $data) = @_;
	$this->_pp->set_data($data);
}

# XXX Does there need to be any delay here ?
sub _flash {
	my ($this) = @_;
	$this->_pp->set_bit(8 * 2, 1);
	$this->_pp->set_bit(8 * 2, 0);
}

sub _pp { return $_[0]->{PP}; }

1;