I am writing a perl script that boots a linux image and needs to detect if the image reached the login prompt. i am using the Device::serial module to communicate with the development board. i am running into problems detecting the login string. i think it might be related to the large amount of prints that occur during a linux boot. the code below tries to capture the prompt. strange enought it only works when i add the unnecessaty "read" command
# Wait for login prompt
$port->are_match("login:");
$gotit = "";
$timeout = 60;
until (($gotit ne "") or ($timeout eq 0))
{
$gotit = $port->lookfor; # poll until data ready
die "Aborted without match\n" unless (defined $gotit);
$read = $port->read(1000000);
$port->lookclear;
sleep(1);
$timeout--;
}
is "lookfor" good for the linux boot scenario at all? why does the "read" make this code work ?
thanks everyone
The CPAN doc page says to do this:
my $gotit = "";
until ("" ne $gotit) {
$gotit = $PortObj->lookfor; # poll until data ready
die "Aborted without match\n" unless (defined $gotit);
sleep 1; # polling sample time
}
There is no call to $port->lookClear
in their loop. I suspect this is contributing to your issue. Also be careful with that timeout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.