LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1172, Access to the port"COM3" is denied

Hi There,

 

I am using a .NET dll to communicate with my hardware. The  .NET dll handles the open COM write/read and then close the com port. In my case is com port 3.

The VI is called from TestStand, and in one subsection there are 20 calls to the some VI.

Because I monitor an analogue input there is a 2.5s wait between every call to give enough time to the A/D conversion.

It does work first call maybe second call but then fail with error 1172 access to the COM3 is denied.

If I have the VI in debug mode then pass all the time.

I have the .NET dll in the some directory as the VI.

 

Can you please have a look at my diagram maybe I have missed something.

It is the first time when I use .NET call.

 

Thanks

0 Kudos
Message 1 of 7
(8,073 Views)

Hard to tell with how the communications fits into the loop, but since it passes in "debug mode" (with the light bulb on?) that points to a timing issue. Something isn't being closed or reset in the time you are allowing, I would guess. Is the 2.5 seconds in that timer on the left side of the diagram? Have you tried making it significantly longer as a test? You say that the .NET function performs the open and close, which apparently you do each time. It is usually a good idea to open a com, do all of the communications (repeated calls, whatever) then close, but with it being done at a low level I don't know what your options might be.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 7
(8,057 Views)

A suggestion: try to keep the .NET object alive across different calls.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 7
(8,048 Views)

Hi Putnam,

 

Yes you are right there is a timing issue. I have increased the time in the timer previous to the com case statement to 5 sec and the some behavior. The NET dll is not written by me so I have no access to the source code. But in my TestStand sequence I have many steps which call the some dll using the .NET adapter and I have never had a fail. Is does point to LabVIEW code. Maybe windows does not close the port.

Thanks for your suggestion.

 

Marian  

0 Kudos
Message 4 of 7
(8,025 Views)

Hi Paolo,

 

How do you keep the .NET object alive? Can you please give me some sugestions or point me in the right direction.

 

Thanks for your replay.

 

Marian

0 Kudos
Message 5 of 7
(8,024 Views)

The simplest way is to place the first ModbusSerialInterface block before the read loop and the Close block after the loop.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 7
(8,003 Views)

Is it possible that you need to call a close port method?  That simply closing the ref num does not ACTUALLY close the port, just invalidates the reference?


Paul
0 Kudos
Message 7 of 7
(7,993 Views)