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