LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Comm Search

I would like to produce a VI that blindly searches available serial comm ports
until it finds the port to which our custom, hardware instrument is attached.
Unfortunately when I write a serial command to a port with no instrument
attached, the software does not time out (using old serial comm vi's since
I don't really understand visa). Any Suggestions?
0 Kudos
Message 1 of 4
(2,761 Views)
Chris Anderson wrote:

> I would like to produce a VI that blindly searches available serial comm ports
> until it finds the port to which our custom, hardware instrument is attached.
> Unfortunately when I write a serial command to a port with no instrument
> attached, the software does not time out (using old serial comm vi's since
> I don't really understand visa). Any Suggestions?

I would really suggest that you look at VISA. There is a function that does
exactly what you wish ( Find VISA Resources or similar).
You dont need to know VISA to use it, simply drop it on a diagram
and wire an indicator. It will return an array of stings listing any
serial, GPIB, or VXI devices it can find.
You can limit it to look for only serial devices.
Kevin Kent
Message 2 of 4
(2,761 Views)
Chris Anderson wrote:

> I would like to produce a VI that blindly searches available serial comm ports
> until it finds the port to which our custom, hardware instrument is attached.
> Unfortunately when I write a serial command to a port with no instrument
> attached, the software does not time out (using old serial comm vi's since
> I don't really understand visa). Any Suggestions?

I think you can write to the serial port anyway, regardless of what is attached to
it.
The problem should be if there is a response. You can set up a simple loop that
acts as a timeout:

while(not timeout)
keep on calling the "Bytes at serial port vi"
if any pending, read them and check if the response is correct.
else keep on looping.

(sorry for the ugly pseudo code)

The timeou
t can be implemented with a difference block: at each loop iteration you
compare the initial ms timer value with the current one. if that diff exceeds a
given trehshold you exit the loop and consider the device not being on that port.

Hope this helps.

--
Wolf-Dieter Wall
0 Kudos
Message 3 of 4
(2,761 Views)
On 7 Jan 2000 15:36:14 -0600, "Chris Anderson"
wrote:
>I would like to produce a VI that blindly searches available serial comm ports
>until it finds the port to which our custom, hardware instrument is attached.
> Unfortunately when I write a serial command to a port with no instrument
>attached, the software does not time out (using old serial comm vi's since
>I don't really understand visa). Any Suggestions?


You might try something like this:
for each of the serial ports you want to try
Initialize your serial port to _not_ use handshaking.
Send the command you need to get the instrument to identify itself
do
check number of characters in serial buffer
(Bytes At Serial Port.vi)
read number of characters from serial buffe
r
(Serial Port Read.vi) and attach it to a "variable"
while not timeout or no identification
end for

--
Rolf
0 Kudos
Message 4 of 4
(2,761 Views)