serial rxtime(ms) example wanted
kkibbe
Posts: 11
I'm having trouble getting my serial port code working. All is well rx'ing data but I would like the code to timeout after a second or so and give up receiving data.... I'm using the FullDuplexSerialPlus object.
I have what looks like this below but I would love to see an example from someone using the rxtime(ms) format.
Thanks,
Kevin
I have what looks like this below but I would love to see an example from someone using the rxtime(ms) format.
. repeat . . char := uart.rxtime(1000) . if char == -1 . quit . . otherwise do something else
Thanks,
Kevin
Comments
Kevin
Joms' program doesn't really time out as you noticed. rxtime() just returns an illegal character (-1) when a timeout occurs. What you do with it depends on what you want your program to do on a time out. One possibility is to do an abort if rxtime() returns a -1 and catch that higher up the call path where it would make sense. Anything like that would require changes to the lower level code, but that's normally the case when you want to improve the error handling of a library. You have to design in the error detection and recovery all up and down the call path (A calls B calls C ....).
In the little code fragment I posted at the top I have the command "quit" if the character returned is a -1 but somehow it isn't exiting the repeat loop. Can you see a reason why I won't get the -1. I know my serial port becomes inactive but I'm thinking if my serial port is being held high or perhaps low the code that looks for a time out condition isn't being reached. The serial port is a 3 wire rx/tx/gnd connection.
If I send to the prop via the serial port the letter "K" and set the repeat loop to exit on the letter "K" then everything is fine, the loop exits.
Kevin
please ATTACH your WHOLE program to a posting by using the ARCHIVE-function of the Propeller-Tool.
The solution will be found 3 times faster if you do that
best regards
Stefan
Thanks,
Kevin
Kevin