From: Atul P. <atu...@ya...> - 2010-05-24 15:54:36
|
Folks, I have the following script to programme the BIOS on an embedded system. I login using a password, select a menu option (by sending $opt), give a description (by sending $description) then finally send the binary file. I'm currently using "cat filename >> /dev/ttyUSB0" in a seperate terminal window, but I want to do this within the script itself. Whats the correct way of sending a binary file using Expect ? thanks for any suggesstions! a. $k = new Expect(); $k->raw_pty(1); $k->spwan(kermit -l $dev_port -q -c -b 115200) $k->send("\n"); $k->expect(45, ['-re', qr/\>/ => sub { $k->send("password\n"); $k->exp_continue; } ], ['-re', qr/\* MyBIOS/ => sub { $k->send("$opt"); $k->exp_continue(); } ], ['-re', qr/Enter FW description:/ => sub { my $fw_file = $options{$opt}->[1]; my $description = $options{$opt}->[0]; print "\n=======================================================\n"; print "sending description $description\n"; $k->send("$description\n"); print "sending binary to $dev_port \n"; print "cat $fw_file >> $dev_port\n"; # system("cat $fw_file >> $dev_port"); # `cat $fw_file >> $dev_port`; print `cat $fw_file > $dev_port`; # `cat $fw_file >> $dev_port`; $k->expect(165, '-re', qr/Downloading/ => sub { print "controller accepted start of binary\n"; $k->expect(150, [ '-re', qr/Erase sector/ => sub { print "... ok\n"; $k->exp_continue(); } ], [ '-re', qr/flashWriteChunk.*complete/ => sub { print "Flash write complete\n"; } ] ); }); print "=======================================================\n"; } ], ); |