projects
/
huawei.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
specify port at command line
[huawei.git]
/
at-chat.pl
diff --git
a/at-chat.pl
b/at-chat.pl
index
7157a30
..
37fa988
100755
(executable)
--- a/
at-chat.pl
+++ b/
at-chat.pl
@@
-5,7
+5,7
@@
use strict;
use Device::SerialPort;
use Data::Dump qw(dump);
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";
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
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 ) {
my $ret = $port->read(1);
again:
while ( my $c = $port->input ) {
@@
-49,9
+51,9
@@
again:
return $ret;
}
return $ret;
}
-c 'ATE0' => 'echo off';
-
#
c 'ATZ' => 'reset';
-#
+
#
c 'ATE0' => 'echo off';
+c 'ATZ' => 'reset';
+
c 'ATI' => 'info';
c 'AT+CGMI' => 'manufacturer';
c 'ATI' => 'info';
c 'AT+CGMI' => 'manufacturer';