Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Problem with rs232 GSM device

by rrozman (Initiate)
on Oct 09, 2002 at 09:04 UTC ( [id://203861]=perlquestion: print w/replies, xml ) Need Help??

rrozman has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I've problem with rs 232 communication with Siemens GSM modem device (it requires hardware flow control and ANSI emulation according to spec.). When I try my attached code I get "framing error detected" on fresh boot up. If I run Hyperterminal with default parameters (9600 8-N-1 + HW control) GSM device responds, and then after this my code also works. I've checked things with "mode com5" and settings actually change only after Hyperterminal. If I run my code on fresh values, they don't change after my script. So obviously I must be doing something wrong in code. When my code doesn't work I get "framing error detected" message so it probably runs on default baudrate - like my code didn't change settings appropriately... Please give me some advice or help, regards, Robert Rozman ------------------my code-----------------------------
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

    I'm still waiting for my M20, so I only can suggest to have a look at Device::Gsm.

    Hth, Valerio

Re: Problem with rs232 GSM device
by jlongino (Parson) on Oct 09, 2002 at 15:27 UTC
    It looks as if you've covered the standard communications settings but what about ANSI emulation according to spec.? Is it possible that Hyperterminal is doing something in that respect that you aren't? I don't really know what is meant by that phrase but it might be worth looking into (although personally I'd check out the module valdez suggested first).

    --Jim

      I'm not sure that I've covered standard communication settings. It seems (checked with "mode com5") that my code doesn't set com port values correctly as Hyperterminal does... Device is Combiset standalone GSM gateway device - I'm not sure whether resembles Siemens GSM phones that suggested module covers. REgards, Robert.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-19 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found