[comp.os.msdos.programmer] Testing serial port?

catfood@NCoast.ORG (Mark W. Schumann) (05/07/91)

I think this must be a FAQ, but here goes.  Is there a generalized
way within an application to determine whether there is actually
a device attached to a COM port?  I know you can try to initialize
the port and check the error code, but that has a very long timeout
period.  (Like 15 minutes on my Gateway.)  Does anybody know a
faster way?

Thanks.

-- 
============================================================
Mark W. Schumann  3111 Mapledale Avenue, Cleveland 44109 USA
Domain: catfood@ncoast.org
UUCP:   ...!mailrus!usenet.ins.cwru.edu!ncoast!catfood

jrd@cc.usu.edu (05/10/91)

In article <1991May7.030539.28611@NCoast.ORG>, catfood@NCoast.ORG (Mark W. Schumann) writes:
> I think this must be a FAQ, but here goes.  Is there a generalized
> way within an application to determine whether there is actually
> a device attached to a COM port?  I know you can try to initialize
> the port and check the error code, but that has a very long timeout
> period.  (Like 15 minutes on my Gateway.)  Does anybody know a
> faster way?
> 
> Thanks.
> 
> -- 
> ============================================================
> Mark W. Schumann  3111 Mapledale Avenue, Cleveland 44109 USA
> Domain: catfood@ncoast.org
> UUCP:   ...!mailrus!usenet.ins.cwru.edu!ncoast!catfood
-----------------
	Yup. MS-DOS Kermit, for example, knows about your serial port
hardware within say about 20-30 microseconds. One needs to do some
readonly tests (input's) to validate the signature of a standard UART
chip without disturbing a thing. I would not dream of initializing the
port to discover it's presence, and Kermit will balk about doing so 
if the readonly tests fail.
	Any testing via the Bios is doomed to fail on networks.
	But you did ask a more specific question about a device being
connected to the port. The only way that information will be available
is if the device asserts one of the many RS323C status inputs. There
is plenty of room for guessing here. The proper one is Data Set Ready,
and MSK will show that for you (see below to find out how).
	I might comment that if the application is using the real serial
port Bios for i/o then there will be long timeouts when a device is 
not plugged in (no DSR and no CTS), and probably less than ideal 
performance.
	I could suggest that you have a look at my serial port code in
file MSXIBM.ASM, part of the Kermit source code stored on the Columbia
Univ archives. It's assembler, but it is very heavily commented.
	Joe D.