LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fail to open Serial Port

Solved!
Go to solution

Problem Description: One C++ Software Called one DLL created by LabVIEW. The DLL is operating one MCU by COM6 on the main board of one industry computer. After end the C++ software by task manager, I start up one LabVIEW EXE to open the COM6 created with one NI official VI "VISA Configure Serial Port (Instr).vi", the following error ocurred.

Error Source:Property Node (arg 1) in VISA Configure Serial Port (Instr).vi

 

1:restart the C++ software to open COM6 ok.
2:add the VISA close 2 times bofore open COM6 to LabVIEW EXE software, open COM6 failed.
3:logout the computer, use the LabVIEW EXE to open COM6 failed, the error is the same with above.
4:only after restart the computer, open COM6 ok by LabVIEW EXE software.
How can I use the LabVIEW EXE to open COM6 ok without restart the computer?

 

LabVIEW Version: 2014(32bit)
NI-VISA Runtime: 14.0.0

Download All
0 Kudos
Message 1 of 25
(2,573 Views)

I tried many way to open this COM6 ok, like:

write another C++ software to open COM6 ok;

use one general serial port assistant to open ok;

use labVIEW call activeX MSComm to open ok;

Only use "Configure Serial Port (Instr).vi" or "VISA Open" function open failed if not restart the computer.

0 Kudos
Message 2 of 25
(2,560 Views)

@changelopnur wrote:

 After end the C++ software by task manager, I start up one LabVIEW EXE to open the COM6 created with one NI official VI "VISA Configure Serial Port (Instr).vi", the following error ocurred.

 


So you are force closing the C++ software, without closing the COM port?

This is a problem, in some cases this would keep the COM port "open" even if nothing is going on on it. Close the port correctly with the C++ software (why are you even using task manager to end it? Sounds like a bad design) and then reopen it in LabVIEW and it should work correctly.

 

EDIT:

Try also just opening the port with LabVIEW directly (without first using the C++ software), to see if that works.

0 Kudos
Message 3 of 25
(2,507 Views)

Thanks.

Yes, I know and verified this problem is caused by force closing the C++ software without closing the COM port, because sometimes the C++ software is down and can't be closed correctly. The last step on C++ software is closing COM port. If this step is run, after closing the C++ software by any way, my LabVIEW Software can open the COM port ok.

I tried many ways like as below after closing C++ software and ensure no any C++ process in tesk manager.

1. run my LabVIEW software first, open COM port failed.

2. Disable and enable COM port.

3. uninstall and reinstall COM port.

4. it should not be driver and cable problem because open ok after restarting the computer.

5. This should be labview problem because this time I can use non labview software to open ok.

0 Kudos
Message 4 of 25
(2,497 Views)

This problem is open over 2 weeks. My customer check the progress with me everyday.😂

0 Kudos
Message 5 of 25
(2,482 Views)

I'd say "go fix the broken code" so you don't have to kill it.  If the code is provided by the customer, this can get rather sticky.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 25
(2,476 Views)

Yes, the C++ software is developed by my customer.

And the software is used over 10 years in mass production line.

It is impossible to update it for my labVIEW problem becuase non LabVIEW software open COM ok after forcing close the C++ software.

0 Kudos
Message 7 of 25
(2,468 Views)

It's probably the difference between using windows functions and whatever labview is doing in the background... I had the same problem, but i solved the improper port closing i had.

 

Can you avoid the task manager kill of the C++ software? Do you know in which cases it hangs?

What if you then open putty (or realterm or whatever you have) and try to close the port that way, before starting LabVIEW app?

 

EDIT:

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)

0 Kudos
Message 8 of 25
(2,460 Views)

Some thoughts:

- the COM port 6, is it a real RS232 port or virtual? Because when virtual, you don't need baud rate and the other serial settings and then it's most likely a USB connection which you can easily disconnect

- the screenshots you posted say that the property node config is bad, though "arg1" is unclear -> you should have found the cultprit since long, as this has been going two weeks now as you say 

- even if you would not correctly close the COM port, disconnecting the USB cable should suffice (assuming the COM port is from USB driver)

- there is an option in LV call "Close VISA session automatically" which isn't enabled by default

- the fact that restarting the PC allows to use the COM port again tells us that it was not closed before the restart

  

0 Kudos
Message 9 of 25
(2,452 Views)

Thank you.

1. can't avoid the task manager kill of the C++ software even if I know what causes it hangs because the software is being used by my customer everyday.

2. I tried some ways like below to close or open/close the COM port before running open by LabVIEW, but all failed.

a. wrote another C++ DLL, call it by my LabVIEW software to open and then close the COM port successfully, then run "VISA Configure Serial Port (Instr).vi" fail to open the same.

b. Call MSComm to open and close ok, then run "VISA Configure Serial Port (Instr).vi" fail to open the same.

c. Call my LabVIEW DLL to open the COM port but fail to open by DLL. I don't know why restart customer's C++ software and call my LabVIEW DLL can open ok. Maybe the difference between C++ and LabVIEW.

3. for you mentioned PuTTY, this problem is caused by customer's C++ software is calling my LabVIEW DLL to control one MCU board, so I can't find any process is still running in tesk manager after I end the C++ software by force.

 

0 Kudos
Message 10 of 25
(2,440 Views)