From 4730dc048d49d3ecaa9ff0f9174e3fdb56aa5c2e Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 8 May 2009 15:28:34 -0400 Subject: [PATCH 1/2] fixed syntax errors. --- mc1322x-load.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mc1322x-load.pl b/mc1322x-load.pl index 2863a39b3..f454736bd 100755 --- a/mc1322x-load.pl +++ b/mc1322x-load.pl @@ -33,7 +33,7 @@ if($filename eq '') { my $ob = Device::SerialPort->new ($term) or die "Can't start $term\n"; # next test will die at runtime unless $ob -if(($filename eq '')) die "you must specify a file with -f\n"; +if ($filename eq '') { die "you must specify a file with -f\n"; } $ob->baudrate($baud); $ob->parity('none'); @@ -68,7 +68,7 @@ my $s = 0; print $ret . "\n"; - if (defined $filename) { + if (-e $filename) { my $size = -s $filename; @@ -88,9 +88,9 @@ my $s = 0; } } - if(-e $second) {$s=1; $filename = $second; continue SEND; } + if(-e $second) {$s=1; $filename = $second; next SEND; } -} +}; print "done.\n"; From b7b99c15f2c9a36683d7328d269e8d142d22e763 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 8 May 2009 15:10:21 -0400 Subject: [PATCH 2/2] first try at dual stage loading. --- mc1322x-load.pl | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/mc1322x-load.pl b/mc1322x-load.pl index f454736bd..21bdd28cb 100755 --- a/mc1322x-load.pl +++ b/mc1322x-load.pl @@ -1,8 +1,9 @@ #!/usr/bin/perl -w -use Device::SerialPort 0.05; +use Device::SerialPort; use Term::ReadKey; use Getopt::Long; +use Time::HiRes qw(usleep); use strict; @@ -40,21 +41,25 @@ $ob->parity('none'); $ob->databits(8); $ob->stopbits(1); $ob->handshake("rts"); +$ob->read_const_time(1000); # 1 second per unfulfilled "read" call +<<<<<<< HEAD:mc1322x-load.pl my $s = 0; SEND: do { my $c; - + my $count; + my $ret = ''; + if($s == 1) { print "performing secondary send\n"; } $ob->write(pack('C','0')); my $ret = ''; my $test; - + if($s == 1) { $test = 'ready'; } else { @@ -62,11 +67,15 @@ my $s = 0; } until($ret eq $test) { - $c = $ob->input; + ($count,$c) = $ob->read(1); + if ($count == 0) { + print '.'; + $ob->write(pack('C','0')); + next; + } $ret .= $c; } - print $ret . "\n"; - + print $ret . "\n"; if (-e $filename) { @@ -81,9 +90,8 @@ my $s = 0; my $i = 1; while(read(FILE, $c, 1)) { print unpack('H',$c) . unpack('h',$c) if $verbose; - print "\n" if ($verbose && ($i%4==0)); $i++; - select undef, undef, undef, 0.001; + usleep(50); # this is as fast is it can go... $ob->write($c); } } @@ -94,6 +102,10 @@ my $s = 0; print "done.\n"; +while(1) { + print $ob->input; +} + $ob -> close or die "Close failed: $!\n"; ReadMode 0; undef $ob; # closes port AND frees memory in perl