add autoreset command and do_exit option

This commit is contained in:
maralvira 2010-11-07 14:08:50 +00:00
parent e886e83908
commit ee943c062d

View file

@ -13,6 +13,8 @@ my $term = '/dev/ttyUSB0';
my $baud = '115200'; my $baud = '115200';
my $verbose; my $verbose;
my $rts = 'rts'; my $rts = 'rts';
my $command = '';
my $do_exit;
GetOptions ('file=s' => \$filename, GetOptions ('file=s' => \$filename,
'secondfile=s' => \$second, 'secondfile=s' => \$second,
@ -20,6 +22,8 @@ GetOptions ('file=s' => \$filename,
'verbose' => \$verbose, 'verbose' => \$verbose,
'baud=s' => \$baud, 'baud=s' => \$baud,
'rts=s' => \$rts, 'rts=s' => \$rts,
'command=s' => \$command,
'exit' => \$do_exit,
) or die 'bad options'; ) or die 'bad options';
$| = 1; $| = 1;
@ -29,11 +33,15 @@ if($filename eq '') {
print " or : mc1322x-load.pl -f flasher.bin -s flashme.bin 0x1e000,0x11223344,0x55667788\n"; print " or : mc1322x-load.pl -f flasher.bin -s flashme.bin 0x1e000,0x11223344,0x55667788\n";
print " -f required: binary file to load\n"; print " -f required: binary file to load\n";
print " -s optional: secondary binary file to send\n"; print " -s optional: secondary binary file to send\n";
print " -t default: /dev/ttyUSB0\n"; print " -t terminal default: /dev/ttyUSB0\n";
print " -b default: 115200\n"; print " -b baud rate default: 115200\n";
print " -r [none|rts] flow control default: rts\n"; print " -r [none|rts] flow control default: rts\n";
print " anything on the command line is sent\n"; print " -c command to run for autoreset: \n";
print " after all of the files.\n"; print " e.g. -c 'bbmc -l redbee-econotag -i 0 reset'\n";
print " -e exit instead of dropping to terminal display\n";
print "\n";
print "anything on the command line is sent\n";
print "after all of the files.\n\n";
exit; exit;
} }
@ -56,6 +64,7 @@ $ob->read_const_time(1000); # 1 second per unfulfilled "read" call
$ob->rts_active(1); $ob->rts_active(1);
my $s = 0; my $s = 0;
my $reset = 0;
while(1) { while(1) {
@ -65,6 +74,12 @@ while(1) {
$ob->write(pack('C','0')); $ob->write(pack('C','0'));
if(($command ne '') &&
($reset eq 0)) {
$reset++;
system($command);
}
if($s == 1) { if($s == 1) {
$test = 'ready'; $test = 'ready';
} else { } else {
@ -121,6 +136,10 @@ if(scalar(@ARGV)!=0) {
$ob->write(','); $ob->write(',');
} }
if(defined($do_exit)) {
exit;
}
my $c; my $count; my $c; my $count;
while(1) { while(1) {
($count, $c) = $ob->read(1); ($count, $c) = $ob->read(1);