Good morning to all who are in the monastery!!

Fellow Monks, I need some assistance with a Win32::SerialPort issue that is driving me nuts. I can write to the serial device all day long and it works just fine. In fact, I have written my script completely to do what I need to do with configuring my serial device from the "write" perspective. However, reading from the device doesn't appear to be working at all like I expect it to work. When I login to the device through PuTTY, this is what I see...

Welcome to the MRV Communications' LX Series Server Port 0 Speed 9600 Login: InReach Password: ******** { screen refresh and blank, then } InReach:0 >

This is what I expect to see when I run my script against the device, but it's not. I pulled the relevant pieces of my script out into a separate test script and have been playing around with "read" and "input". Here is my code:

#!C:/Perl/bin/perl.exe use warnings; use strict; use Win32::SerialPort; my $response; my $port = Win32::SerialPort->new("COM1"); $port->user_msg(1); $port->error_msg(1); $port->baudrate(9600); $port->databits(8); $port->parity("none"); $port->stopbits(1); $port->handshake("xoff"); $port->buffers(8192, 8192); $port->are_match(":", ">", ">>", "\n"); $port->write_settings; $response = $port->input; print "DEBUG: response1 = $response\n"; $port->write("InReach\r"); sleep 1; $response = $port->input; print "DEBUG: response2 = $response\n"; $port->write("********\r"); sleep 1; $response = $port->input; print "DEBUG: response3 = $response\n"; $port->write("exit\r"); sleep 1; $response = $port->input; print "DEBUG: response4 = $response\n";

This is what I get back when I run my script:

C:\Users\MyID\Documents\Perl\Test>SerialPortTest.pl DEBUG: response1 = DEBUG: response2 = InReach Password: DEBUG: response3 = ******** InReach:0 >exit[H[2J[2J Disconnected [H[2J Welcome to the MRV Communications' LX Series Server

What I expect to see is response1 equal to the first three lines of the manual login, response2 equal to "Password:", response3 equal to "InReach:0 >", and response 4 equal to the first three lines of the manual login again. What I don't expect to see is the string I am writing echoed back to me before the response. Am I not understanding the "input" command properly? Am I expecting too much? Also, is there a way to get rid of the control characters in the response3 lines above?

Many thanks in advance!!

ImJustAFriend


In reply to Win32::SerialPort read/input issues by ImJustAFriend

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.