in reply to SerialPort issues under Windows 10

Based on my testing, the issue is that you need to do $port->write_settings or die "write_settings: $^E"; after setting the parameters.

The next issue I had was that Win32::SerialPort's ->read appears to be behaving non-blocking (I unfortunately don't have enough time to investigate further at the moment see reply). See its documentation for a few blocking methods you can try, or you can use the tied filehandle interface to be able to use Perl's readline and read - if I wanted blocking I/O, the latter is what I would do as I find the filehandle interface more familiar.

Note you should Use strict and warnings!

Replies are listed 'Best First'.
Re^2: SerialPort issues under Windows 10
by haukex (Archbishop) on Apr 16, 2021 at 12:24 UTC
    The next issue I had was that Win32::SerialPort's ->read appears to be behaving non-blocking

    It's actually just timing out immediately - adding the minimum of e.g. $port->read_const_time(1000); sets the read timeout to 1s.

Re^2: SerialPort issues under Windows 10
by clinicalAD (Initiate) on Apr 20, 2021 at 13:19 UTC
    Aha! write_settings was the key step I think - I naively thought that was just to write settings to a file, rather than initiate the settings described!

    Many thanks all.

    Will try and remember strict and warnings... Have had a bug in the last several years of occasional scripting where that might have been useful, in retrospect. Old habits etc...