| 1 | package Device::ParallelPort::Printer; | ||
| 2 | use strict; | ||
| 3 | use Carp; | ||
| 4 | use Device::ParallelPort; | ||
| 5 | use IO::File; | ||
| 6 | |||
| 7 | # XXX 1.0 - Make this work and test with simple printer. | ||
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Device::ParallelPort::Printer - Emulate a normal old style printer using Device::ParallelPort | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | use Device::ParallelPort::Printer; | ||
| 16 | my $printer = Device::ParallelPort::Printer->new('parport:0'); | ||
| 17 | $printer->sendfile('demo.ps'); | ||
| 18 | |||
| 19 | =head1 DESCRIPTION | ||
| 20 | |||
| 21 | This is a demonstration only and does not have any real practical application. | ||
| 22 | It has been written as a demonstration on how to write drivers for | ||
| 23 | Device::ParallelPort. | ||
| 24 | |||
| 25 | Device::ParallelPort provides a raw interface to the parallel port. Printers | ||
| 26 | actually expect a certain way of getting data. That is the Centronix Parallel | ||
| 27 | Port Protocol. | ||
| 28 | |||
| 29 | Basically you set a byte you want to send to the printer on the first byte of | ||
| 30 | the parallel device. You then raise and lower a pin on the control byte (3rd I | ||
| 31 | think ???) which tells the printer to retrieve the data you put on the first | ||
| 32 | byte. | ||
| 33 | |||
| 34 | =head1 COPYRIGHT | ||
| 35 | |||
| 36 | Copyright (c) 2002,2004 Scott Penrose. All rights reserved. | ||
| 37 | This program is free software; you can redistribute it and/or modify | ||
| 38 | it under the same terms as Perl itself. | ||
| 39 | |||
| 40 | =head1 AUTHOR | ||
| 41 | |||
| 42 | Scott Penrose L<scottp@dd.com.au>, L<http://linux.dd.com.au/> | ||
| 43 | |||
| 44 | =head1 SEE ALSO | ||
| 45 | |||
| 46 | L<Device::ParallelPort> | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | sub new { | ||
| 51 | my ($class, $parport) = @_; | ||
| 52 | my $this = bless {}, ref($class) || $class; | ||
| 53 | $this->{PP} = Device::ParallelPort->new($parport) | ||
| 54 | or croak("Unable to create device - $parport"); | ||
| 55 | return $this; | ||
| 56 | } | ||
| 57 | |||
| 58 | sub sendfile { | ||
| 59 | } | ||
| 60 | |||
| 61 | sub _data { | ||
| 62 | my ($this, $data) = @_; | ||
| 63 | $this->_pp->set_data($data); | ||
| 64 | } | ||
| 65 | |||
| 66 | # XXX Does there need to be any delay here ? | ||
| 67 | sub _flash { | ||
| 68 | my ($this) = @_; | ||
| 69 | $this->_pp->set_bit(8 * 2, 1); | ||
| 70 | $this->_pp->set_bit(8 * 2, 0); | ||
| 71 | } | ||
| 72 | |||
| 73 | sub _pp { return $_[0]->{PP}; } | ||
| 74 | |||
| 75 | 1; |