Unsolved how to use syncronous serial port for io and op?
-
I am trying to input data from serial port and reply in 30ms only. I need to use a syncronous method to write out the data. I set up the buffer to 1 byte, is it correct?
but when i receive the data and write it out, it seems it is not in the given time frame.Is there a special setting in QSerial ? i based my app on the terminal application ..
-
@sherifomran said in how to use syncronous serial port for io and op?:
I need to use a syncronous method to write out the data
You don't have to. You can use a QTimer with 30ms timeout and in the slot write...
-
may be you misunderstood me, i am receiving a data (live) online and i must reply as fast as i receive the data. But when i write, i see it is not fast enough.
-
@sherifomran
if you write to your serial port in the slot connected to readyRead, than that is as fast as it possibly can be.Can you show your read and write functions?
-
@sherifomran Such hard requirements are usually hard to satisfy on a non real-time operating system.
Even if you handle the incoming bytes as fast as possible, the operating system may still delay the write. Sometimes it helps to
flush()
the output buffer after write.And one tip: use a "real" serial port, no USB-serial converter. These usually have further delay times, as USB is polled, not interrupt driven.
I set up the buffer to 1 byte, is it correct?
That heavily depends on the protocol you want to transmit.
Regards