Menu

Read unknown buffer serial length

Anonymous
2022-09-16
2022-09-19
  • Anonymous

    Anonymous - 2022-09-16

    I need to readout all the char from the RX buffer after a CR has been sent. So send CR, wait for 1sec, dump the char. I can see how to do steps 1 and 3 but how do I set a 1 sec delay to wait for the buffer to fill up?

     
  • Stefan Zieker

    Stefan Zieker - 2022-09-16

    You can use sleep or a timer (depends on your script).

    Sleep:

    scriptThread.sleepFromScript(1000);//Sleep for 1s
    

    Timer:

    function timerSlot()
    {
        timer.stop();
    
        //Do something.
    }
    var timer = scriptThread.createTimer();
    timer.timeoutSignal.connect(timerSlot);
    timer.start(1000);//Start the timer with a 1s interval
    
     
  • Anonymous

    Anonymous - 2022-09-19

    Hi Stefan,

    Can you give me an example of using the single shot timer. I can't get it to work for love or money.

    Thanks in advance.

     
  • Anonymous

    Anonymous - 2022-09-19

    Hi Stefan,

    I must be missing something fundamental. I have two functions One starts a timeout timer(3 sec) every 10 seconds to send some data. The second function is called when some data is received. To process the data and stop the timeout timer. It would appear the stop timer command in the second function does not stop the time started in the first function. The timer is defined in the main body of the script.

    What am I missing?

     
    • Anonymous

      Anonymous - 2022-09-19

      All good fix my own problem.

       
  • Stefan Zieker

    Stefan Zieker - 2022-09-19

    :-)

     

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.