• Re: Reading the serial port line by line

    From Gunnar Schmidt@21:1/5 to All on Sun Jan 22 14:34:19 2023
    Hello,

    thank you all for this input. I m struggling, that my buffer is getting very large. I try to figure out, how to add to each line in the buffer a timestamp.

    Is it possible to find out, when the message is send by the device via serial communication.

    I used your code:

    function buf = readserialline(h)
    tmpbuf = emptystr();
    while tmpbuf == emptystr()
    //TCL_EvalStr("gets " + h + " ttybuf"); Todo: Had some issues, if queue of serialstatus == 75
    //https://stackoverflow.com/questions/54935990/read-the-latest-line-of-a-serial-port
    // Todo: read last line of buffer and add timestamp
    TCL_EvalStr("binary scan [gets "+h+"] cu* ttybuf");
    //tmpbuf = TCL_GetVar("ttybuf");
    tmpbuf = ascii(evstr(TCL_GetVar("ttybuf")));
    end
    buf = tmpbuf;

    endfunction

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gunnar Schmidt@21:1/5 to All on Thu Feb 16 10:38:54 2023
    How can you generate a time stamp whenever the serial port API generates an event to indicate that data was received as well as after newline and/or carriage return characters?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Gunnar Schmidt on Thu Feb 16 19:16:45 2023
    Gunnar Schmidt <[email protected]> wrote:
    How can you generate a time stamp whenever the serial port API
    generates an event to indicate that data was received

    In your event handler, use the [clock] command to generate a timestamp
    in your desired format.

    as well as after newline and/or carriage return characters?

    For that you will have to monitor the incoming data for
    newline/carriage return characters and when you find one, use [clock]
    to generate a timestamp.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)