LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Mapping Files to Memory

I need to be able to communicate data between LabVIEW and another program.  We need LV to write to a file (e.g. *.txt.) about 1x per second (only writing about 10-20 string controls) and the other software reads it at about the same rate.  The data in this file will be read by the 3rd party software.  The 3rd party software will only be reading, LV will be doing all of the writing.  The method that the 3rd party software company proposed (since they had worked with it before) is memory mapping, or mapping the file to memory.  Has anybody had any success in doing this before?  I am trying to rework some code posted before.  I am also using MSDN to get all of the function calls down.

The main problem I am having is how am I able to read back the data?  I thought I was close, but based on the code attached, it didn't return anything.  Also, does the filemapping update when the referenced file is changed?  Or will I need to read and write through through the memory mapping?

Here is the MSDN site for File Mapping.  I'm really stuck on implementing the code in this section.

-Aaron
0 Kudos
Message 1 of 4
(2,800 Views)

I'm not sure about the specifics, but why can't you just write to the file and let them read from it?

Better yet, why not just open a TCP/IP connection to their application and send the data through it? That's usually the cleanest method. Since you're only dealing in ASCII, you don't have to worry about data types and other stuff like that.


___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,787 Views)
We can't have it read and write to the same file because the 3rd party program is reading the data in at 20-60x per second (most of this is static data, it only changes 1x per second...I know sounds odd but that is the way it needs to be).  I think that this becomes an issue with the speed of reading that data in, as well as having file access conflicts when Program B is reading while Program A is writing the data.  As for TCP/IP, I don't know if the 3rd party software is capable of using that as a data stream.  Regardless, using memory mapping method that they suggested to use for this type of application after we explained it to them...so now I need to make it work in LV.
0 Kudos
Message 3 of 4
(2,780 Views)
Hi Aaron,

There is way in labview to directly map data to particular location in Memory. It is called Out port.vi and In port.vi. I looked at your program and maybe I have understood the requirements wrong. Are you trying to make the 3rd party program read the data or is LabVIEW trying to read the data?


Warm regards,
Karunya R
National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(2,746 Views)