EAFDSS

 view release on metacpan or  search on metacpan

lib/EAFDSS.pm  view on Meta::CPAN

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
0x02: Field too long
0x03: Field too small
0x04: Field fixed size mismatch
0x05: Field range or type check failed
0x06: Bad request code
0x09: Printing type bad
0x0A: Cannot execute with day open
0x0B: RTC programming requires jumper
0x0C: RTC date or time invalid
0x0D: No records in fiscal period
0x0E: Device is busy in another task
0x0F: No more header records allowed
0x10: Cannot execute with block open
0x11: Block not open
0x12: Bad data stream
0x13: Bad signature field
0x14: Z closure time limit
0x15: Z closure not found
0x16: Z closure record bad
0x17: User browsing in progress
0x18: Signature daily limit reached

lib/EAFDSS/Base.pm  view on Meta::CPAN

347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
        return (0, $deviceDir);
}
 
sub _Recover {
        my($self) = shift @_;
        my($reply, $status1, $status2, $lastZ, $total, $daily, $signBlock, $remainDaily);
 
        ($reply, $status1, $status2) = $self->PROTO_GetStatus();
        if ($reply ne "0") { return $reply };
 
        my($busy, $fatal, $paper, $cmos, $printer, $user, $fiscal, $battery) = $self->UTIL_devStatus($status1);
        if ($cmos != 1) { return 0 };
 
        my($day, $signature, $recovery, $fiscalWarn, $dailyFull, $fiscalFull) = $self->UTIL_appStatus($status1);
 
        $self->debug("   CMOS is set, going for recovery!");
 
        ($reply, $status1, $status2, $lastZ, $total, $daily, $signBlock, $remainDaily) = $self->PROTO_ReadSummary(0);
        if ($reply != 0) {
                $self->debug("   Aborting recovery because of ReadClosure reply [%d]", $reply);
                return $reply

lib/EAFDSS/Dummy.pm  view on Meta::CPAN

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
case 00+0x02     { return "Field too long"}
case 00+0x03     { return "Field too small"}
case 00+0x04     { return "Field fixed size mismatch"}
case 00+0x05     { return "Field range or type check failed"}
case 00+0x06     { return "Bad request code"}
case 00+0x09     { return "Printing type bad"}
case 00+0x0A     { return "Cannot execute with day open"}
case 00+0x0B     { return "RTC programming requires jumper"}
case 00+0x0C     { return "RTC date or time invalid"}
case 00+0x0D     { return "No records in fiscal period"}
case 00+0x0E     { return "Device is busy in another task"}
case 00+0x0F     { return "No more header records allowed"}
case 00+0x10     { return "Cannot execute with block open"}
case 00+0x11     { return "Block not open"}
case 00+0x12     { return "Bad data stream"}
case 00+0x13     { return "Bad signature field"}
case 00+0x14     { return "Z closure time limit"}
case 00+0x15     { return "Z closure not found"}
case 00+0x16     { return "Z closure record bad"}
case 00+0x17     { return "User browsing in progress"}
case 00+0x18     { return "Signature daily limit reached"}

lib/EAFDSS/Dummy.pm  view on Meta::CPAN

386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
=head2 UTIL_devStatus
 
=cut
 
sub UTIL_devStatus {
        my($self)   = shift @_;
        my($status) = sprintf("%08b", shift);
        my(@status) = split(//, $status);
 
        my($busy, $fatal, $paper, $cmos, $printer, $user, $fiscal, $battery) =
                ($status[7],$status[6],$status[5],$status[4],$status[3],$status[2],$status[1],$status[0]);
 
        return ($busy, $fatal, $paper, $cmos, $printer, $user, $fiscal, $battery);
}
 
=head2 UTIL_appStatus
 
=cut
 
sub UTIL_appStatus {
        my($self)   = shift @_;
 
        my($status) = sprintf("%08b", shift);

lib/EAFDSS/Micrelec.pm  view on Meta::CPAN

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
case 00+0x02     { return "Field too long"}
case 00+0x03     { return "Field too small"}
case 00+0x04     { return "Field fixed size mismatch"}
case 00+0x05     { return "Field range or type check failed"}
case 00+0x06     { return "Bad request code"}
case 00+0x09     { return "Printing type bad"}
case 00+0x0A     { return "Cannot execute with day open"}
case 00+0x0B     { return "RTC programming requires jumper"}
case 00+0x0C     { return "RTC date or time invalid"}
case 00+0x0D     { return "No records in fiscal period"}
case 00+0x0E     { return "Device is busy in another task"}
case 00+0x0F     { return "No more header records allowed"}
case 00+0x10     { return "Cannot execute with block open"}
case 00+0x11     { return "Block not open"}
case 00+0x12     { return "Bad data stream"}
case 00+0x13     { return "Bad signature field"}
case 00+0x14     { return "Z closure time limit"}
case 00+0x15     { return "Z closure not found"}
case 00+0x16     { return "Z closure record bad"}
case 00+0x17     { return "User browsing in progress"}
case 00+0x18     { return "Signature daily limit reached"}

lib/EAFDSS/Micrelec.pm  view on Meta::CPAN

424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
=head2 UTIL_devStatus
 
=cut
 
sub UTIL_devStatus {
        my($self)   = shift @_;
        my($status) = sprintf("%08b", shift);
        my(@status) = split(//, $status);
 
        my($busy, $fatal, $paper, $cmos, $printer, $user, $fiscal, $battery) =
                ($status[7],$status[6],$status[5],$status[4],$status[3],$status[2],$status[1],$status[0]);
 
        return ($busy, $fatal, $paper, $cmos, $printer, $user, $fiscal, $battery);
}
 
=head2 UTIL_appStatus
 
=cut
 
sub UTIL_appStatus {
        my($self)   = shift @_;
 
        my($status) = sprintf("%08b", shift);

lib/EAFDSS/SDNP.pm  view on Meta::CPAN

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
sub SendRequest {
        my($self)   = shift @_;
        my($opcode) = shift @_;
        my($opdata) = shift @_;
        my($data)   = shift @_;
 
        my(%reply) = ();
 
        # For at least 6 times do:
        my($busy_try, $state, $try);
        BUSY: for ($busy_try = 1; $busy_try <= 3; $busy_try++) {
                for ($try = 1; $try < 6; $try++) {
                        my(%reply)  = ();
                        $self->debug("    Send Request try #%d", $try);
                        SYNC:
                        # If state is UNSYNCHRONIZED or connection SYNC timer expired then:
                        if ($self->_getTimer('_TSYNC') >= 0) {
                                $self->debug("      Syncing with device");
                                if ( $self->_sdnpSync() == 0) {
                                        $self->debug("        Sync Failed");
                                        $self->error(64+3);

lib/EAFDSS/SDNP.pm  view on Meta::CPAN

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
}
#$self->debug(  "        Checking Data checksum [%04X]", $checksum);
if ($checksum != $reply{CHECKSUM}) {
        # Create and send NAK frame with FSN set to received FSN;
        my($msg) = $self->sdnpPacket(0x13, 0x00);
        $self->_sdnpPrintFrame("      ----> [%s]\n", $msg);
        $self->{_SOCKET}->send($msg);
        next;
} else {
        if ( $reply{DATA} =~ /^0E/ ) {
                $self->debug("      Will retry because of busyness $busy_try");
                $state = "BUSY";
                sleep 2;
                next BUSY;
        } else {
                $self->debug("      Done Getting reply");
 
                # Renew connection's SYNC timer;
                $self->_setTimer('_TSYNC', 4);
 
                # Advance connection's NextFSN by one;

lib/EAFDSS/SDNP.pm  view on Meta::CPAN

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
                                                next;
                                        }
                                } else {
                                        $self->debug(  "        Bad Frame, Discarding");
                                }
                        }
                }
        }
 
        if ($state eq "BUSY") {
                $self->debug("      Too busy device... aborting");
                $reply{DATA}   = "0E/0/";
        }
 
        # Return request transmittion failure;
        return %reply;
}
 
sub _sdnpQuery {
        my($self)  = shift @_;
        my($devices);

lib/EAFDSS/SDSP.pm  view on Meta::CPAN

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
        $self->{_SERIAL}->stopbits(1);
 
        $self->{_SERIAL}->read_const_time(1);
 
        my($reply, $deviceID) = $self->PROTO_ReadDeviceID();
        if ( ($reply == 0) && ($deviceID ne $self->{SN}) ) {
                return $self->error("Serial Number not matching");
        }
         
        if ( $reply ==0x0E ) {
                return $self->error("Device is too busy!");
        }
 
        if ( $reply != 0 ) {
                return $self->error("Error initializing device");
        }
 
        return $self;
}
 
=head2 SendRequest

lib/EAFDSS/SDSP.pm  view on Meta::CPAN

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
=cut
 
sub SendRequest {
        my($self)   = shift @_;
        my($opcode) = shift @_;
        my($opdata) = shift @_;
        my($data)   = shift @_;
 
        my(%reply) = ();
 
        my($busy_try, $try, $state);
 
        BUSY: for ($busy_try = 1; $busy_try <= 3; $busy_try++) {
                $self->{_SERIAL}->read_const_time(3000);
                $self->{_SERIAL}->read_char_time(0);
                $state = "ENQ";
                ENQ: for ($try = 1; $try <= 3; $try++) {
                        my($count_out);
                        $self->debug("    Sending ENQ [try %d]", $try);
                        $count_out = $self->{_SERIAL}->write($control->{'CAN'});
                        $count_out = $self->{_SERIAL}->write($control->{'CAN'});
                        $count_out = $self->{_SERIAL}->write($control->{'CAN'});
                        $count_out = $self->{_SERIAL}->write($control->{'ENQ'});

lib/EAFDSS/SDSP.pm  view on Meta::CPAN

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
        if ($count_in && ($c ne $control->{'ETX'} ) ) {
                $full_reply .= $c;
        }
} until ($c eq $control->{'ETX'});
$full_reply =~ /(.*)\/(\d\d)$/;
($reply, $checksum) =  ($1, $2);
if ( $checksum == $self->_checksum($reply . "/")) {
        $self->debug("      Got Reply [%s]", $reply);
        $self->{_SERIAL}->write($control->{'ACK'});
        if ( $reply =~ /^0E/ ) {
                $self->debug("      Will retry because of busyness");
                sleep 2;
                next BUSY;
        } else {
                $self->debug("      Done Getting reply");
                $state = "DONE";
                last REPLY;
        }
} else {
        $self->{_SERIAL}->write($control->{'NAK'});
        $self->debug("      Discarding because of bad checksum");

lib/EAFDSS/SDSP.pm  view on Meta::CPAN

198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
                }
                if ($state ne "DONE") {
                        $reply{DATA}   = "02/0/";
                        return %reply;
                } else {
                        $reply{DATA}   = $reply;       
                        return %reply;
                }
        }
 
        $self->debug("      Too busy device... aborting");
        $reply{DATA}   = "0E/0/";
        return %reply;
}
 
sub _sdnpQuery {
        my($self)  = shift @_;
        return (0, undef);
}
 
sub _checksum {



( run in 0.390 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )