LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing data with multiple instances

I wrote a LabVIEW program which communicates to custom hardware via a USB port.  The custom hardware utilizes an FTDI chip, so I am using the dll on the FTDI website for all communications....no problem.  My LabVIEW program opens the hardware, obtains the usb handle and communicates with it. 

 

However, now I need to allow a separate legacy executable (written in VB6) to communicate with the same hardware over the same USB connection.  My LabVIEW program runs the legacy executable by calling it with the System Exec.vi.  The legacy software originally communicated to PCI hardware using a custom dll.  So...I replicated the legacy dll in LabVIEW, but altered all of the hardware communications to utilize the USB port.  I created a new dll in place of the old one.  But since the USB handle is already opened by my LabVIEW program, the dll fails to communicate -- the OPEN fails.  FTDI support said that only one connection can exist and that is why the second OPEN fails.  Since I already know the USB handle from my LabVIEW program (and I control the hardware access), I figured that I could pass the handle into the dll for the VB program to use.  Then when the VB code 'opens' the hardware, it is really just reading the handle from the dll that my LabVIEW program placed there.

 

I added a vi to the dll that allows me to pass the handle into it.  This did not work.  It turns out that the LabVIEW executable instantiates a different copy of the dll than the VB executable.  So I cannot pass data between the two executables this way.  My next effort works, but it is not very elegant.  Now when I pass the handle into the dll, I have the dll write it to a disk file.  When the VB program calls the 'open' routine, the dll reads the handle from the disk file.  This works fine.  My application and the VB application both operate as they need to. 

 

I can forsee problems with this solution:

  1. The user may not want a small file being written to their system directory.
  2. Only one instance of the software/hardware can run on the computer.

 

This is a very custom system and will never be mass produced, but there is the possibility that mulitiple versions may need to run in the future.  Since the file name is generic, both instances of the software would access the same file and could overwrite each other's data.  What is the better way to pass my USB handle from one executable to another?  I tried using a shared variable in the dll, but I think I have the same issue of instantiated dlls not sharing information with each other.

 

I included a block diagram of my situation.  The code is proprietary, so I cannot include the code.  Thank you for any help or suggestions.

Jason
.
0 Kudos
Message 1 of 2
(2,892 Views)

Have you considered UDP or TCP/IP?  Both work well interprocess on local machines and are easily expandable to multiple machines.  Network shared variables and network streams should also work.

 

Note that I have never used any of these technologies, I usually launch multiple LabVIEW executables into the same runtime if I am running them on the same machine and communicate via queues or action engines.

0 Kudos
Message 2 of 2
(2,857 Views)