| 1 | package Device::TLSPrinter; | ||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Class::Accessor; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | { | ||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | no strict "vars"; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 3 | $VERSION = '0.51'; | |||||||||||||||||||||||||||||||||||||
| 10 | 3 | @ISA = qw< Exporter Class::Accessor >; | |||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | 3 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||
| 13 | feedback => [qw< | ||||||||||||||||||||||||||||||||||||||
| 14 | FC_OK FC_SERIAL_TIMEOUT_ERROR FC_COMMAND_ERROR | ||||||||||||||||||||||||||||||||||||||
| 15 | FC_MEMORY_FULL_ERROR FC_IMAGE_ALREADY_EXISTS | ||||||||||||||||||||||||||||||||||||||
| 16 | FC_IMMEDIATE_COMMANDS_ENABLED FC_OUT_OF_LABELS FC_PRINTHEAD_OPEN | ||||||||||||||||||||||||||||||||||||||
| 17 | FC_OUT_OF_RIBBON FC_BATTERY_CELL_SHORTED FC_LOW_BATTERY | ||||||||||||||||||||||||||||||||||||||
| 18 | FC_PRINTING_COMPLETE FC_PRINTING_COMPLETE FC_NO_LABEL_FORMAT_ERROR | ||||||||||||||||||||||||||||||||||||||
| 19 | FC_MEMORY_READ_ERROR FC_MEDIA_CHANGED FC_PRINTHEAD_TOO_HOT | ||||||||||||||||||||||||||||||||||||||
| 20 | FC_LABEL_ERROR FC_FIELD_ERROR FC_FEED_TO_CUT_COMPLETE | ||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | FC_UNDEF FC_IMMEDIATE_COMMANDS_DISABLED FC_NOT_IN_LABEL_EDIT_MODE | ||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | ROTATION_NONE ROTATION_90 ROTATION_180 ROTATION_270 | ||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | TYPE_FONT TYPE_BARCODE_39 TYPE_BARCODE_39_WITH_CHECK | ||||||||||||||||||||||||||||||||||||||
| 27 | TYPE_BARCODE_128 TYPE_IMAGE | ||||||||||||||||||||||||||||||||||||||
| 28 | >], | ||||||||||||||||||||||||||||||||||||||
| 29 | ascii => [qw< | ||||||||||||||||||||||||||||||||||||||
| 30 | SOH STX CR | ||||||||||||||||||||||||||||||||||||||
| 31 | >], | ||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | 3 | $EXPORT_TAGS{all} = [ @{$EXPORT_TAGS{feedback}}, @{$EXPORT_TAGS{ascii}} ]; | |||||||||||||||||||||||||||||||||||||
| 35 | 3 | @EXPORT = ( @{$EXPORT_TAGS{feedback}} ); | |||||||||||||||||||||||||||||||||||||
| 36 | 3 | @EXPORT_OK = ( @{$EXPORT_TAGS{ascii}} ); | |||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | # ASCII constants | ||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 42 | 3 | SOH => "\x01", | |||||||||||||||||||||||||||||||||||||
| 43 | STX => "\x02", | ||||||||||||||||||||||||||||||||||||||
| 44 | CR => "\x0D", | ||||||||||||||||||||||||||||||||||||||
| 45 | CRLF => "\x0D\x0A", | ||||||||||||||||||||||||||||||||||||||
| 46 | LF => "\x0A", | ||||||||||||||||||||||||||||||||||||||
| 47 | 3 | }; | |||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 50 | # standard feedback chars | ||||||||||||||||||||||||||||||||||||||
| 51 | 3 | FC_OK => "0", | |||||||||||||||||||||||||||||||||||||
| 52 | FC_SERIAL_TIMEOUT_ERROR => "1", | ||||||||||||||||||||||||||||||||||||||
| 53 | FC_COMMAND_ERROR => "2", | ||||||||||||||||||||||||||||||||||||||
| 54 | FC_MEMORY_FULL_ERROR => "3", | ||||||||||||||||||||||||||||||||||||||
| 55 | FC_IMAGE_ALREADY_EXISTS => "4", | ||||||||||||||||||||||||||||||||||||||
| 56 | FC_IMMEDIATE_COMMANDS_ENABLED => "5", | ||||||||||||||||||||||||||||||||||||||
| 57 | FC_OUT_OF_LABELS => "6", | ||||||||||||||||||||||||||||||||||||||
| 58 | FC_PRINTHEAD_OPEN => "7", | ||||||||||||||||||||||||||||||||||||||
| 59 | FC_OUT_OF_RIBBON => "8", | ||||||||||||||||||||||||||||||||||||||
| 60 | FC_BATTERY_CELL_SHORTED => "A", | ||||||||||||||||||||||||||||||||||||||
| 61 | FC_LOW_BATTERY => "B", | ||||||||||||||||||||||||||||||||||||||
| 62 | FC_PRINTING_COMPLETE => "C", | ||||||||||||||||||||||||||||||||||||||
| 63 | FC_NO_LABEL_FORMAT_ERROR => "D", | ||||||||||||||||||||||||||||||||||||||
| 64 | FC_MEMORY_READ_ERROR => "E", | ||||||||||||||||||||||||||||||||||||||
| 65 | FC_MEDIA_CHANGED => "F", | ||||||||||||||||||||||||||||||||||||||
| 66 | FC_PRINTHEAD_TOO_HOT => "G", | ||||||||||||||||||||||||||||||||||||||
| 67 | FC_LABEL_ERROR => "H", | ||||||||||||||||||||||||||||||||||||||
| 68 | FC_FIELD_ERROR => "I", | ||||||||||||||||||||||||||||||||||||||
| 69 | FC_FEED_TO_CUT_COMPLETE => "J", | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | # custom feedback chars | ||||||||||||||||||||||||||||||||||||||
| 72 | FC_UNDEF => "~", | ||||||||||||||||||||||||||||||||||||||
| 73 | FC_IMMEDIATE_COMMANDS_DISABLED => ";", | ||||||||||||||||||||||||||||||||||||||
| 74 | FC_NOT_IN_LABEL_EDIT_MODE => ":", | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | # rotations | ||||||||||||||||||||||||||||||||||||||
| 77 | ROTATION_NONE => 1, | ||||||||||||||||||||||||||||||||||||||
| 78 | ROTATION_90 => 2, | ||||||||||||||||||||||||||||||||||||||
| 79 | ROTATION_180 => 3, | ||||||||||||||||||||||||||||||||||||||
| 80 | ROTATION_270 => 4, | ||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | # field types | ||||||||||||||||||||||||||||||||||||||
| 83 | TYPE_FONT => "9", | ||||||||||||||||||||||||||||||||||||||
| 84 | TYPE_BARCODE_39 => "a", | ||||||||||||||||||||||||||||||||||||||
| 85 | TYPE_BARCODE_39_WITH_CHECK => "b", | ||||||||||||||||||||||||||||||||||||||
| 86 | TYPE_BARCODE_128 => "c", | ||||||||||||||||||||||||||||||||||||||
| 87 | TYPE_IMAGE => "Y", | ||||||||||||||||||||||||||||||||||||||
| 88 | 3 | }; | |||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||
| 90 | # object fields and default values | ||||||||||||||||||||||||||||||||||||||
| 91 | 3 | my %object_fields = ( | |||||||||||||||||||||||||||||||||||||
| 92 | # internal parameters | ||||||||||||||||||||||||||||||||||||||
| 93 | _device => undef, # device string | ||||||||||||||||||||||||||||||||||||||
| 94 | _socket => undef, # IO::Socket::INET object | ||||||||||||||||||||||||||||||||||||||
| 95 | _serial => undef, # {Device,Win32}::SerialPort object | ||||||||||||||||||||||||||||||||||||||
| 96 | _timeout => 10, # timeout | ||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||
| 98 | # public attributes | ||||||||||||||||||||||||||||||||||||||
| 99 | feedback_chars => 0, # are feedback characters enabled? | ||||||||||||||||||||||||||||||||||||||
| 100 | immediate_cmds => 0, # are immediate commands enabled? | ||||||||||||||||||||||||||||||||||||||
| 101 | label_edition => 0, # currently in label editing mode? | ||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | # create accessors | ||||||||||||||||||||||||||||||||||||||
| 105 | 3 | __PACKAGE__->mk_accessors(keys %object_fields); | |||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | # private variables | ||||||||||||||||||||||||||||||||||||||
| 108 | 3 | my $HEX = "[0-9A-Fa-f]"; | |||||||||||||||||||||||||||||||||||||
| 109 | 3 | my $HEXNUM = $HEX x 2; | |||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||||||||||||
| 113 | # new() | ||||||||||||||||||||||||||||||||||||||
| 114 | # --- | ||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=30.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 116 | 2 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | # if missing, try to infer the type from the device param | ||||||||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | if (not $args{type}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if (eval { $args{device}->isa("Device::SerialPort") } ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $args{type} = "serial" | |||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||
| 123 | 0 | elsif (eval { $args{device}->isa("Win32::SerialPort") } ) { | |||||||||||||||||||||||||||||||||||||
| 124 | 0 | $args{type} = "serial" | |||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||
| 126 | elsif ($args{device} =~ m{^COM\d|^/dev/(?:term|tty)}) { | ||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $args{type} = "serial" | |||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||
| 129 | elsif ($args{device} =~ m{^[a-zA-Z0-9.-]+:[0-9]+$}) { | ||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $args{type} = "network" | |||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | # enable debug mode? | ||||||||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | { local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | *DEBUG = $args{debug} ? \&_DEBUG : sub {}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | # check arguments | ||||||||||||||||||||||||||||||||||||||
| 140 | 2 | ▶ | carp "warning: You should specify the connection type" unless exists $args{type}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | croak "error: Missing required parameter: device" unless exists $args{device}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | # create the object and populate the attributes | ||||||||||||||||||||||||||||||||||||||
| 144 | my %fields = ( | ||||||||||||||||||||||||||||||||||||||
| 145 | %object_fields, # default values | ||||||||||||||||||||||||||||||||||||||
| 146 | _type => $args{type}, | ||||||||||||||||||||||||||||||||||||||
| 147 | _device => $args{device}, | ||||||||||||||||||||||||||||||||||||||
| 148 | _timeout => $args{timeout}, | ||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ); | |||||||||||||||||||||||||||||||||||||
| 150 | 1 | my $self = __PACKAGE__->SUPER::new(\%fields); | |||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||
| 152 | # initialize the backend driver | ||||||||||||||||||||||||||||||||||||||
| 153 | 1 | my ($driver) = $args{type} =~ /^(\w+)$/; | |||||||||||||||||||||||||||||||||||||
| 154 | 1 | $class = __PACKAGE__."::".ucfirst($driver); | |||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | eval "require $class" | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 156 | or croak "error: Could not load driver $class: no such module"; | ||||||||||||||||||||||||||||||||||||||
| 157 | 1 | bless $self, $class; # rebless the object into the class of the driver | |||||||||||||||||||||||||||||||||||||
| 158 | 1 | $self->init(); | |||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||
| 160 | 1 | return $self | |||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | # | ||||||||||||||||||||||||||||||||||||||
| 165 | # _DEBUG() | ||||||||||||||||||||||||||||||||||||||
| 166 | # ------ | ||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub _DEBUG { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_DEBUG: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 168 | 0 | print STDERR @_, $/ | |||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||
| 172 | # | ||||||||||||||||||||||||||||||||||||||
| 173 | # exec_command() | ||||||||||||||||||||||||||||||||||||||
| 174 | # ------------ | ||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub exec_command { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
exec_command: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 177 | 0 | my ($rc, $answer, $n) = (FC_UNDEF, "", 0); | |||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | carp "error: Missing required parameter: cmd" and return unless $args{cmd}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$args{'cmd'} || carp('error: Missing required parameter: cmd') && (return)
carp("error: Missing required parameter: cmd") and return
MC/DC0%0/2
$args{'cmd'} || carp('error: Missing required parameter: cmd') && (return)
$args{'cmd'}
carp("error: Missing required parameter: cmd")
Truth table0%0/3
A || B
A= $args{'cmd'}B= carp("error: Missing required parameter: cmd")
| |||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | # send the data | ||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $n = $self->write(data => $args{cmd}); | |||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||
| 184 | # read the answer if any is expected | ||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ($args{expect}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my ($left_to_read, $read, $chunk); | |||||||||||||||||||||||||||||||||||||
| 187 | 0 | $left_to_read = $args{expect}; | |||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | while ($left_to_read > 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ($read, $chunk) = $self->read(expect => $left_to_read); | |||||||||||||||||||||||||||||||||||||
| 191 | 0 | $answer .= $chunk; | |||||||||||||||||||||||||||||||||||||
| 192 | 0 | $left_to_read -= $read; | |||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | # read the feedback character if enabled | ||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($args{feedback} and $self->feedback_chars) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"feedback"} and $self->feedback_chars
MC/DC0%0/2
$args{"feedback"} and $self->feedback_chars
$args{"feedback"}
$self->feedback_chars
Truth table0%0/3
A and B
A= $args{"feedback"}B= $self->feedback_chars
| |||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ($n, $rc) = $self->read(expect => 1); | |||||||||||||||||||||||||||||||||||||
| 199 | 0 | DEBUG(" >>> exec_command(): feedback='$rc' (", ord($rc), ")"); | |||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return ($rc, $answer) | |||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||
| 206 | # ======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 207 | # Immediate commands | ||||||||||||||||||||||||||||||||||||||
| 208 | # | ||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||
| 210 | 3 | my %ic_cmds = ( | |||||||||||||||||||||||||||||||||||||
| 211 | ic_printer_reset => { string => "#", expect => 25 }, | ||||||||||||||||||||||||||||||||||||||
| 212 | ic_printer_status => { | ||||||||||||||||||||||||||||||||||||||
| 213 | string => "A", expect => 9, filter => \&ic_filter_printer_status | ||||||||||||||||||||||||||||||||||||||
| 214 | }, | ||||||||||||||||||||||||||||||||||||||
| 215 | ic_toggle_pause => { string => "B", expect => 0 }, | ||||||||||||||||||||||||||||||||||||||
| 216 | ic_cancel_job => { string => "C", expect => 0 }, | ||||||||||||||||||||||||||||||||||||||
| 217 | ic_batch_quantity => { string => "E", expect => 5 }, | ||||||||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||
| 220 | 3 | for my $cmd (keys %ic_cmds) { | |||||||||||||||||||||||||||||||||||||
| 221 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | *$cmd = sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 224 | 0 | my ($rc, $raw, @data) = (FC_UNDEF); | |||||||||||||||||||||||||||||||||||||
| 225 | 0 | DEBUG(" >>> $cmd()"); | |||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ($self->immediate_cmds) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 228 | ($rc, $raw) = $self->exec_command( | ||||||||||||||||||||||||||||||||||||||
| 229 | cmd => SOH.$ic_cmds{$cmd}{string}, | ||||||||||||||||||||||||||||||||||||||
| 230 | expect => $ic_cmds{$cmd}{expect}, | ||||||||||||||||||||||||||||||||||||||
| 231 | 0 | feedback => 0, | |||||||||||||||||||||||||||||||||||||
| 232 | ); | ||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $rc = FC_OK; | |||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||
| 235 | # pass the raw result to the filter if it's defined | ||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if (defined $raw and ref $ic_cmds{$cmd}{filter} eq "CODE") { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $raw and ref $ic_cmds{$cmd}{"filter"} eq "CODE"
MC/DC0%0/2
defined $raw and ref $ic_cmds{$cmd}{"filter"} eq "CODE"
defined $raw
ref $ic_cmds{$cmd}{"filter"} eq "CODE"
Truth table0%0/3
A and B
A= defined $rawB= ref $ic_cmds{$cmd}{"filter"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||
| 237 | 0 | @data = $ic_cmds{$cmd}{filter}->($raw) | |||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||
| 240 | else { | ||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $rc = FC_IMMEDIATE_COMMANDS_DISABLED | |||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return wantarray ? ($rc, $raw, @data) : $rc | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||
| 246 | 15 | } | |||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||
| 249 | # | ||||||||||||||||||||||||||||||||||||||
| 250 | # ic_disable_immediate_cmds() | ||||||||||||||||||||||||||||||||||||||
| 251 | # ------------------------- | ||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | sub ic_disable_immediate_cmds { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ic_disable_immediate_cmds: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->exec_command(cmd => SOH."D"); | |||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->immediate_cmds(0); | |||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||
| 259 | # | ||||||||||||||||||||||||||||||||||||||
| 260 | # ic_filter_printer_status() | ||||||||||||||||||||||||||||||||||||||
| 261 | # ------------------------ | ||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub ic_filter_printer_status { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
ic_filter_printer_status: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||
| 265 | # decode the status | ||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my @chars = split //, $raw; | |||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my %status = ( | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 268 | printhead_open => $chars[0] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 269 | out_of_labels => $chars[1] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 270 | out_of_ribbon => $chars[2] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 271 | printing_batch => $chars[3] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 272 | busy_printing => $chars[4] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 273 | printer_paused => $chars[5] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 274 | touch_cell_error => $chars[6] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 275 | low_battery => $chars[7] eq "Y" ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||
| 276 | ); | ||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return %status | |||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||
| 282 | # ======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 283 | # System commands | ||||||||||||||||||||||||||||||||||||||
| 284 | # | ||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||
| 286 | 3 | my %sc_cmds = ( | |||||||||||||||||||||||||||||||||||||
| 287 | sc_heat_setting_offset => { string => "b%+02.2d" }, | ||||||||||||||||||||||||||||||||||||||
| 288 | sc_disable_feed_to_cut_position => { string => "C" }, | ||||||||||||||||||||||||||||||||||||||
| 289 | sc_enable_feed_to_cut_position => { string => "c" }, | ||||||||||||||||||||||||||||||||||||||
| 290 | sc_quantity_for_stored_labels => { string => "E%04d" }, | ||||||||||||||||||||||||||||||||||||||
| 291 | sc_form_feed => { string => "F" }, | ||||||||||||||||||||||||||||||||||||||
| 292 | sc_set_form_stop_position => { string => "f%+02.2d" }, | ||||||||||||||||||||||||||||||||||||||
| 293 | sc_print_last_label_format => { string => "G" }, | ||||||||||||||||||||||||||||||||||||||
| 294 | sc_set_printer_to_metric => { string => "m" }, | ||||||||||||||||||||||||||||||||||||||
| 295 | sc_set_printer_to_inches => { string => "n" }, | ||||||||||||||||||||||||||||||||||||||
| 296 | sc_set_start_of_print_offset => { string => "O+02.2d" }, | ||||||||||||||||||||||||||||||||||||||
| 297 | sc_set_horizontal_align_offset => { string => "o+02.2d" }, | ||||||||||||||||||||||||||||||||||||||
| 298 | sc_set_continuous_label_length => { string => "P%04d" }, | ||||||||||||||||||||||||||||||||||||||
| 299 | sc_clear_all_memory => { string => "Q" }, | ||||||||||||||||||||||||||||||||||||||
| 300 | sc_set_continuous_label_spacing => { string => "S%04d" }, | ||||||||||||||||||||||||||||||||||||||
| 301 | sc_print_test_label => { string => "T" }, | ||||||||||||||||||||||||||||||||||||||
| 302 | sc_get_touch_cell_data_binary => { | ||||||||||||||||||||||||||||||||||||||
| 303 | string => "t", expect => 32 | ||||||||||||||||||||||||||||||||||||||
| 304 | }, | ||||||||||||||||||||||||||||||||||||||
| 305 | sc_replace_label_format_field => { string => "U%02d%s".CR }, | ||||||||||||||||||||||||||||||||||||||
| 306 | sc_get_touch_cell_data_ascii => { | ||||||||||||||||||||||||||||||||||||||
| 307 | string => "V", expect => 32*2, filter => \&sc_filter_touch_cell_data_ascii | ||||||||||||||||||||||||||||||||||||||
| 308 | }, | ||||||||||||||||||||||||||||||||||||||
| 309 | sc_firmware_version => { | ||||||||||||||||||||||||||||||||||||||
| 310 | string => "v", expect => 25, filter => \&sc_filter_chomp | ||||||||||||||||||||||||||||||||||||||
| 311 | }, | ||||||||||||||||||||||||||||||||||||||
| 312 | sc_memory_information => { | ||||||||||||||||||||||||||||||||||||||
| 313 | string => "W%s", expect => 255, filter => \&sc_filter_memory_info | ||||||||||||||||||||||||||||||||||||||
| 314 | }, | ||||||||||||||||||||||||||||||||||||||
| 315 | sc_delete_file => { string => "x%s%s" }, | ||||||||||||||||||||||||||||||||||||||
| 316 | sc_pack_memory => { string => "z" }, | ||||||||||||||||||||||||||||||||||||||
| 317 | ); | ||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||
| 319 | 3 | for my $cmd (keys %sc_cmds) { | |||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | *$cmd = sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||
| 323 | 0 | my @data; | |||||||||||||||||||||||||||||||||||||
| 324 | 0 | DEBUG(" >>> $cmd(@args)"); | |||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||
| 326 | # execute the command | ||||||||||||||||||||||||||||||||||||||
| 327 | my ($rc, $raw) = $self->exec_command( | ||||||||||||||||||||||||||||||||||||||
| 328 | cmd => sprintf(STX.$sc_cmds{$cmd}{string}, @args), | ||||||||||||||||||||||||||||||||||||||
| 329 | expect => $sc_cmds{$cmd}{expect}, | ||||||||||||||||||||||||||||||||||||||
| 330 | 0 | feedback => 1, | |||||||||||||||||||||||||||||||||||||
| 331 | ); | ||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||
| 333 | # pass the raw result to the filter if it's defined | ||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if (defined $raw and ref $sc_cmds{$cmd}{filter} eq "CODE") { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $raw and ref $sc_cmds{$cmd}{"filter"} eq "CODE"
MC/DC0%0/2
defined $raw and ref $sc_cmds{$cmd}{"filter"} eq "CODE"
defined $raw
ref $sc_cmds{$cmd}{"filter"} eq "CODE"
Truth table0%0/3
A and B
A= defined $rawB= ref $sc_cmds{$cmd}{"filter"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||
| 335 | 0 | @data = $sc_cmds{$cmd}{filter}->($raw) | |||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | return wantarray ? ($rc, $raw, @data) : $rc | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||
| 340 | 66 | } | |||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||
| 343 | # | ||||||||||||||||||||||||||||||||||||||
| 344 | # sc_filter_chomp() | ||||||||||||||||||||||||||||||||||||||
| 345 | # --------------- | ||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub sc_filter_chomp { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_filter_chomp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||
| 348 | 0 | $raw =~ s/[\012\015]$//g; | |||||||||||||||||||||||||||||||||||||
| 349 | 0 | return $raw | |||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||
| 353 | # | ||||||||||||||||||||||||||||||||||||||
| 354 | # sc_filter_memory_info() | ||||||||||||||||||||||||||||||||||||||
| 355 | # --------------------- | ||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub sc_filter_memory_info { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_filter_memory_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||
| 358 | 0 | $raw =~ s/\b($HEX+)\s$/hex($1)/e; | |||||||||||||||||||||||||||||||||||||
| 359 | 0 | return split CR, $raw | |||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||
| 363 | # | ||||||||||||||||||||||||||||||||||||||
| 364 | # sc_filter_touch_cell_data_ascii() | ||||||||||||||||||||||||||||||||||||||
| 365 | # ------------------------------- | ||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub sc_filter_touch_cell_data_ascii { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_filter_touch_cell_data_ascii: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my @values = map {hex} $raw =~ m{ | |||||||||||||||||||||||||||||||||||||
| 370 | ^ $HEXNUM ($HEXNUM $HEXNUM) $HEXNUM $HEXNUM # label quantity | ||||||||||||||||||||||||||||||||||||||
| 371 | ($HEXNUM) ($HEXNUM $HEXNUM) ($HEXNUM $HEXNUM) # bits field, offset X and Y | ||||||||||||||||||||||||||||||||||||||
| 372 | ($HEXNUM $HEXNUM) ($HEXNUM $HEXNUM) # width, length | ||||||||||||||||||||||||||||||||||||||
| 373 | }x; | ||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my %fields = ( | |||||||||||||||||||||||||||||||||||||
| 376 | remaining_labels => $values[0], | ||||||||||||||||||||||||||||||||||||||
| 377 | notched_material => $values[1] & 1, | ||||||||||||||||||||||||||||||||||||||
| 378 | offset_x => $values[2], | ||||||||||||||||||||||||||||||||||||||
| 379 | offset_y => $values[3], | ||||||||||||||||||||||||||||||||||||||
| 380 | label_width => $values[4], | ||||||||||||||||||||||||||||||||||||||
| 381 | label_length => $values[5], | ||||||||||||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||
| 384 | 0 | return %fields | |||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||
| 388 | # | ||||||||||||||||||||||||||||||||||||||
| 389 | # sc_disable_feedback_chars() | ||||||||||||||||||||||||||||||||||||||
| 390 | # ------------------------- | ||||||||||||||||||||||||||||||||||||||
| 391 | ## @method string sc_disable_feedback_chars($self) | ||||||||||||||||||||||||||||||||||||||
| 392 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 393 | # | ||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub sc_disable_feedback_chars { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_disable_feedback_chars: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 396 | 0 | DEBUG(" >>> sc_disable_feedback_chars()"); | |||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->exec_command(cmd => STX."A", feedback => 0); | |||||||||||||||||||||||||||||||||||||
| 398 | 0 | $self->feedback_chars(0); | |||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||
| 402 | # | ||||||||||||||||||||||||||||||||||||||
| 403 | # sc_enable_feedback_chars() | ||||||||||||||||||||||||||||||||||||||
| 404 | # ------------------------ | ||||||||||||||||||||||||||||||||||||||
| 405 | ## @method string sc_enable_feedback_chars($self) | ||||||||||||||||||||||||||||||||||||||
| 406 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 407 | # | ||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | sub sc_enable_feedback_chars { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_enable_feedback_chars: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 410 | 0 | DEBUG(" >>> sc_enable_feedback_chars()"); | |||||||||||||||||||||||||||||||||||||
| 411 | 0 | $self->exec_command(cmd => STX."a", feedback => 0); | |||||||||||||||||||||||||||||||||||||
| 412 | 0 | $self->feedback_chars(1); | |||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||
| 416 | # | ||||||||||||||||||||||||||||||||||||||
| 417 | # sc_enable_immediate_cmds() | ||||||||||||||||||||||||||||||||||||||
| 418 | # ------------------------ | ||||||||||||||||||||||||||||||||||||||
| 419 | ## @method string sc_enable_immediate_cmds($self) | ||||||||||||||||||||||||||||||||||||||
| 420 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 421 | # | ||||||||||||||||||||||||||||||||||||||
| 422 | 3 | *ic_enable_immediate_cmds = \&sc_enable_immediate_cmds; | |||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | sub sc_enable_immediate_cmds { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_enable_immediate_cmds: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 425 | 0 | DEBUG(" >>> sc_enable_immediate_cmds()"); | |||||||||||||||||||||||||||||||||||||
| 426 | 0 | my ($rc) = $self->exec_command(cmd => STX."H", feedback => 1); | |||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | $self->immediate_cmds(1) if $rc eq FC_IMMEDIATE_COMMANDS_ENABLED; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return $rc | |||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||
| 432 | # | ||||||||||||||||||||||||||||||||||||||
| 433 | # sc_input_image_data() | ||||||||||||||||||||||||||||||||||||||
| 434 | # ------------------- | ||||||||||||||||||||||||||||||||||||||
| 435 | ## @method string sc_input_image_data($self, $data_type, $format, $image_name, @image_data) | ||||||||||||||||||||||||||||||||||||||
| 436 | # @param data_type string | ||||||||||||||||||||||||||||||||||||||
| 437 | # @param format string, image format designation | ||||||||||||||||||||||||||||||||||||||
| 438 | # @param image_name string, image name, up to 8 characters long | ||||||||||||||||||||||||||||||||||||||
| 439 | # @param image_data array or image data | ||||||||||||||||||||||||||||||||||||||
| 440 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 441 | # | ||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub sc_input_image_data { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_input_image_data: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my ($self, $data_type, $format, $image_name, @image_data) = @_; | |||||||||||||||||||||||||||||||||||||
| 444 | 0 | DEBUG(" >>> sc_input_image_data($data_type, $format, $image_name)"); | |||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||
| 446 | # check arguments | ||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | carp "error: Invalid value for data type: '$data_type'" | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$data_type =~ /^[AB]$/ || carp("error: Invalid value for data type: '${data_type}'") && (return)
carp("error: Invalid value for data type: '${data_type}'") and return
MC/DC0%0/2
$data_type =~ /^[AB]$/ || carp("error: Invalid value for data type: '${data_type}'") && (return)
$data_type =~ /^[AB]$/
carp("error: Invalid value for data type: '${data_type}'")
Truth table0%0/3
A || B
A= $data_type =~ /^[AB]$/B= carp("error: Invalid value for data type: '${data_type}'")
| |||||||||||||||||||||||||||||||||||||||
| 448 | and return if $data_type !~ /^[AB]$/; | ||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | carp "error: Invalid value for format designation: '$format'" | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$format =~ /^[BbPpU]$/ || carp("error: Invalid value for format designation: '${format}'") && (return)
carp("error: Invalid value for format designation: '${format}'") and return
MC/DC0%0/2
$format =~ /^[BbPpU]$/ || carp("error: Invalid value for format designation: '${format}'") && (return)
$format =~ /^[BbPpU]$/
carp("error: Invalid value for format designation: '${format}'")
Truth table0%0/3
A || B
A= $format =~ /^[BbPpU]$/B= carp("error: Invalid value for format designation: '${format}'")
| |||||||||||||||||||||||||||||||||||||||
| 450 | and return if $format !~ /^[BbPpU]$/; | ||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||
| 452 | # first disable immediate commands if they were enabled | ||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $ic_enabled = $self->immediate_cmds; | |||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | $self->ic_disable_immediate_cmds if $ic_enabled; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||
| 456 | # then send the actual image command | ||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $cmd = sprintf STX."I%s%s%s".CR, $data_type, $format, $image_name; | |||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $data = join '', @image_data; | |||||||||||||||||||||||||||||||||||||
| 459 | 0 | my ($rc) = $self->exec_command(cmd => $cmd.$data, feedback => 1); | |||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||
| 461 | # finaly restore immediate commands | ||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | $self->sc_enable_immediate_cmds if $ic_enabled; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return $rc | |||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||
| 468 | # | ||||||||||||||||||||||||||||||||||||||
| 469 | # sc_extended_system_cmds() | ||||||||||||||||||||||||||||||||||||||
| 470 | # ----------------------- | ||||||||||||||||||||||||||||||||||||||
| 471 | ## @method string sc_extended_system_cmds($self) | ||||||||||||||||||||||||||||||||||||||
| 472 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 473 | # | ||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | sub sc_extended_system_cmds { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_extended_system_cmds: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 476 | 0 | DEBUG(" >>> sc_extended_system_cmds()"); | |||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->exec_command(cmd => STX."K", feedback => 0); | |||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||
| 481 | # | ||||||||||||||||||||||||||||||||||||||
| 482 | # sc_enter_label_formatting_cmd() | ||||||||||||||||||||||||||||||||||||||
| 483 | # ----------------------------- | ||||||||||||||||||||||||||||||||||||||
| 484 | ## @method string sc_enter_label_formatting_cmd($self) | ||||||||||||||||||||||||||||||||||||||
| 485 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | sub sc_enter_label_formatting_cmd { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_enter_label_formatting_cmd: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 489 | 0 | DEBUG(" >>> sc_enter_label_formatting_cmd()"); | |||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my ($rc) = $self->exec_command(cmd => STX."L", feedback => 1); | |||||||||||||||||||||||||||||||||||||
| 492 | 0 | $self->label_edition(1); | |||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||
| 494 | 0 | return $rc | |||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||
| 498 | # ======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 499 | # Label formatting commands | ||||||||||||||||||||||||||||||||||||||
| 500 | # | ||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||
| 502 | 3 | my %lc_cmds = ( | |||||||||||||||||||||||||||||||||||||
| 503 | lc_set_format_attribute => { string => "A%d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 504 | lc_set_column_offset => { string => "C%04d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 505 | lc_end_label_formatting_and_print => { string => "E".CR, end_mode => 1 }, | ||||||||||||||||||||||||||||||||||||||
| 506 | lc_set_row_offset => { string => "C%04d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 507 | lc_end_label_formatting => { string => "X".CR, end_mode => 1 }, | ||||||||||||||||||||||||||||||||||||||
| 508 | lc_increment_prev_numeric_field => { string => "+%s%02d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 509 | lc_decrement_prev_numeric_field => { string => "-%s%02d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 510 | lc_increment_prev_alphanum_field => { string => ">%s%02d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 511 | lc_decrement_prev_alphanum_field => { string => "<%s%02d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 512 | lc_set_count_by_amount => { string => "^%02d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 513 | lc_add_field => { string => "%d%s00%03d%04d%04d".CR }, | ||||||||||||||||||||||||||||||||||||||
| 514 | ); | ||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||
| 516 | 3 | for my $cmd (keys %lc_cmds) { | |||||||||||||||||||||||||||||||||||||
| 517 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | *$cmd = sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||
| 520 | 0 | DEBUG(" >>> $cmd(@args)"); | |||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||
| 522 | # check that we're in label formatting mode | ||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | return FC_NOT_IN_LABEL_EDIT_MODE | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 524 | unless $self->label_edition; | ||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||
| 526 | # execute the command | ||||||||||||||||||||||||||||||||||||||
| 527 | my ($rc) = $self->exec_command( | ||||||||||||||||||||||||||||||||||||||
| 528 | cmd => sprintf($lc_cmds{$cmd}{string}, @args), | ||||||||||||||||||||||||||||||||||||||
| 529 | expect => $lc_cmds{$cmd}{expect}, | ||||||||||||||||||||||||||||||||||||||
| 530 | 0 | feedback => 1, | |||||||||||||||||||||||||||||||||||||
| 531 | ); | ||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||
| 533 | # end edition mode if needed | ||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if ($lc_cmds{$cmd}{end_mode}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $self->label_edition(0) | |||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||
| 538 | 0 | return $rc | |||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||
| 540 | 33 | } | |||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||
| 543 | # ======================================================================== | ||||||||||||||||||||||||||||||||||||||
| 544 | # High-level commands | ||||||||||||||||||||||||||||||||||||||
| 545 | # | ||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||
| 548 | # | ||||||||||||||||||||||||||||||||||||||
| 549 | # hc_flush_input() | ||||||||||||||||||||||||||||||||||||||
| 550 | # -------------- | ||||||||||||||||||||||||||||||||||||||
| 551 | ## @method string hc_flush_input($self) | ||||||||||||||||||||||||||||||||||||||
| 552 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 553 | # | ||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | sub hc_flush_input { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
hc_flush_input: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 556 | 0 | my ($n, $data) = (1, ""); | |||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||
| 558 | # read everything in the input buffer | ||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | while ($n) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | local $SIG{ALRM} = sub { $n = 0; die "read timeout\n" }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 561 | 0 | alarm 2; | |||||||||||||||||||||||||||||||||||||
| 562 | 0 | ($n, $data) = eval { $self->read(expect => 20) }; | |||||||||||||||||||||||||||||||||||||
| 563 | 0 | alarm 0; | |||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | $n ||= 0; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$n ||= 0
MC/DC0%0/1
$n ||= 0
$n
Truth table0%0/2
A
A= $n
| |||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||
| 567 | 0 | return FC_OK | |||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||
| 571 | # | ||||||||||||||||||||||||||||||||||||||
| 572 | # hc_upload_label() | ||||||||||||||||||||||||||||||||||||||
| 573 | # --------------- | ||||||||||||||||||||||||||||||||||||||
| 574 | ## @method string hc_upload_label($self, %params) | ||||||||||||||||||||||||||||||||||||||
| 575 | # @param lines arrayref of lines describing the label | ||||||||||||||||||||||||||||||||||||||
| 576 | # @param print_now boolean | ||||||||||||||||||||||||||||||||||||||
| 577 | # @return feedback code | ||||||||||||||||||||||||||||||||||||||
| 578 | # | ||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | sub hc_upload_label { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
hc_upload_label: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||
| 581 | 0 | DEBUG(" >>> hc_upload_label()"); | |||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $rc; | |||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | croak "error: Missing required parameter: lines" unless exists $args{lines}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | croak "error: Invalid value for parameter 'lines'" unless ref $args{lines} eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||
| 586 | # prepare the data to be sent | ||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my @lines = @{ $args{lines} }; | |||||||||||||||||||||||||||||||||||||
| 588 | 0 | chomp @lines; | |||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||
| 590 | # send the label data | ||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->sc_enter_label_formatting_cmd; | |||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||
| 593 | 0 | for my $line (@lines) { | |||||||||||||||||||||||||||||||||||||
| 594 | 0 | ($rc) = $self->exec_command(cmd => $line.CR, feedback => 1); | |||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | last if $rc ne FC_OK; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||
| 598 | # in case of error, stop and return the last feedback char | ||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ($rc ne FC_OK) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $self->lc_end_label_formatting; | |||||||||||||||||||||||||||||||||||||
| 601 | 0 | return $rc | |||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||
| 604 | # end the label edition mode | ||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | if ($args{print_now}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ($rc) = $self->lc_end_label_formatting_and_print | |||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||
| 608 | else { | ||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ($rc) = $self->lc_end_label_formatting | |||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||
| 612 | 0 | return $rc | |||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||
| 616 | 3 | 1; | |||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||
| 618 | __END__ | ||||||||||||||||||||||||||||||||||||||