Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Trying to read from serial port - not getting a response

by adiuva (Sexton)
on Dec 04, 2012 at 13:33 UTC ( [id://1007091]=note: print w/replies, xml ) Need Help??


in reply to Re: Trying to read from serial port - not getting a response
in thread Trying to read from serial port - not getting a response

I got it "simpler" before changing to this version, but it didn't work either. Here's the modified version:
use Strict; use IO::Socket; use IO::Select; my $COMport=33; #open Port or die if blocked / wrong port if (!open( PORT, "+>\\\\.\\COM$COMport" )) { die ("Can't open COM$COMport"); } PORT->autoflush(1); PORT->flush(); print "\nEnter AT command:"; my $ATcmd=<STDIN>; chomp($ATcmd); # remove CRLF $ATcmd =~ s/^\s+//; # remove leading space $ATcmd =~ s/\s+$//; # remove trailing space print "Sending: '$ATcmd'\n"; print PORT $ATcmd . "\r\n"; sleep(2); #Reading the response print "reading\n"; while (1) { my $ret=<PORT>; print $ret; if ($ret=~/^OK/ || $ret=~/^ERROR/) { last} } close(PORT); print "done!";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1007091]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2025-03-18 14:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (57 votes). Check out past polls.