There are no obvious clues in the documentation.

Code: Select all
If IsSerialPort(ComID):ComThread=CreateThread(@ComEventRcv(),0):EndIf
Code: Select all
Procedure ComEventRcv(*nada) ;serial input thread
Protected ComRcv.s,char.s=" ",buffer.b,n
Repeat
If IsSerialPort(ComID)
While AvailableSerialPortInput(ComID)
n=ReadSerialPortData(ComID,@buffer,1)
Select buffer ;Asc(char)
Case 10,13,32 To 126:ComRcv+Chr(buffer)
EndSelect
If Right(ComRcv,2)=#CRLF$
If CmdMode
cmd=Left(ComRcv,Len(ComRcv)-2)
Else
UpdateIO(Left(ComRcv,Len(ComRcv)-2))
EndIf
ComRcv=""
EndIf
Wend
EndIf
ForEver
EndProcedure
EDIT:kh1234567890 wrote:Thanks for the replies.
So when the serial port 'times out' after an interval set by SerialPortTimeouts it just closes and disappears ?
I was hoping for something more useful - I suppose it is back to the kludge of using the API timer to periodically check if any characters have appeared in the serial buffer.
In this application I have a simple three wire serial connection with no handshaking lines, connected to an unpredictable data acquisition front end sending data whenever it feels like it.
It is all coming back, why I gave up on PB about four years ago
kh1234567890 (because people kept using kh1, kh2 etc.)