Commit 34625949 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

fiji_download.pl: Fix baudrate selection on Windows

parent 3cd4a51e
......@@ -3,13 +3,14 @@
use strict;
use warnings;
use Switch;
use AnySerialPort;
use Log::Log4perl qw(get_logger);
use Scalar::Util "looks_like_number";
use Config::Simple;
use Time::HiRes "usleep";
use AnySerialPort;
use Digest::CRC "crc";
use Data::Dumper;
#** Initiates a serial port
#
......@@ -34,9 +35,24 @@ sub init_uart {
return undef;
}
if ($port->can("are_baudrate") && $port->are_baudrate !~ $baudrate) {
$logger->error("Invalid baud rate ($baudrate). Possible choices are $port->are_baudrate");
return undef;
if ($port->can("are_baudrate")) {
my @rates = $port->are_baudrate;
if (grep(/^$baudrate$/, @rates) == 0) {
$logger->error("Invalid baud rate ($baudrate). Possible choices are:",
{
filter => sub {
my $opts = shift;
my $ret = "";
foreach my $o (@$opts) {
$ret .= sprintf("\n%d", $o);
}
return $ret;
},
value => \@rates
}
);
return undef;
}
}
$port->databits(8);
$port->baudrate($baudrate);
......@@ -52,7 +68,6 @@ sub init_uart {
}
$logger->info("Using serial port $portname with baud rate $baudrate.");
return $port;
}
## @function rcv_bitstream ($port, $todo, $timeout, @$out_ref)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment