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: 

Problems with access to serial port using reentrant code

Hi,

I have a VI that send commands and receive answers from an instrument using
de serial port.
This VI runs perfectly when used alone.
However I'm trying run two instances of that VI simultaneously using
reentrant code and I'm facing some problems.
Sometimes everything is OK but sometimes, in the process of writing to
serial port the following error happen:
Error code 36.
Invalid refnum device.

What is this?
Does someone know how to prevent this?


Thanks in advance for any help.
0 Kudos
Message 1 of 4
(2,638 Views)
Perhaps one VI is opening the port and not closing it so the other
VI can use it?

Can what you are trying to accomplish be done without reentrant
VIs?

Alan

"Paro, Paula [CMPS:2721:EXCH]" wrote in message
news:8s4uli$jii$1@nrchh45.us.nortel.com...
> Hi,
>
> I have a VI that send commands and receive answers from an instrument
using
> de serial port.
> This VI runs perfectly when used alone.
> However I'm trying run two instances of that VI simultaneously using
> reentrant code and I'm facing some problems.
> Sometimes everything is OK but sometimes, in the process of writing to
> serial port the following error happen:
> Error code 36.
> Invalid refnum device.
>
> What is this?
> Does someone know how to prevent this?
>
>
> Thanks in adva
nce for any help.
>
>
0 Kudos
Message 2 of 4
(2,638 Views)
I think that the error code 36 and message "invalid device refnum"
is correct.

Have a look at the device reference numbers which are handled by
Open Serial Driver.vi. I don't actually know what you have done,
but make sure that the Open Serial Driver.vi is not reentrant.

Martin


--
Martin Henz Systemtechnik
Dipl. Ing. (FH) Martin Henz
Walchensee Str. 3
70378 Stuttgart
Tel. ++49-711-5302605
Fax ++49-711-5058649
http://www.mhst.de
"Paro, Paula [CMPS:2721:EXCH]" schrieb im Newsbeitrag
news:8s4uli$jii$1@nrchh45.us.nortel.com...
> Hi,
>
> I have a VI that send commands and receive answers from an instrument using
> de serial port.
> This VI runs perfectly when used alone.
> However I'm trying run two instances of that VI simultaneously using

> reentrant code and I'm facing some problems.
> Sometimes everything is OK but sometimes, in the process of writing to
> serial port the following error happen:
> Error code 36.
> Invalid refnum device.
>
> What is this?
> Does someone know how to prevent this?
>
>
> Thanks in advance for any help.
>
>
0 Kudos
Message 3 of 4
(2,638 Views)
"Paro, Paula [CMPS:2721:EXCH]" wrote:
>
> Hi,
>
> I have a VI that send commands and receive answers from an instrument using
> de serial port.
> This VI runs perfectly when used alone.
> However I'm trying run two instances of that VI simultaneously using
> reentrant code and I'm facing some problems.
> Sometimes everything is OK but sometimes, in the process of writing to
> serial port the following error happen:
> Error code 36.
> Invalid refnum device.
>
> What is this?
> Does someone know how to prevent this?
>
> Thanks in advance for any help.

You can't use reentrant vi's vith serial vi calls without supervising of
driver.
Use VISA instead and you have to control the VISA session opening and
closing. Another word is that the only one serial port sess
ion should be
opened at a time.
Reentrant vi's for serial port without checking serial port session is a
mistake of program algorithm. Change it in any convenient way.
--
Sergey Krasnishov
____________________________________
Automated Control Systems
National Instruments Alliance Member
Moscow, Russia
sergey_acs@levsha.ru
http://acs.levsha.ru
0 Kudos
Message 4 of 4
(2,638 Views)