Click here to get back home

No response from printer using Win32::SerialPort

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
No response from printer using Win32::SerialPort woodycm 10-11-2006
Posted by woodycm on October 11, 2006, 11:36 am
Please log in for more thread options


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('');

#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.'';
$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....


Similar ThreadsPosted
Win32::Printer::Enum::Printer($server) June 23, 2005, 2:18 pm
Problem printing a file uing Win32::Printer September 30, 2006, 3:36 pm
Error calling Win32::Printer from a perl script hosted in IIS on Win2k3 June 3, 2008, 8:53 am
Error calling Win32::Printer from a perl script hosted in IIS on Win2k3 June 3, 2008, 8:57 am
Need help with Win32::SerialPort August 13, 2004, 5:43 am
help on win32::serialport June 4, 2007, 5:12 pm
Please help on win32::serialport July 13, 2007, 12:41 pm
problem in using win32::SerialPort September 7, 2007, 2:27 am
Win32::serialport and Windows NT 4 July 31, 2007, 6:08 pm
win32::SerialPort are_match just won't work February 15, 2006, 8:05 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap