[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Serial Port access

Some time ago we got two NT boxes talking to one another via the com port
under IDL. 

This is the only code I can find (below) for writing to the com port. It
tries to open a file named "COM1:". I've just tried it sitting here
(nothing connected to my com port and a different machine to that on
which it worked) and it fails - IDL complains it cannot find a file named

That said this certainly worked at some point under NT! It may be you
have to set up your COM ports under NT so they are recognised as part of
the file system - I'm not sure. I can't remember what we had to do to get
it working, but we certainly managed to do it. 

Drop me a line if you need more help (something might jog my memory).
Also I'll check on our machines in the lab next time I'm down there -
there may be some clues! 

Good luck!


pro gcs_serialout, text, port

text = strtrim(text, 2)	;Convert first param to string type.

if n_params(0) lt 2 then begin	;If no port given, choose COM1:.
	xport = 'COM1:'
endif else begin		;Otherwise, choose port based on input.
	port = fix(port)
	if (port gt 2) or (port lt 1) then begin
		print, 'PORT must be 1 or 2.'
	xport = 'COM' + strtrim(port, 2) +':'

get_lun, u
openw, u, xport
;print, fstat(u)	;For debug only.
writeu, u, text		;Raw text output.
;writeu, u, text + string(byte([13,10]))

flush, u
;print, fstat(u)	;For debug only.

close, u
free_lun, u


richt@sbrc.umanitoba.ca (Richard Tyc) wrote in

>Anybody have any libraries, DLL's, , CALL_EXTERNAL code examples which
>provides an IDL application with the ability to read the serial port on
>Windows NT machines (Intel).  I am trying to get my IDL app to link to a
>fiberoptic thermometer via RS232 to read data continuously.
>Just don't want to reinvent the wheel. Not to mention, I have never
>written code to access the serial port on a NT box.
>BTW, I am referring to the standard COM1/COM2 port on the motherboard
>not external PCI/ISA interface cards.