Hello all,

First question asked, so please bear with me...

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 in pointing me to where I have gone wrong, would be greatly appreciated.
Thanks
#!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,"CART +ON",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"; exit;

In reply to No response from printer using Win32::SerialPort by woodycm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.