Here is a simple program that tests the availabilty of a particular COM port once per second:
Code:
timer% = 100
t% = 0
REPEAT
WAIT 1
timer% += 1
IF timer% > 100 THEN
t% += 1
PRINT " TIME = " + STR$(t%)
timer% = 0
port% = OPENUP("COM4: 115200,N,8,1")
PRINT "port%= " + STR$(port%)
CLOSE#0
ENDIF
UNTIL FALSE
I have tested this by plugging/unplugging a USB-to-serial adapter into/from the COM4 port on a laptop, running Windows 7/32.
Logically it works OK, but when I plug the adapter into the PC, there is a very long delay (around 4-5 seconds) before the port open state is recognized -- the timer counter update freezes during this time. When I remove the adapter the state is recognized almost immediately.
Is there a way to reduce the OPENUP delay when the port becomes available?
--
Ian