-->
Page 1 of 1

UART - time between two received bytes

PostPosted: Fri Dec 18, 2015 8:39 am
by MrSupe
Is it possible to get time between two received bytes?

I am using Arduino 1.6.5 with 2.0.0 esp8266 library.

Re: UART - time between two received bytes

PostPosted: Fri Dec 18, 2015 9:43 am
by xtal
Why would you want to know this?....to me it all relative
1> Baud rate .. You know the bit time, so you can approx the time to Rx 2 bytes
but that doesn't give the time between 2 bytes... maybe 1 stop bit time at the minimum?
2> on Rx side hardware overhead/delays etc and software overhead [affected by other tasks ie access to data]
3> on Tx side hardware overhead/delays etc and software overhead & Tx method buffered / byte,byte [affected by other tasks ie ints/callbacks etc]

Re: UART - time between two received bytes

PostPosted: Fri Dec 18, 2015 9:56 am
by MrSupe
to program Modbus RTU I need it.
Time 3.5xcharacter between received characters means end of message...
In case of 19200 baud it is 18.2ms.
SO, if time between two received characters is less then 18.2 ms, message from master is still transmitting. When I start my Modbus RTU slave I MUST wait for end of message to synchronise myself to listen messages...

I hve startet to modify HadwareSerial.cpp...
Do you have better idea?

Re: UART - time between two received bytes

PostPosted: Fri Dec 18, 2015 5:07 pm
by xtal
I know very little about Arduino stuff or C, modifying serial could be a viable solution,
I would assume you would start a timer when \n\r received , then query timer as needed ?

What is the modbus, seems like I've heard this term before ?