X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=qcdm.pl;h=57125b461f66505d0184e37b697638b90332421c;hb=00d6f06e01867e32b1d8d35bf166f20368d95673;hp=693e48dfa76b0150b7647c11351f9beef296f17c;hpb=9952172f4e84cc1fe59a84052e3c20658c89bf4b;p=huawei.git diff --git a/qcdm.pl b/qcdm.pl index 693e48d..57125b4 100755 --- a/qcdm.pl +++ b/qcdm.pl @@ -53,7 +53,8 @@ sub crc { -my $device = $ENV{DEVICE} || '/dev/ttyUSB2'; # last device! control port! +my $device = $ARGV[0] || $ENV{DEVICE} || '/dev/ttyUSB2'; # last device! control port! +my $at_qcdmg = $ARGV[1]; # force AT$QCDMG from command-line my $port = Device::SerialPort->new( $device ) || die "$device: $!"; $port->baudrate(115200) || die "fail $device baudrate"; @@ -73,10 +74,12 @@ $port->read_const_time(3000); # 1 s read timeout while ( my $drain = $port->input ) { warn "# drain $drain\n"; + $at_qcdmg = 1; +} +if ( $at_qcdmg ) { $port->write('AT$QCDMG' . "\r"); - warn "DIAG mode: ", $port->read(2), $port->input; # OK+cr/lf - + warn "DIAG mode: ", $port->read(9 + 3); # echo, OK+cr/lf } my $diag = {