view release on metacpan or search on metacpan
lib/EAFDSS.pm view on Meta::CPAN
3613623633643653663673683693703713723733743753763773783793803810x02: 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
347348349350351352353354355356357358359360361362363364365366367
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
341342343344345346347348349350351352353354355356357358359360361case 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
386387388389390391392393394395396397398399400401402403404405406407408409=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
377378379380381382383384385386387388389390391392393394395396397case 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
424425426427428429430431432433434435436437438439440441442443444445446447=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
93949596979899100101102103104105106107108109110111112113114sub
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
165166167168169170171172173174175176177178179180181182183184185}
#$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
194195196197198199200201202203204205206207208209210211212213214
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
8081828384858687888990919293949596979899100
$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
104105106107108109110111112113114115116117118119120121122123124125126=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
175176177178179180181182183184185186187188189190191192193194195
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
198199200201202203204205206207208209210211212213214215216217218
}
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 {