07-09-2020 10:09 AM
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!
07-09-2020 11:36 AM - edited 07-09-2020 11:36 AM
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.
07-09-2020 11:49 AM - edited 07-09-2020 12:00 PM
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 ?
07-09-2020 12:28 PM - edited 07-09-2020 12:29 PM
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.
11-08-2022 12:22 AM
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!
11-10-2022 08:05 AM
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/...