| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Device::Opto22::Firewire; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
923
|
use IO::Socket; |
|
|
1
|
|
|
|
|
28204
|
|
|
|
1
|
|
|
|
|
4
|
|
|
7
|
1
|
|
|
1
|
|
6037
|
use IO::Select; |
|
|
1
|
|
|
|
|
1732
|
|
|
|
1
|
|
|
|
|
51
|
|
|
8
|
1
|
|
|
1
|
|
861
|
use POSIX; |
|
|
1
|
|
|
|
|
11474
|
|
|
|
1
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(IO::Socket); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = ( ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT = qw( ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.90'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$| = 1; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Global Data Area |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# TCode for transmission |
|
23
|
|
|
|
|
|
|
our $TC_WR_QUAD_RQST = 0; |
|
24
|
|
|
|
|
|
|
our $TC_WR_BLK_RQST = 1; |
|
25
|
|
|
|
|
|
|
our $TC_RD_QUAD_RQST = 4; |
|
26
|
|
|
|
|
|
|
our $TC_RD_BLK_RQST = 5; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# TCode for responses |
|
29
|
|
|
|
|
|
|
our $TC_WR_RSP = 2; |
|
30
|
|
|
|
|
|
|
our $TC_RD_BLK_RSP = 6; |
|
31
|
|
|
|
|
|
|
our $TC_RD_QUAD_RSP = 7; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $timeout = 5; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
my $class = shift @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my %args = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $PeerAddr = $args{PeerAddr}; |
|
42
|
0
|
|
|
|
|
|
my $PeerPort = $args{PeerPort}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
0
|
|
|
|
if (not ($PeerAddr && $PeerPort) ) { |
|
45
|
0
|
|
|
|
|
|
die "Inputs missing in Package $class. Require PeerAddr and PeerPort"; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# This establishes a SENDER socket connection OK |
|
49
|
0
|
|
|
|
|
|
my $self = new IO::Socket::INET (PeerAddr => $PeerAddr , |
|
50
|
|
|
|
|
|
|
PeerPort => $PeerPort , |
|
51
|
|
|
|
|
|
|
Proto => 'tcp', |
|
52
|
|
|
|
|
|
|
Timeout => $timeout ); |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
unless ( $self ) { die "Error Socket Connecting" } |
|
|
0
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Init a error message |
|
57
|
0
|
|
|
|
|
|
${*$self}->{'error_msg'} = ""; |
|
|
0
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$SIG{ALRM} = \&_time_out ; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
bless $self, $class; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
67
|
|
|
|
|
|
|
# Description: Does a socket transation |
|
68
|
|
|
|
|
|
|
# |
|
69
|
|
|
|
|
|
|
# Inputs: $socket - Socket descriptor |
|
70
|
|
|
|
|
|
|
# $packet - Request packet to send |
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
# Output: |
|
73
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub chat { |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
0
|
|
my ($self, $packet) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my ($rsp,$cnt); |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
eval { |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
alarm ($timeout) ; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
print $self $packet; |
|
86
|
0
|
|
|
|
|
|
$cnt = $self->recv($rsp, 300, 0 ) ; |
|
87
|
0
|
|
|
|
|
|
alarm(0); |
|
88
|
|
|
|
|
|
|
}; |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
unless ( length($rsp) ) |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
0
|
|
|
|
|
|
${*$self}->{'error_msg'} = "$@ - Nothing returned in Chat" ; |
|
|
0
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
return 0 ; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Split response |
|
97
|
0
|
|
|
|
|
|
my $header = substr $rsp, 0 , 16; |
|
98
|
0
|
|
|
|
|
|
my $payload; |
|
99
|
0
|
0
|
|
|
|
|
if ( length($rsp) >= 16 ) { $payload = substr $rsp, 16 } |
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my @header_lst = unpack ("C8", $header ) ; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my $tcode = $header_lst[3] >> 4 ; |
|
104
|
0
|
|
|
|
|
|
my $rcode = $header_lst[6] >> 4 ; |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if ($rcode) { |
|
107
|
0
|
|
|
|
|
|
${*$self}->{'error_msg'} = "oh oh we got a NAK in Chat" ; |
|
|
0
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return 0 ; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ( $tcode == 2 ) { $payload = 1 ; } |
|
|
0
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return ($payload) ; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
117
|
|
|
|
|
|
|
# Description: Formats a packet as per pg 106 of the SNAP Users Guide |
|
118
|
|
|
|
|
|
|
# |
|
119
|
|
|
|
|
|
|
# Inputs: $offset (hexidecimal MemMap address) |
|
120
|
|
|
|
|
|
|
# |
|
121
|
|
|
|
|
|
|
# Output: pointer to the packet consisting of 16 bytes |
|
122
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub bld_rd_quad_packet { |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
|
|
0
|
0
|
|
my ($self, $offset) = @_; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $src_id = 0; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my $trans += 1; # global variable |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $dest_id = 0; # Destination ID |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $tl = ($trans & 0x3f) << 2; # Transaction Label (shifted to set retry bits to 00) |
|
135
|
0
|
|
|
|
|
|
my $tcode = $TC_RD_QUAD_RQST << 4; # Bit shift over the unused priority bits |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my $fixed = 0xffff ; # fixed area of address |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $packet = pack "ncc n2 N N", $dest_id, $tl, $tcode, $src_id, $fixed, $offset ; |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
return $packet; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
146
|
|
|
|
|
|
|
# Description: Formats a packet as per pg 106 of the SNAP Users Guide |
|
147
|
|
|
|
|
|
|
# |
|
148
|
|
|
|
|
|
|
# Inputs: $offset - (hexidecimal MemMap address which is prefixed with $fixed) |
|
149
|
|
|
|
|
|
|
# $data - 4 bytes of data to write |
|
150
|
|
|
|
|
|
|
# |
|
151
|
|
|
|
|
|
|
# Output: pointer to the packet consisting of 16 bytes |
|
152
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub bld_wr_quad_packet { |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
0
|
0
|
|
my ($self, $offset, $data) = @_; |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
my $trans += 1; # global variable |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
my $src_id = 0 ; |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my $dest_id = 0; # Destination ID |
|
163
|
0
|
|
|
|
|
|
my $tl = ($trans & 0x3f) << 2; # Transaction Label (shifted to set retry bits to 00) |
|
164
|
0
|
|
|
|
|
|
my $tcode = $TC_WR_QUAD_RQST << 4; # Bit shift over the unused priority bits |
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $fixed = 0xffff ; # fixed area of address |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $packet = pack "ncc n2 N N", $dest_id, $tl, $tcode, $src_id, $fixed, $offset, $data; |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
return $packet; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
175
|
|
|
|
|
|
|
# Description: Formats a packet as per pg 106 of the SNAP Users Guide |
|
176
|
|
|
|
|
|
|
# |
|
177
|
|
|
|
|
|
|
# Inputs: $offset - (hexidecimal MemMap address which is prefixed with $fixed) |
|
178
|
|
|
|
|
|
|
# $data - 4 bytes of data to write |
|
179
|
|
|
|
|
|
|
# |
|
180
|
|
|
|
|
|
|
# Output: pointer to the packet consisting of 16 bytes |
|
181
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub bld_rd_blk_packet { |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
0
|
0
|
|
my ($self, $offset, $length) = @_; |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $trans += 1; # global variable |
|
188
|
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
my $src_id = 0 ; |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $dest_id = 0; # Destination ID |
|
192
|
0
|
|
|
|
|
|
my $tl = ($trans & 0x3f) << 2; # Transaction Label (shifted to set retry bits to 00) |
|
193
|
0
|
|
|
|
|
|
my $tcode = $TC_RD_BLK_RQST << 4; # Bit shift over the unused priority bits |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my $fixed = 0xffff ; # fixed area of address |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
$length = $length << 16 ; |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
my $packet = pack "ncc n2 N2", $dest_id, $tl, $tcode, $src_id, $fixed, $offset, $length ; |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
return $packet; |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
206
|
|
|
|
|
|
|
# Description: Formats a packet as per pg 106 of the SNAP Users Guide |
|
207
|
|
|
|
|
|
|
# |
|
208
|
|
|
|
|
|
|
# Inputs: $offset - (hexidecimal MemMap address which is prefixed with $fixed) |
|
209
|
|
|
|
|
|
|
# $data - 4 bytes of data to write |
|
210
|
|
|
|
|
|
|
# |
|
211
|
|
|
|
|
|
|
# Output: pointer to the packet consisting of 16 bytes |
|
212
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub bld_wr_blk_packet { |
|
215
|
|
|
|
|
|
|
|
|
216
|
0
|
|
|
0
|
0
|
|
my ($self, $offset, $length) = @_; |
|
217
|
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
my $trans += 1; # global variable |
|
219
|
|
|
|
|
|
|
|
|
220
|
0
|
|
|
|
|
|
my $src_id = 0 ; |
|
221
|
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
my $dest_id = 0; # Destination ID |
|
223
|
0
|
|
|
|
|
|
my $tl = ($trans & 0x3f) << 2; # Transaction Label (shifted to set retry bits to 00) |
|
224
|
0
|
|
|
|
|
|
my $tcode = $TC_WR_BLK_RQST << 4; # Bit shift over the unused priority bits |
|
225
|
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
my $fixed = 0xffff ; # fixed area of address |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
$length = $length << 16 ; |
|
229
|
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
my $packet = pack "ncc n2 N2", $dest_id, $tl, $tcode, $src_id, $fixed, $offset, $length ; |
|
231
|
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
|
return $packet; |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# Report error message |
|
237
|
|
|
|
|
|
|
sub error_msg |
|
238
|
|
|
|
|
|
|
{ |
|
239
|
0
|
|
|
0
|
0
|
|
my $self = shift @_; |
|
240
|
0
|
|
|
|
|
|
return ${*$self}->{'error_msg'}; |
|
|
0
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
#------------------ |
|
245
|
|
|
|
|
|
|
# Private Functions |
|
246
|
|
|
|
|
|
|
#------------------ |
|
247
|
|
|
|
|
|
|
sub _time_out { |
|
248
|
|
|
|
|
|
|
|
|
249
|
0
|
|
|
0
|
|
|
die "Error Time Out" ; |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub dump_quadlet |
|
255
|
|
|
|
|
|
|
{ |
|
256
|
0
|
|
|
0
|
0
|
|
my $self = shift @_ ; |
|
257
|
0
|
|
|
|
|
|
my $data = shift @_ ; |
|
258
|
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
my $len = length($data); |
|
260
|
0
|
|
|
|
|
|
print "Length $len\n"; |
|
261
|
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
my @lst = split // , unpack "B128" , $data ; |
|
263
|
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
my $cnt; |
|
265
|
0
|
|
|
|
|
|
foreach my $b (@lst) |
|
266
|
|
|
|
|
|
|
{ |
|
267
|
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
print "$b "; |
|
269
|
0
|
|
|
|
|
|
$cnt++; |
|
270
|
0
|
0
|
|
|
|
|
unless ( $cnt % 8 ) { print " " } |
|
|
0
|
|
|
|
|
|
|
|
271
|
0
|
0
|
|
|
|
|
unless ( $cnt % 32 ) { print "\n" } |
|
|
0
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
print "\n"; |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
1; |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|