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.

FlexLogger

cancel
Showing results for 
Search instead for 
Did you mean: 

Are semaphore possible in FlexLogger?

Hi,

 

I was wondering if it was possible to share data through multiple instances of a plugin using a global variable or a semaphore.

 

In my case, I would like to call multiple instances a plugin that will be connected to a modbus equipment. Because I will have multiple connection, I fear that I will have errors so I would like to share the connection to the equipment and “block” the read/write request when it is already used by another instance of the plugin. For the blocking request, can I use a semaphore.

 

Thank you!

0 Kudos
Message 1 of 6
(2,900 Views)

You can use semaphores in plugins (at least I don't see any reason they wouldn't work).  The only caveat is that plugins are built into packed project libraries so things like functional global variables don't always work the way you would think. I've used named queues between plugins before, I think semaphores behave similarly under the hood.  You might even be able to get away with just making your VI which accesses the hardware non re-entrant.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 6
(2,876 Views)

Hi Kevin,

 

I work with Dave, who's the author of the original post.

Ok for the semaphores, we'll try it. We do not want to modify the reentrancy of a lib that is part of the LV ecosystem. So we'll go with the semaphores.

In that plugin, we'll need to share port references to ensure that a port is not reopened if already opened by another instance of the plugin (for example an RS232 connection). Sharing the ref info through globals would work in order to share that data between plugin instances ?

 

 

CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 3 of 6
(2,864 Views)

Globals are a little tricky for the reasons described in this thread:https://forums.ni.com/t5/LabVIEW/How-to-access-common-global-variable-between-different-Packed/td-p/...

 

I'm actually not sure you will have this problem or not using a global if its in the plugin library and all users of it are that same plugin library.  If you do run into problems, the single element named queue has worked well for me for similar situations when I need to share data between some things that are in a ppl and other things that are not.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 4 of 6
(2,846 Views)

Can you please share more on how you got named queues to work in FlexLogger Plug-Ins?

 

I have been unable to get this to work. I would like to stream FlexLogger channel data using a named queue (or network stream) out of the plug-in to another VI running on the same computer. The reading VI is part of the same project as the plug-in.

 

The queue's never see each other. Same with network streams. My guess is the queues are in separate application instances, or that the endpoint references within the plug-in are getting destroyed/garbagecollected (which was implied by this error: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019MUUSA2&l=en-US)

 

Can you provide a bit more info on how you got queues to work across the plug-in boundary? Thanks!

0 Kudos
Message 5 of 6
(1,649 Views)

It sounds like you got this working in this thread, so attaching so others can find it:
https://forums.ni.com/t5/FlexLogger/Why-is-reading-Skyline-tags-from-FlexLogger-limited-to-1-Hz/m-p/...

0 Kudos
Message 6 of 6
(1,631 Views)