timeout
Hi all!
I am looking forward for some immediate help in realm of the timeout function using propeller.
In case of FullDuplexSerial.spin we have rxtime(ms) PUB function that takes serial in the char value if not within time 'ms' it will step forward and execute next instruction.
I want to implement the similar case for ParallaxSerialTerminal.spin case for the PUB function DecIn.
The code for the FullDuplexSerial.spin is
PUB rxtime(ms) : rxbyte | t
'' Wait ms milliseconds for a byte to be received
'' returns -1 if no byte received, $00..$FF if byte
t := cnt
repeat until (rxbyte := rxcheck) => 0 or (cnt - t) / (clkfreq / 1000) > ms
How should I implement the same for ParallaxSerialTerminal.spin DecIn case? or how to modify the case for former for Decimal entries instead of char?
Looking forward for your help.
Thanks
Jay
I am looking forward for some immediate help in realm of the timeout function using propeller.
In case of FullDuplexSerial.spin we have rxtime(ms) PUB function that takes serial in the char value if not within time 'ms' it will step forward and execute next instruction.
I want to implement the similar case for ParallaxSerialTerminal.spin case for the PUB function DecIn.
The code for the FullDuplexSerial.spin is
PUB rxtime(ms) : rxbyte | t
'' Wait ms milliseconds for a byte to be received
'' returns -1 if no byte received, $00..$FF if byte
t := cnt
repeat until (rxbyte := rxcheck) => 0 or (cnt - t) / (clkfreq / 1000) > ms
How should I implement the same for ParallaxSerialTerminal.spin DecIn case? or how to modify the case for former for Decimal entries instead of char?
Looking forward for your help.
Thanks
Jay

Comments
If you need a 4 byte LONG value then create a loop that reads, validates, and stores the 4 bytes in memory. Use the rxbyte method of the Full-Duplex Serial object to read the bytes without blocking.
Since ParallaxSerialTerminal has an rxcheck routine, you can just add the same rxtime routine routine to it that you showed. DecIn uses the routine StrInMax which uses CharIn which uses rxcheck. You could substitute a call to rxtime for the call to CharIn to come up with a StrInMaxTime routine, then you'd have DecInTime call StrInMaxTime.
PUB StrInMaxTime(stringptr, maxcount, mstime) | temp {{Receive a string of characters (either carriage return terminated or maxcount in length) and stores it (zero terminated) starting at stringptr. Waits until either full string received or maxcount characters received. Times out in mstime milliseconds. Returns true if a timeout occurred, false otherwise. Parameters: stringptr - pointer to memory in which to store received string characters. Memory reserved must be large enough for all string characters plus a zero terminator (maxcount + 1). maxcount - maximum length of string to receive, or -1 for unlimited. mstime - timeout in milliseconds (for each received character)}} repeat while (maxcount--) 'While maxcount not reached if (temp := rxtime(mstime)) < 0 ' Stop on a timeout byte[stringptr]~ ' Zero terminate string return true if (byte[stringptr++] := temp) == NL 'Get chars until NL quit byte[stringptr+(byte[stringptr-1] == NL)]~ 'Zero terminate string; overwrite NL or append 0 charmeanwhile thanks for the support, will take care in future.
Thanks
Jay