PilotinControl:
I don't know anything about Win32::Serial, nor how it may interact with Windows 10. I'd suggest sprinkling a few print statements in locations to see what the code is doing.
The first one I'd suggest is to put a print statement immediately inside the while loop:
my $are_we_done_yet = 0;
while (!$are_we_done_yet) {
print "loop\n";
# Check for console activity
my $con_key = ReadKey(-1);
This way, we can see if the loop is operating correctly. However, it'll quickly fill your screen up. So if that's working OK, you'll want to take it out again after checking.
Next, we can add a couple print statements to is_serial_data_ready, to see what it's doing:
sub is_serial_data_ready {
print "is_serial_data_ready: enter\n";
# Non-blocking read: otherwise, we'll hang up here!
my $c = $port->input;
print "is_serial_data_ready: got <$c>\n";
# Process the incoming characters
for my $char (split '', $c) {
print "is_serial_data_ready: char '$char'\n";
if ($char eq "\n" or $char eq "\r") {
print "is_serial_data_ready: end-of-line found\n";
# End of line found, add current line to buffer
# (unless it's empty)
if ($serial_input ne '') {
push @serial_data, $serial_input;
# start a new blank line
$serial_input = "";
}
}
else {
# Just a normal character, add to the input
$serial_input .= $char;
}
}
# Returns true if there are any completed lines to handle
print "is_serial_data_ready: ", join(" // ", @serial_data), ".\n";
return scalar @serial_data;
}
This way, you can see if it's actually entering the is_serial_data_ready function. If so, you can see if there's any time lag on the input statement, and whether anything ever shows up in $c. It'll also show if the characters are building up into statements or not.
The idea is to put some print statements in various locations to verify that the program is operating as you expect it to. Normally, I'd suggest using the perl debugger, but this trick should help you get started along finding the problem.
Since you say it operates differently between Windows 10 and Windows 7, I'd try to first concentrate on finding out just what the difference is. From there, it may give a clue on what to research to find the problem.
...roboticus
When your only tool is a hammer, all problems look like your thumb. |