adiuva has asked for the wisdom of the Perl Monks concerning the following question:
Thank you in advance! Regards, Stefanuse IO::Socket; use IO::Select; my $COMport=33; while (1) { #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"; print "reading\n"; #Reading the response while (my $ret=<PORT>) { print $ret; if ($ret=~/^OK/ || $ret=~/^ERROR/) { last} } close(PORT); } print "done!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trying to read from serial port - not getting a response
by graff (Chancellor) on Dec 05, 2012 at 02:20 UTC | |
by adiuva (Sexton) on Dec 05, 2012 at 10:23 UTC | |
by graff (Chancellor) on Dec 05, 2012 at 22:27 UTC | |
by adiuva (Sexton) on Dec 06, 2012 at 09:26 UTC | |
by adiuva (Sexton) on Dec 05, 2012 at 14:58 UTC | |
|
Re: Trying to read from serial port - not getting a response
by ColonelPanic (Friar) on Dec 04, 2012 at 13:22 UTC | |
by adiuva (Sexton) on Dec 04, 2012 at 13:33 UTC |