Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

serial port status moitoring


rawon87 Dec 19, 2019 03:21 AM

hi, i want to monitor status of com port and base on that condition, if time after last port activity >5 mins, then input = ""

i tried this code below but i can't find any option on prolonging the status monitoring >what seems to be 40 sec

Public input As String * 50

Public size

Public status

'Main ProgramBeginProgSerialOpen(com1,9600,0,0,10000)

Scan (1,Sec,0,0)   

SerialInRecord(com1,input,0,5,0,size,00)

status = ComPortIsActive (Com1)

If status = false Then 

input = "" 

EndIf



NextScan

EndProg

anyone have an idea?

thanks beforehand


rawon87 Dec 19, 2019 05:57 AM

sorry, i forgot to mention, 

i did put a manual timer and it works fine, but i ended up with 3 if statement.

this is a test and i would like to implement this in an already large and heavy program, so i would like to make this function as simple as possible

Public input As String * 50

Public size

Public status

Public time

'Main Program

BeginProg

SerialOpen(com1,9600,0,0,10000)
Scan (1,Sec,0,0)

SerialInRecord(com1,input,0,5,0,size,00)
status=ComPortIsActive (Com1)

If status = false Then  

time=time+1 

EndIf

If status = true Then 

time=0 

EndIf

If status=false AND time >  180 Then 

input=""  time=0  EndIf

NextScan

EndProg

Log in or register to post/reply in the forum.