From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically detect com port

Hello

 

I would like to create a User Event that defines which method data is provided to the VI (either Serial port or Telnet). If it is Serial port then I would like the VI to automatically find the correct data port that is providing valid instrument data and then stream the data to the screen. If it is a Telnet connection then the IP addresses are pre-determined and the data will also stream to the screen.

 

As you can see in the attached VI, I am chasing my tail. I can successfully configure my Serial ports to my instrument thanks to some previous help but when I try to build an automatic COM port detection loop, I make a mess of it and my clean-working VI get all gunked-up.

 

Will someone please put me back on track? What are the key elements that I am missing in this logic?

 

Thank you so much.

~Derailed

 

p.s LabView 2009 on MacOSX

 

p.p.s. I just found this in the forum help topics and will explore it, but I think I need additional logical sequences to accomplish my goal.

http://forums.ni.com/t5/LabVIEW/ASRL-versus-COM-display/m-p/88100#M54017

 

 

0 Kudos
Message 1 of 7
(12,566 Views)

You dont have to itterate all ports, first limit your scan by using VISA find all resources (possibly limit to COM*)

then on thoese ports listen for a valid reply. once found use the resource.

A simple state machine would also help you with your architecture.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 7
(12,555 Views)

So I simplified. Attached is a VI using VISA Find Resource to pipe a list to a While Loop that searches the com ports for valid packets.

 

When running with highlighted execution ON, I can see that the loop sees the correct com port and the logic is good but the VISA Read reads no data. I removed the Flush Buffer vi and increased the bytes to VISA Read but still have the same result - no data to screen.

 

I also tried to lengthen the amount of time the Mac might need to read the com port from 50ms to 100ms but still nothing. Any ideas?

 

Thanks,

~Almost back on one rail

0 Kudos
Message 3 of 7
(12,530 Views)

Does your device just start sending data without first recieving a request?

If you open up some type of Terminal program, do you see data right away? (I don't know what's on a Mac)

 

If your setup is the same as in Terminal program and there are no errors from the "VISA Configure Serial Port" or "VISA Set I/O Buffer Size", I don't see way you should not see something from your device if your device is sending stuff out.

 

Also you your wait for your read data is set to 2100 ms (2 sec timeout + 100 ms delay). The VISA will wait 2 sec looking for a cntrl-D termination char before returning an error.

Omar
0 Kudos
Message 4 of 7
(12,524 Views)

Yes, device is set to simply feed data to serial port at 25 bytes/sec as long as it is powered on, and yes, data spews directly into Hyperterminal and equivalents without prompting when connected.

 

Ok, well that makes me feel better about my confusion at least. I'll keep sleuthing but any other suggestions are welcome!

0 Kudos
Message 5 of 7
(12,520 Views)

when in doubt power cycle. Looks like that piece of code is running ok now. Will return soon with Event Structure...

0 Kudos
Message 6 of 7
(12,518 Views)

Let's just try a very simple comport read VI

 

Try this with your correct comport and see what you get.

 

Adjust the VISA Configure setting to see if that makes a different.

 

I don't use a Mac so it might be something not on a PC

 

 

Omar
0 Kudos
Message 7 of 7
(12,512 Views)