in reply to Re^3: Win32 Serial Under Windows 7
in thread Win32 Serial Under Windows 7

I added each print statement as described....the only print that comes through is the Loop.....nothing ever comes from the is_serial_data_ready print statements. I find that very weird....as stated before when I use Putty and connect to the Arduino and push the button the feedback is printed to the screen. Each computer has the same version of perl and same version of Win32::SerialPort. The laptop running Vista is fine, the laptop running Windows 7 is fine....the Tablet running Windows 10...with an attached keyboard works fine sending...doesn't receive.

Replies are listed 'Best First'.
Re^5: Win32 Serial Under Windows 7
by roboticus (Chancellor) on Apr 04, 2018 at 16:22 UTC

    PilotinControl:

    OK, then if you're never seeing the is_serial_data_ready print statements, then I'm assuming that you see only one "loop" statement printed on the screen until you press a key. If that's the case, then your "my $con_key = ReadKey(-1);" is blocking. You'll need to dig deeper into the use of Win32::Console and/or Term::ReadKey stuff to find out how to do a non-blocking read.

    If you get a continuous stream of "loop", then the $con_key value is defined even when there's no keypress ready. This is causing the first branch of the if statement to fire. You'd need to change the test to let the elsif condition activate and get into the is_serial_data_ready part of the code.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      Correct... I only see one LOOP when a key is pressed etc. I still find this strange on windows 10 as windows xp, vista, and 7 all work fine makes you wonder what "broke". I will keep working and report back.
      so I've narrowed it down to this:
      user Term::ReadKey; ReadMode 4; my $key; while (!defined ($key = ReadKey(-1))) { print "Test\n"; sleep(5); } ReadMode 0;
      This does not work on Windows 10 using Strawberry Perl or ActiveState Perl....anyone else have this issue?

        "'Not I,' said the sheep." I get impatient, so used 1s sleep, not 5s. But it works how I believe you intend for me using Strawberry v5.26.0.

        use warnings; use strict; use Term::ReadKey; ReadMode 4; my $key; while( !defined ($key = ReadKey(-1)) ) { print qq(Test\n); sleep(1); } print qq(Exit With Key $key\n); __END__ From cmd.exe prompt: C:\usr\local\share\PassThru\perl\perlmonks>perl 1212444.pl Test Test Exit With Key a C:\usr\local\share\PassThru\perl\perlmonks>perl -v This is perl 5, version 26, subversion 0 (v5.26.0) built for MSWin32-x +64-multi-thread

        relevant update: windows 10, 1709 (os build 16299.248)

        irrelevant update: whoops, there was no sheep, just a pig, cat, and rat... and it's actually "and the cat said, 'not I'". I guess it's been a few years since my kids last requested that story.