| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Device::ParallelPort::drv::win32; |
|
2
|
1
|
|
|
1
|
|
6792
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
32
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
62
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Device::ParallelPort::drv::win32 - Windows 32 Drivers Version |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This module uses the inpout32.dll common to Windows users to read and write to |
|
12
|
|
|
|
|
|
|
the Parallel Port. For futher details see L |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 INSTALLATION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Standard installation, but you also need "inpout32.dll" which may require |
|
17
|
|
|
|
|
|
|
either putting into your windows System directory, or at the location of your |
|
18
|
|
|
|
|
|
|
executable. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 inpout32.dll |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
inpout32.dll actually comes from a 3rd party source and is freely available. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
http://www.logix4u.net/inpout32.htm |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
It apparently works on Win95, Win98, WinNT, Win2K and WinXP. The XP and other |
|
27
|
|
|
|
|
|
|
ptoected mode systems has been solved by the DLL automatically loading a Kernel |
|
28
|
|
|
|
|
|
|
Mode driver at initalisation. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
NOTE - Although this is not mentioned on this web site, it may be necessary to |
|
31
|
|
|
|
|
|
|
have administration privs to load this DLL. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Copyright (c) 2002,2004 Scott Penrose. All rights reserved. |
|
36
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
37
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 AUTHOR |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Scott Penrose L, L |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
L |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
1544
|
use Win32::API; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# NOTE - Have not considered pre Perl 5.6 support - may need to |
|
51
|
|
|
|
|
|
|
use base qw/Device::ParallelPort::drv/; |
|
52
|
|
|
|
|
|
|
use vars qw/$VERSION/; |
|
53
|
|
|
|
|
|
|
$VERSION = '1.3'; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Standard function to return information from this driver |
|
56
|
|
|
|
|
|
|
sub INFO { |
|
57
|
|
|
|
|
|
|
return { |
|
58
|
|
|
|
|
|
|
'os' => 'win32', |
|
59
|
|
|
|
|
|
|
'ver' => '>= 95', |
|
60
|
|
|
|
|
|
|
'type' => 'byte', |
|
61
|
|
|
|
|
|
|
}; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub init { |
|
65
|
|
|
|
|
|
|
my ($this, $str, @params) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Accept a HEX address - else convert lpt1 -> 0 and then 0 -> 0x378 |
|
68
|
|
|
|
|
|
|
if ($str =~ /^0x/) { |
|
69
|
|
|
|
|
|
|
$this->{DATA}{BASE} = $str * 1; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
|
|
|
|
|
|
$this->{DATA}{BASE} = $this->num_to_hardware($this->address_to_num($str)); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
croak "Invalid BASE address to Device::ParallelPort::drv::win32 ($str)" unless (($this->{DATA}{BASE} * 1) > 1); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$this->{DATA}{GET} = Win32::API->new("inpout32", "Inp32", ['I'], 'I') |
|
76
|
|
|
|
|
|
|
or die "Failed to load inpout32.dll - Can't create Inp32 2 - $!"; #import Inp32 from DLL |
|
77
|
|
|
|
|
|
|
$this->{DATA}{SET} = Win32::API->new("inpout32", "Out32", ['I', 'I'], 'I') |
|
78
|
|
|
|
|
|
|
or die "Failed to load inpout32.dll - Can't create Out32 - $!"; #import Out32 from DLL |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub set_byte { |
|
82
|
|
|
|
|
|
|
my ($this, $byte, $val) = @_; |
|
83
|
|
|
|
|
|
|
croak "Invalid byte" unless ($byte >=0 && $byte <= 2); |
|
84
|
|
|
|
|
|
|
$this->{DATA}{SET}->Call($this->{DATA}{BASE} + $byte, ord($val)); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub get_byte { |
|
88
|
|
|
|
|
|
|
my ($this, $byte, $val) = @_; |
|
89
|
|
|
|
|
|
|
croak "Invalid byte" unless ($byte >=0 && $byte <= 2); |
|
90
|
|
|
|
|
|
|
return chr($this->{DATA}{GET}->Call($this->{DATA}{BASE} + $byte)); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
|