aaronfleishman Posted February 22, 2008 Report Share Posted February 22, 2008 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 20x-60x per second. 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 @ NI Developer Forums. I am also using MSDN to get all of the function calls. 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 Note: I've been asked about using TCP/IP to send the data. The above method was suggested by the 3rd party company. Quote Link to comment
Rolf Kalbermatter Posted February 23, 2008 Report Share Posted February 23, 2008 QUOTE(psufleish23 @ Feb 21 2008, 03:40 PM) 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 20x-60x per second. 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 @ NI Developer Forums. I am also using MSDN to get all of the function calls.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 . I'm really stuck on implementing the code in this . -Aaron Note: I've been asked about using TCP/IP to send the data. The above method was suggested by the 3rd party company. File mapping should work for use as shared mamory in theory and did so in the past for me but: no, if you update the file instead of a mapped pointer to the file I don't think this is gonna work. Also you should not try to copy the name string for the MapFile but instead the returned pointer from MapViewToFile. Another suggestion would be to use UnmapViewFromFile and CloseHandle afterwards to properly close of all resources. Also as has been explained on the page you linked to access to mappedFiles can generate exceptions. LabVIEW has an exception handler around Call Library Nodes but that will popup an user error dialog. To handle those exceptions yourself you will have to create an external DLL as custom exception handling is not supported by LabVIEW. I would say go for UDP/TCP instead. Much more robust, remote capability built in and easy to do in LabVIEW. Rolf Kalbermatter Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.