We've been using Printer::ESCPOS module but we could not make it to work on USB or Serial connection.
Whenever we tried printing to a POS printer interface to a PC using USB or Serial cable, we always encounter "Negative repeat count does nothing at Serial.pm on line 93
my $buffer = $self->_buffer;
if ( defined $raw ) {
$buffer = $raw;
}
else {
$self->_buffer('');
}
my $n = 8; # Size of each chunk in bytes
$n = 64 if ( $self->serialOverUSB );
@chunks = unpack "a$n" x ( ( length($buffer) / $n ) - 1 ) . "a*", $buffer;
for my $chunk (@chunks) {
$self->_connection->write($chunk);
if ( $self->serialOverUSB ) {
$self->_connection->read();
}
else {
usleep(10000)
; # Serial Port is annoying, it doesn't tell you when it is ready to get the next chunk
}
}
and 102 for USB,pm.
USB.pm error will be on line 102 (for loop), code snippet below
my $buffer = $self->_buffer;
if ( defined $raw ) {
$buffer = $raw;
}
else {
$self->_buffer('');
}
my $n = 2**14; # Size of each chunk in bytes
@chunks = unpack "a$n" x ( ( length($buffer) / $n ) - 1 ) . "a*", $buffer;
for my $chunk (@chunks) {
$self->_connection->bulk_write( $self->endPoint, $chunk,
$self->timeout );
usleep(10000)
; # USB Port is sometimes annoying, it doesn't always tell you when it is ready to get the next chunk
}