X-Git-Url: http://git.rot13.org/?p=huawei.git;a=blobdiff_plain;f=at-chat.pl;h=37fa988d1ecbec529e4eeab9461e5b8812e013c9;hp=7157a30559d8198da1b9fa5e07c6ac05dd2c40c8;hb=47be57c9c075d029ca9b63bc93658fdc9c97112b;hpb=86f97ad79d997e1846fd5c567f13697b369789cf diff --git a/at-chat.pl b/at-chat.pl index 7157a30..37fa988 100755 --- a/at-chat.pl +++ b/at-chat.pl @@ -5,7 +5,7 @@ use strict; use Device::SerialPort; use Data::Dump qw(dump); -my $device = $ENV{DEVICE} || '/dev/ttyUSB0'; +my $device = $ENV{DEVICE} || shift @ARGV || '/dev/ttyUSB0'; my $port = Device::SerialPort->new( $device ) || die "$device: $!"; $port->baudrate(115200) || die "fail $device baudrate"; @@ -35,7 +35,9 @@ sub c { print STDERR ">>> $cmd >>> $message\n"; $port->write("$cmd\r"); # $port->write_done(1); # flush - $port->write_drain; +# $port->write_drain; + $port->read( length($cmd) + 1 ); # slurp echo + my $ret = $port->read(1); again: while ( my $c = $port->input ) { @@ -49,9 +51,9 @@ again: return $ret; } -c 'ATE0' => 'echo off'; -#c 'ATZ' => 'reset'; -# +#c 'ATE0' => 'echo off'; +c 'ATZ' => 'reset'; + c 'ATI' => 'info'; c 'AT+CGMI' => 'manufacturer';