Q: Why might a Web Serial API app work in Windows and Linux but not macOS? I'm trying to develop an web-page which can talk to an STM Nucleo board attached to a USB port on the computer.  The Nucleo board communicates using a serial port connection over USB, and I can happily talk to it using a serial terminal program (CoolTerm in my case).  The browser app works fine in Windows and Linux, but not in macOS.  macOS reports that the serial connection is available, appears to connect and open the port correctly, and starts working, but after sending a few dozen bytes the serial port in the mac appears to freeze, and it doesn't transmit anything more to the Nucleo board.
The Web serial app reports all the flags (CTS, DCD, DSR and RI) to be false, both before and after the transmitter stops sending data, but the port is opened with flowControl set to the default "none").
Does anyone have any idea why this might be happening and how to get the mac serial port to transmit more than a few dozen bytes?
(I've observed exactly the same behaviour trying to use python and pyserial: it works in Windows and Linux, but doesn't work in macOS, so I am assuming this is something to do with the macOS serial ports.)
The code to open the port and send the data looks like this:
async function _serialNewClickConnect() {

    // Select the serial port.  Note: can add filters here, see web.dev/serial
    _serialPort = await navigator.serial.requestPort();

    // Open the serial port.
    await _serialPort.open({ baudRate: 115200, bufferSize: 64 });

    // Set up to allow data to be written:
    _serialWriter = _serialPort.writable.getWriter();

    // Listen to data coming from the serial device.
    while (_serialPort.readable) {

        _serialReader = _serialPort.readable.getReader();
        try {
            while (true) {
                const { value, done } = await _serialReader.read();
                if (done) {
                    // To allow the serial port to be closed later:
                    _serialReader.releaseLock();
                    break;
                }
                if (value) {
                    // Something has arrived.  This will be stored in value as a uint8 array.
                    for (let x = 0; x < value.byteLength; x++) {
                        _serialRxData.push(value[x]);
                    }
                }
            }
        } catch (error) {
            // TODO: Handle non-fatal read error.
        }
    }
}

async function sendString(string) {
    // Sends a string over the serial port.
    const data = new TextEncoder().encode(string);
    await _serialWriter.write(data);
}


A: With many thanks to a colleague (who doesn't have a Stack Overflow account to be rewarded for his work), I have found a (partial) answer: "because there was a bug in the firmware of the Nucleo board".
Updating the firmware on the Nucleo board to the latest revision fixed the problem.  Quite why the old firmware worked with Windows, Linux and with Coolterm on macOS, but not with a python script or Web Serial API on macOS is something that I will probably never know.  But I would be interested to find out the whole story.  If anyone ever learns more, please do post a reply / comment.
