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
Well, if i connect to the modem directly with Putty for example and execute the same command I'm getting the expected feedback. I also tried different modems with the same result. I think for some reason the response is not ending up the file handle. If you look at the first code I posted you see that the loop to output the response should only be entered if there is anything in the filehandle. But it never entered it. In the second code it's just getting stuck as there is nothing in the filehandle as well.
Could you maybe explain more detailed (or provide links) what you mean with "more explicit file handle discipline"? I'm not a very experienced programmer so I would need more input to understand :)
I tried both now - read and sysread. But both loops are not beeing entered at all:
Here's what's happening:my $read; my $sysread; #Reading the response print "reading...\n"; while ( read(PORT,$read,2048) ) { print "using read:\n"; print $read; } while (sysread(PORT, $sysread, 10000)) { print "using sysread:\n"; print $sysread; }
c:\Dropbox\Scripts>perl PortTest.pl Enter AT command:ATI0 Sending: 'ATI0' reading... done! c:\Dropbox\Scripts>
In Section
Seekers of Perl Wisdom