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; }; };

In reply to Problem with rs232 GSM device by rrozman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.