I need to read info at SER2 and sent it to the MDM interface when the MDM is conected to my application(server) in TCP mode.
So when the transparent connection is stablished I run this:
(CONFIG._SER_TIMEOUT = 1Seg)
def GetSerial2():read = ”read = SER2.read()if (not read): return FALSE
timeout = MOD.secCounter() + CONFIG._SER_TIMEOUT
while (timeout > MOD.secCounter()):aux = SER2.read()read = read + auxif (aux): timeout = MOD.secCounter() + CONFIG._SER_TIMEOUT#if (not aux): return read return read
What do this function, get me -1 when the serial is empty or a data stream(string) reading it with a 1 second timeout. (this timer reset each time a char is get i meen it start to count only when any char is found)
This works great at 9600 & 19200 Bps.
But now I need to run it in 2400B and with a longer stream (aprox 1200chars).
I don’t know other way to do this. I test several other codes and I get partial parts of the stream of even worst some incomplete parts.
The idea is read all the data that is in the hardware buffer or data incoming, waiting one seconds to dispatch to the server the content of this software buffer.
I try testing user .read() at the main loop at others tips& tricks that I found.
Is not a note a example code to build a virtual serial application that works in any way at any speed?. IT’s a nice module but is a headache about USART management and programming.
Maybe is a baudrate issue, is the stream received 100% reliable in a terminal on a computer?
I would also try with readbyte in the main loop, accumulating in a buffer and have a test with MOD.secCounter when to send data.
Hit enter to search or ESC to close
Knowledge Base & Download Zone