
detecting non-working serial interface
On Fri, 02 Jul 1999 13:09:48 -0400, Joe Turner
Quote:
>Can anyone give me some guidance on how to do this: I have a 3 wire
>serial port connection that I'm using to communicate with an external
>device. When everything is working correctly, the external device will
>reply to a command I send through the serial interface (using OPEN
>"COM1:...,RS,CS,DS,CD" as #1 then PRINT #1, cmdstring and INPUT #1,
>ans$). This is all fine as long as I use the correct com port and the
>external device is powered. What I need is some way to detect if the
>port doesn't respond in a certain time, so I can then try changing to
>COM2. If COM2 doesn't respond either then I want to display a message.
>What happens now is that I send my cmdstring and the program hangs,
>waiting for a response that never comes. I would think that there must
>be a simple solution for this. Any ideas?
Try polling the Com port rather than just doing the INPUT#1.
Check the on-line help under LOC(n). This will tell you if there is
anything in the Rx buffer. You can loop on this test until you choose
to abandon the exercise and try the next port (hic). If it comes up
Quote:
>0 then you know there is a response, although I usually test for >1
to avoid surplus delimiters left after previous tests, or startup
transients from the peripheral.
If you need an example plse email me and I'll dig out a proggie i
wrote a few years back, in Qbasic 1.1.
HTH
Peter
PERTH - WESTERN AUSTRALIA
Remove the NOWHERE from reply address