-my $device = shift @ARGV || $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";
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 = {