Serial Communications Problem
Posted: Fri Apr 25, 2008 7:27 pm
I have a serial receive procedure, patterned after one I use under Windows, that runs in a background thread. It works after a fashion, but only updates the editor gadget when the mouse moves. The Windows procedure does not have this issue but updates as each line is received. All incoming lines terminate with #CRLF$.
It's called as soon as the main window opens (The serial port is intialized and opened earlier).
How can I persuade it to update as each line is received?
Code: Select all
Procedure ComEventRcv() ;serial input thread
Protected ComRcv.s,*buf
*buf=AllocateMemory(1) ;freed automatically at program end
Repeat
If fd>-1
If read_(fd,*buf,1)>0
If PeekC(*buf)=10
If Trim(ComRcv)<>""
ComRcv=RemoveString(ComRcv,#CR$)
AddGadgetItem(#EDT_IO_MAIN,-1,ComRcv)
ScrollToEnd(#EDT_IO_MAIN)
ComRcv=""
EndIf
Else
ComRcv+PeekS(*buf,1)
EndIf
EndIf
EndIf
ForEver
EndProcedureCode: Select all
If OpenWindowMain()
If fd>-1:ComThread=CreateThread(@ComEventRcv(),0):EndIf
...