LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fail to open Serial Port

Solved!
Go to solution

1. it is a real RS232 DB9 port mounted on the main board of one industry computer, not USB-RS232.

2. The LabVIEW error code is -107380246 showed on my first picture.

3. I failed to find the function "Close VISA session automatically", only found "VISA Close" in LabVIEW 2014.

VISA Close.jpg

0 Kudos
Message 11 of 25
(2,301 Views)

@AeroSoul wrote:

If you can close the port with putty or similar, then you can probably make batch script that you call with LabVIEW before opening the port.

 

Content of batchscript:

cd C:\Program Files (x86)\PuTTY (path to putty on your system, this is on mine)

putty.exe -serial COM#

taskkill /IM putty.exe /F (/F to force close it, otherwise you need to click OK)


Have you tried this, from my previous post?

 

The Close VISA session automatically can be found in Getting started window (View-->Getting Started Window..-->Tools-->Options...-->Environment-->Automatically Close VISA Sessions), but that probably won't help you here.

0 Kudos
Message 12 of 25
(2,293 Views)

Thank you AeroSoul.

I have tried some ways to open and close the com port successfully including the following serial port assistant which should be similar with Putty.exe. Then start my LabVIEW EXE to open the com port failed.

COM Assistant.jpg

0 Kudos
Message 13 of 25
(2,266 Views)

This is LabVIEW problem because other program language can open ok.

 

0 Kudos
Message 14 of 25
(2,228 Views)

changelopnur, you confuse us.

First it was a USB port. Later you wrote, it's an RS232 port. RS232 ports are not listed as USB:: in NI MAX. Next, the error in the first picture was not from opening the COM port, it was from the configuration via property node. So if that real RS232 port is COM6, which I currently doubt, you would open it as COM6 or perhaps by its ASRLx::INSTR resource string. When opening the COM6 with VISA Open, another error should come up or none at all. 

 

Regarding item 3: LabVIEW option "Close VISA sessions automatically", not function or VI.

0 Kudos
Message 15 of 25
(2,215 Views)

@MaSta,

I never said it was a USB port. The COM6 is one RS232 DB9 port mounted on the main board of industry computer.

Always, I first set the com port using VISA Configure Serial Port (Instr).vi(I mean open the com6), then I can use VISA write and VISA read.

I also tried first use VISA Open function to open COM6, failed the same.

0 Kudos
Message 16 of 25
(2,212 Views)

@MaSta,

Do you mean I first active the option "Close VISA sessions automatically", then build my EXE?

BTW, this problem is present only at forcing close the C++ software which is calling one LabVIEW DLL for operating COM6 without closing .

So I need to active the option "Close VISA sessions automatically", then build the DLL?

0 Kudos
Message 17 of 25
(2,206 Views)

You might have luck with restarting the COM-Port driver:

 

https://superuser.com/questions/1412239/how-to-force-closing-freeing-the-serial-ports-opened-by-othe...

 

 

 

0 Kudos
Message 18 of 25
(2,181 Views)

This all sounds very strange to me.

 

Are you sure, that you get the same error message in all cases?

 

Up to now, we do not know, what the C++DLL is doing and we do not know, what VISA and other programs doing. It may have something to do with access levels/shared access. I never tried to configure the serial port for shared access - it makes simply no sense. So I don't know if this works or not.

 

I would like to know how my shared library acts in your situation. I just call the DLL directly, because I have no LabVIEW 14 version available. Please execute the attached VI. It's doing nothing special. Just opening the serial port with read/write access and then closing the serial port. It should be very similar to what other programs are doing.

 

 

 

 

Message 19 of 25
(2,163 Views)

@MaSta,

 

Active the option "Close VISA sessions automatically", built the DLL.It doesn't work, the problem is the same.

0 Kudos
Message 20 of 25
(2,057 Views)