| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Device::ParallelPort::drv::parport; |
|
2
|
1
|
|
|
1
|
|
9234
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Device::ParallelPort::drv::parport - Linux Kernel 2.2+ parport /dev/parport |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This program uses the linux /dev/parportX devices, which means of course that |
|
12
|
|
|
|
|
|
|
you must have access to that device, which is simply a matter changing |
|
13
|
|
|
|
|
|
|
permissions for your system, much the same as you would if you where giving the |
|
14
|
|
|
|
|
|
|
user access to the sound card (eg: /dev/dsp) |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NOTES |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Note that this is a temporary hack for now, full version to come soon... |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Copyright (c) 2002,2004 Scott Penrose. All rights reserved. |
|
23
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
24
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 AUTHOR |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Scott Penrose L, L |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
L |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
1120
|
use Device::ParallelPort::drv; |
|
|
1
|
|
|
|
|
1425
|
|
|
|
1
|
|
|
|
|
682
|
|
|
37
|
|
|
|
|
|
|
require DynaLoader; |
|
38
|
|
|
|
|
|
|
our @ISA = qw(Device::ParallelPort::drv DynaLoader); |
|
39
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
bootstrap Device::ParallelPort::drv::parport $VERSION; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Standard function to return information from this driver |
|
44
|
|
|
|
|
|
|
sub INFO { |
|
45
|
|
|
|
|
|
|
return { |
|
46
|
0
|
|
|
0
|
0
|
|
'os' => 'linux', |
|
47
|
|
|
|
|
|
|
'ver' => '>= 2.2', |
|
48
|
|
|
|
|
|
|
'type' => 'byte', |
|
49
|
|
|
|
|
|
|
}; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub init { |
|
53
|
0
|
|
|
0
|
0
|
|
my ($this, $str, @params) = @_; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$this->{DATA}{DEVICE} = "/dev/parport" . $this->address_to_num($str); |
|
56
|
|
|
|
|
|
|
# XXX What happened to ppuser support ? |
|
57
|
0
|
|
|
|
|
|
$this->{DATA}{BASE} = parport_opendev($this->{DATA}{DEVICE}); |
|
58
|
0
|
0
|
|
|
|
|
unless ($this->{DATA}{BASE} > 1) { |
|
59
|
0
|
|
|
|
|
|
croak "Failed to load partport driver for " . $this->{DATA}{DEVICE}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub set_byte { |
|
64
|
0
|
|
|
0
|
1
|
|
my ($this, $byte, $val) = @_; |
|
65
|
0
|
0
|
|
|
|
|
if ($byte == $this->OFFSET_DATA()) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
parport_wr_data($this->{DATA}{BASE}, $val); |
|
67
|
|
|
|
|
|
|
} elsif ($byte == $this->OFFSET_CONTROL()) { |
|
68
|
0
|
|
|
|
|
|
parport_wr_ctrl($this->{DATA}{BASE}, $val); |
|
69
|
|
|
|
|
|
|
} elsif ($byte == $this->OFFSET_STATUS()) { |
|
70
|
|
|
|
|
|
|
# parport_wr_status($this->{DATA}{BASE}, $val); |
|
71
|
0
|
|
|
|
|
|
croak "Unsupported - write to status line"; |
|
72
|
|
|
|
|
|
|
} else { |
|
73
|
0
|
|
|
|
|
|
croak "drv:parport supports only byte 0,1 and 2"; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_byte { |
|
78
|
0
|
|
|
0
|
1
|
|
my ($this, $byte, $val) = @_; |
|
79
|
0
|
0
|
|
|
|
|
if ($byte == $this->OFFSET_DATA()) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return parport_rd_data($this->{DATA}{BASE}); |
|
81
|
|
|
|
|
|
|
} elsif ($byte == $this->OFFSET_CONTROL()) { |
|
82
|
0
|
|
|
|
|
|
return parport_rd_ctrl($this->{DATA}{BASE}); |
|
83
|
|
|
|
|
|
|
} elsif ($byte == $this->OFFSET_STATUS()) { |
|
84
|
0
|
|
|
|
|
|
return parport_rd_status($this->{DATA}{BASE}); |
|
85
|
|
|
|
|
|
|
} else { |
|
86
|
0
|
|
|
|
|
|
croak "drv:parport supports only byte 0,1 and 2"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub DESTROY { |
|
91
|
0
|
|
|
0
|
|
|
my ($this) = @_; |
|
92
|
0
|
0
|
|
|
|
|
if (defined($this->{DATA}{BASE})) { |
|
93
|
0
|
|
|
|
|
|
parport_closedev($this->{DATA}{BASE}); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
|
98
|
|
|
|
|
|
|
|