Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Loading text file of constants from DLL

We are creating a piece of software that needs to read a set of constants from a simple text file for use inside of functions contained in a DLL. We are running this on RT. We seem to be having a problem with opening the text file. If we have the DLL give just the file name and not the full path to where on the remote host the constant file is stored where does the remote host expect to find the constants file. We have tried just C:\ , but that doesn't seem to be it.
0 Kudos
Message 1 of 9
(4,561 Views)
rtp6xc,

Specifying the full path to the file should work.  If you don't specify a directory in the pathname, the default directory is c:\ni-rt\startup.
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 2 of 9
(4,554 Views)

We tried moving the text file to c:\ni-rt\startup and it still caused the program to crash. Could there be a problem with fgets()? Is there some other function to open a file I should use? We tried running a program that only opened the file and that failled too.

 

Thanks

Bob

0 Kudos
Message 3 of 9
(4,523 Views)
Bob,
Have you tried writing a simple LabVIEW VI that simply opens and closes the file to see if that works?
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 4 of 9
(4,519 Views)
Yeah thats what we tried. It just stops responding and then we have to restart the remote machine(We are using labview rt in case I forgot to mention)
0 Kudos
Message 5 of 9
(4,516 Views)
If we cannot open a simple file on the target that is the first thing to resolve.  Feel free to post your simple VI that opens and closes a file that you are running on the RT target.
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 6 of 9
(4,512 Views)
I think we have a miscommunication. A function inside the DLL opens and reads the file. We have tried a VI that only calls that function, and it still doesn't work. The VI works fine if executed on the local machine. It only fails on the remote. I have had a similar problem using matlab in this fashion, and it was caused by the constants file not being in a place that was seen by the fgets function.
0 Kudos
Message 7 of 9
(4,492 Views)
rtp6xc,
I assume you are trying to use a 3rd party dll that you don't have source code access to --otherwise the best way is to implement everything in LabVIEW.  The ETS RTOS supports a large subset of the Win32 API and the standard ANSI C functions, including standard I/O functions such as fgets() and fopen().  To test to see whether a dll uses any imcompatible function calls you can use the utility found in this KB. Specifying the full path to the file should be fine if your dll is using a function like fgets() or fopen().  One thing you may try is creating your own dll to experiment with, exporting a simple function that uses fgets() or fopen() to try to get that working first.
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 8 of 9
(4,478 Views)
Actually we did code the DLL. It seems that placing the DLL, the constants file, and msvc71d.dll from the computer that compiled it fixed the problem. We coded the DLL in Visual Studio 2003, so it seems the be linked to the MS Visual C Foudation, the third DLL. I repost if anything goes wrong.

Thanks
Bob
0 Kudos
Message 9 of 9
(4,472 Views)