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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |