No response from printer using Win32::SerialPort

No response from printer using Win32::SerialPort

am 11.10.2006 17:36:33 von woodycm

I've posted this topic on Perlmonks.org and comp.lang.perl.misc as
well...

I am using Win32::SerialPort to communicate (ie print) with a PAXAR
9855 printer. I can poll the printer status using Windows Terminal and
PAXAR's own gui tool, but cannot get a response from my perl program
(attached below). The print part works fine, it's the read that doesn't
work. Actually when SerialPort.pm runs, the got_p scalar, which is
where I believe the response from the device is populated, is blank (as
in null/nothing).

Any help would be greatly
appreciated.
Thanks

Begin Code....

#!c:\perl\bin\perl
require 5.002;
use Win32;
use Win32::SerialPort;
use Win32::API;

$SerialPort = "COM1";
$ENQ = "^E";

$Port = Win32::SerialPort->new($SerialPort);
$Port->baudrate(9600) || die "failed setting baudrate";
$Port->parity("none") || die "failed setting parity";
$Port->databits(8) || die "failed setting databits";
$Port->stopbits(1) || die "failed setting databits";
$Port->handshake("xoff") || die "failed setting handshake";
$flowcontrol = $Port->handshake || die "failed setting flowcontrol";

$Port->user_msg(1);
$Port->error_msg(1);
$Port->debug(1);

$Port->write_settings || die "no settings";

#Write Immediate command to allow for Polling.
print "Send Immediate Command\n";
$Port->write('{I,E,"~123~044~034~124~125~126~094"|}');

#Print Label
$record_to_print = '';
$record_to_print = $record_to_print.'{F,26,A,R,E,600,400,"FMT26"|';
$record_to_print =
$record_to_print.'C,400,50,0,50,16,16,O,L,0,0,"CARTON",0|}';
$record_to_print = $record_to_print.'{B,26,N,1|}';
$Port->write($record_to_print);
sleep 2;

#Read from Printer
undef $msg;
($count, $msg) = $Port->read(4); # Read string 1
$code1 = substr($msg,1,1);
$code2 = substr($msg,2,1);
print "DATA = $msg | COUNT = $count\n";
print "CODE1 = $code1\n";
print "CODE2 = $code2\n";
sleep 2;

#Print ENQ to poll printer
$Port->write("^E");

#Read from Printer
undef $msg;
$msg = $Port->read(3); # Read string 1
$code1 = substr($msg,1,1);
$code2 = substr($msg,2,1);
print "DATA = $msg\n";
print "CODE1 = $code1\n";
print "CODE2 = $code2\n";

End Code....