rrozman has asked for the wisdom of the Perl Monks concerning the following question:
BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use lib '../lib', '../lib/site'"; # Use BEGIN eval to ke +ep perl2exe happy eval "use Win32::SerialPort"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN if ($OS_win) { $port = 'COM5'; $ob = Win32::SerialPort->new ($port); } else { $port = '/dev/modem'; $ob = Device::SerialPort->new ($port); } die "Can't open serial port $port: $^E\n" unless ($ob); $ob->user_msg(1); # misc. warnings $ob->error_msg(1); # hardware and data errors $ob->baudrate(9600); $ob->parity("none"); ## $ob->parity_enable(1); # for any parity except "none" $ob->databits(8); $ob->stopbits(1); $ob->handshake("rts"); $ob->read_interval(0) if ($OS_win); $ob->read_const_time(10000); #---------------------START------------------------------------------- +--- $result=''; my $temp_result=0; until ($result eq "AT\r\n\r\nOK\r\n") { $ob->write("AT\r\n"); print "Sending: AT \n"; sleep 3; $result = $ob->input; print "Got something back: $result \n" if ($result); if ($result eq "AT\r\n\r\nOK\r\n") { &printx ($result); print "Got Acknowledge: $result \n"; $temp_result=1; } else { sleep 10; }; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with rs232 GSM device
by valdez (Monsignor) on Oct 09, 2002 at 09:56 UTC | |
|
Re: Problem with rs232 GSM device
by jlongino (Parson) on Oct 09, 2002 at 15:27 UTC | |
by rrozman (Initiate) on Oct 09, 2002 at 16:47 UTC |