Serial Port [message #14133] |
Thu, 28 January 1999 00:00  |
Bernard Puc
Messages: 65 Registered: January 1998
|
Member |
|
|
Is there anybody who has written any IDL code to access the serial
port on a PC or UNIX platform? I'd be interested in seeing
implementations.
Thanks.
--
Bernard Puc AETC, INC.
bpuc@va.aetc.com 1225 Jefferson Davis Highway #800
(703) 413-0500 Arlington, VA 22202
|
|
|
Re: Serial Port [message #14226 is a reply to message #14133] |
Fri, 29 January 1999 00:00   |
ashmall
Messages: 14 Registered: October 1998
|
Junior Member |
|
|
Apologies for following up to my article but...
If you're not reading a fixed amount of bytes from the port, to terminate the
transmission I think you have to send byte value 4, something like:
get_lun, u
openw, u, "COM1:"
text = "Hello Mum"
writeu, u, text + string(4b)
close, u
free_lun, u
Justin
In article <78s43i$pec$1@jura.cc.ic.ac.uk>, ashmall@my-dejanews.com (Justin
Ashmall) wrote:
> We've done this under NT4. We just open a file as normal with OPENR or OPENW
> (for reading or writing to the port), but in the place of the file name use
> COM1: or COM2: (not forgetting the colons). The only problem is if you try to
> read from the port and it gets no data - it either hangs or has a very long
> time out.
> If you're having trouble email me at justin@ic.ac.uk and I'll dig out the
> code for you.
>
> Justin
>
>
> In article <36B0B2B5.1C0A2FB7@va.aetc.com>, bpuc@va.aetc.com wrote:
>> Is there anybody who has written any IDL code to access the serial
>> port on a PC or UNIX platform? I'd be interested in seeing
>> implementations.
>> Thanks.
>>
>>
|
|
|
|
|
|
|
Re: serial port [message #40336 is a reply to message #14133] |
Mon, 02 August 2004 12:58   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
michele writes:
> okay i try to explain better...
>
> i want to write a program that uses the gps and so i need to read and
> write directly from the serial port.
> on the idl web-site there is a zip file (under user-contributed site,
> section dll and dlm files) that seems to provide what i need.
>
> if you unzip the file you get 4 files:
> serial.dll and serial.dlm (to be put in a specified folder)
> a readme file that is a bit like the help page that describes 4
> functions
> and a c-language source code (it doesn't have a main).
>
> my goal is to be able to use the functions described in the text file:
> these functions are
> comm_open
> comm_read
> comm_write
> comm_close.
>
> all this stuff is achieved through dynamically linked modules, and in
> this case it means that my idl program must be coupled with some piece
> of C-language..
>
> what i did is just putting the dll and dlm files in the right folder,
> and than trying to use the functions as normal idl functions.
> but they are not recognized as functions.
> moreover i didn't use the c source file in any way... but i think i
> should use it.. if it contained a main i could try to spawn it from
> the main idl module but i can't get an executable out of it becuse it
> contains no main...
I don't know. It seemed to work for me. I downloaded the file. Extracted
the DLL and DLM files to the appropriate place in my IDL distribution.
Exited IDL. Started IDL and typed this:
IDL> DLM_LOAD, 'serial'
% Loaded DLM: SERIAL.
IDL> h=COMM_OPEN('com1')
IDL> ok = COMM_CLOSE(h)
Seems to work fine.
You are running this on a Windows machine, right? If not,
the C source code is so you can recompile it for your machine.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: serial port [message #40338 is a reply to message #14133] |
Mon, 02 August 2004 12:41   |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
michele wrote:
> okay i try to explain better...
>
Hi,
Although you know the DLM is not working, you can confirm that it is (or is not)
in you DLM path by...
HELP, /DLM
which will spit out all of the currently accessible DLMs (whether loaded or
not). If it doesn't show up in the listing produced by the call to help, then
check your DLM path to make sure it includes the place you put the serial DLM.
PRINT, !DLM_PATH
Of course, you probably know already that the serial DLM is for Windows only.
Ben
> i want to write a program that uses the gps and so i need to read and
> write directly from the serial port.
> on the idl web-site there is a zip file (under user-contributed site,
> section dll and dlm files) that seems to provide what i need.
>
> if you unzip the file you get 4 files:
> serial.dll and serial.dlm (to be put in a specified folder)
> a readme file that is a bit like the help page that describes 4
> functions
> and a c-language source code (it doesn't have a main).
>
> my goal is to be able to use the functions described in the text file:
> these functions are
> comm_open
> comm_read
> comm_write
> comm_close.
>
> all this stuff is achieved through dynamically linked modules, and in
> this case it means that my idl program must be coupled with some piece
> of C-language..
>
> what i did is just putting the dll and dlm files in the right folder,
> and than trying to use the functions as normal idl functions.
> but they are not recognized as functions.
> moreover i didn't use the c source file in any way... but i think i
> should use it.. if it contained a main i could try to spawn it from
> the main idl module but i can't get an executable out of it becuse it
> contains no main...
>
> thanks in advance
>
> michael
|
|
|
|
|
Re: Serial Port [message #41931 is a reply to message #14133] |
Tue, 30 November 2004 15:04  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Have you tried the serial port dlm that is offered in the user contrib
section of the RSI web page?
Haje
"Patrick Dillmann" <patrick.dillmann@gmx.de> wrote in message
news:c10d9338.0411300705.7915ac22@posting.google.com...
> Hi,
>
> I have a problem if I try to read a serial port on a Win 2000 PC. If I
> only send a message to a device everything works fine. But when I use
> the following Code to get an answer IDL hangs up:
>
> val=bytarr(34)
> port='COM1:'
> get_lun, u
> openu, u, port
> text = 'DATA?'+string(13B)
> writeu, u, text
> readu,u,val
> close, u
> free_lun, u
>
> Due to the fact that this code works as expected even for getting an
> answer if I first start and close the Hyper Terminal for this port, I
> believe that I must send some port settings (e.g bits per second,..)
> before sending my code.
>
> If this is the case, how can I initialize a serial port with IDL? Are
> there other possibilities to communicate with a device via a serial
> port?
>
> Thanks,
> Patrick
|
|
|