Menu

Read from serial (synchronous)

devnull
2024-02-19
2024-02-22
  • devnull

    devnull - 2024-02-19

    Hi, i've tried to simply init a serial communication (Windows 10), send some text and expect and answer. But it always give me 0 bytes in return:

        var serialPort = scriptInf.createSerialPort();
        serialPort.setPortName("COM10");
        serialPort.setBaudRate(115200);
        serialPort.setDataBits(8);
        serialPort.setParity("None");
        serialPort.setStopBits("1");
        serialPort.setFlowControl("None");
        serialPort.setDTR(true);
        serialPort.setRTS(true);
        serialPort.readAll(); // flush RX-Buffer
    
        serialPort.writeString("ATZ\r");
        scriptThread.sleep(2000);
        UI_console.append(serialPort.readAll());
    

    When i add an async reader, i get the desired answer there:

    function serialBytesReceived()
    {
        UI_console.append(serialPort.readAll());
    }
    serialPort.readyReadSignal.connect(serialBytesReceived);
    

    So, isn't it possible to run the serial object without an async reader?

     
  • Stefan Zieker

    Stefan Zieker - 2024-02-20

    Hi,

    I never tried it without an async reader. But yes, it seems that is it not possible without an asymc reader.

     
  • Anonymous

    Anonymous - 2024-02-22

    What i did not get was, regardless how long i wait, that readAll() does not return anything. But if that was never planned to work, it's useless to think about and i'll do it with an asnyc function.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.