From c8bde02029c61160f56218fdc0b5f4f4d9bed4f4 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 27 Jan 2012 15:48:52 +0100 Subject: [PATCH] more command, better handling of response --- qcom-chat.pl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/qcom-chat.pl b/qcom-chat.pl index 71fb97c..a901ce3 100755 --- a/qcom-chat.pl +++ b/qcom-chat.pl @@ -20,8 +20,8 @@ $port->user_msg(1); $port->error_msg(1); $port->debug(1); -$port->read_char_time(1000); # 0.1 s char timeout -$port->read_const_time(500); # 0.5 s read timeout +$port->read_char_time(3000); # 5 s char timeout +$port->read_const_time(3000); # 1 s read timeout while ( my $drain = $port->input ) { warn "# drain $drain\n# /drain\n"; @@ -37,13 +37,14 @@ sub c { # $port->write_done(1); # flush $port->write_drain; my $ret = $port->read(1); +again: while ( my $c = $port->input ) { print STDERR "<<< ",dump($ret . $c), $/; $ret .= $c; # last if $c =~ m/^OK\r/; } + goto again unless $ret =~ s/\r\n(OK|ERROR)\r\n$//s || warn "ERROR: can't find OK or ERROR status!\n"; $ret =~ s/^[\r\n]+//; - $ret =~ s/\r\nOK\r\n$// || warn "ERROR: missing OK"; print "$cmd [$message] = $ret\n"; return $ret; } @@ -53,15 +54,23 @@ c 'ATE0' => 'echo off'; # c 'ATI' => 'info'; -c 'AT+CGMI' => 'CGMI'; +c 'AT+CGMI' => 'manufacturer'; -c 'AT+CGMM' => 'CGMM'; +c 'AT+CGMM' => 'model'; -c 'AT+CGMR' => 'CGMR'; +c 'AT+CGMR' => 'revision'; + +c 'AT+CGSN' => 'serial'; + +c 'AT+GCAP' => 'capabilities'; c 'AT+CIMI' => 'IMSI'; -c 'AT+CGSN' => 'CGSN'; +c 'AT+CNUM' => 'MSISDN'; + +#c 'AT+COPS=?' => 'operators'; # times out + +c 'AT+CLCK=?' => 'facility lock'; c 'AT^CVOICE?' => 'is voice enabled?'; -- 2.20.1