LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview (RTX) Real Time Question

I've been developing an application, which was originally being developed on the ETS real time system, but has migrated to the RTX system.  Everything has gone fine except now when I try to load the program onto RTX I get the following error: Failed to load shared library test.dll on RT target device.  I know RTX supports DLL's but I didn't find any information specifically about DLL's on RTX and Labview, but are DLL's not supported on RTX?  If they are supported, here is what I've tried.  I made a test function that does nothing but return a value.  I used the RTX SDK Visual Studio Wizard to get all the necessary DLL configuration.  I've tried several different configurations with no luck.  I'm using Labview 7.1.  I would appreciate any suggestions, alternative approaches, and/or examples.

I have one more question -- the source of which may be obvious because of my ETS background.  How do I tell RTX to run the real-time part of the software and have the non-critical part of the software to run on Windows.  In ETS you run the real-time program on ETS then connect to it with another computer running the non-critical software.  Thanks for all the clarifications.

Aaron
0 Kudos
Message 1 of 12
(8,761 Views)

Aaron, it is possible -- but I'm not sure what may be causing the error, assuming you have correctly installed the LabVIEW Real-Time Module for RTX according to the installation instructions.  If  you haven't already, definitely install RTX 6.1.  RTX 6.1 provides support for Windows XP SP2. There are several other Knowledge Base entries dealing with RTX which you may want to take a look at (simply type in RTX in the ni.com search field) but none that seemed directly related to your issue

The real-time architecture using RTX is basically the same as ETS -- the display or front panel VI will run in Windows, while the time-critical VI will run on RTX.  You can target RTX in LabVIEW much like you target a Real-Time ETS target.

Hope this helps.

 
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
Message 2 of 12
(8,739 Views)
OK, I read both the KB's you mentioned and updated my RTX.  None of these helped unfortunately.  I was concerned that I wasn't compiling the DLL properly, so I used an RTX SDK example (RTDll\sampleRtdll.c) which comes with a make file to compile it.  It contains one function, Toggle, that I then called from an empty VI (called RTDll Test.vi).  Labview is set to RTRTX::0 and I hit run.  It starts downloading the VI then fails on the sampleRtdll.dll.  I can find no other error messages besides the "Failed to load shared library..." error.  So I guess I ask the question again, does anyone have a suggestions or alternative solutions?  And Doug M although your ideas haven't fixed my problem, your suggestions have greatly expanded my knowledge and I thank you for that.

Aaron
0 Kudos
Message 3 of 12
(8,721 Views)
Aaron,
Have you figured anything out on this?  If you are still having issues with this post your example code and make file as well as your labview vi and I'll try to see if an R&D developer has the RTX tools to try to compile it and see if there is anything else you need to do to get it to work...
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 12
(8,681 Views)
 

No, I haven't yet figured it out and I've run into additional issues.  I've also started a ticket with the phone support, but they have also not been able to find a solution yet.  I found a DLL Checker that I used to test the different DLLs I built.  The real DLL I built uses NI's Hardware DDK, but unfortunately it says that many of the calls/imports rtapi_w32.dll are bad.  So I've also been trying to figure out if I can't use a DLL that involves NI's Hardware DDK in Labview Real-time RTX module. 

Back to the original problem.  Here is the test code:

int __cdecl main(int argc, char **argv)
{
    //SuspendThread( GetCurrentThread());
    return 1;
}


__declspec(dllexport) long int __stdcall InitTask(float sampleRate)
{
    return 5;
}

__declspec(dllexport) long int __stdcall ReadWrite(unsigned short channels,
    short start, short stop, short halt, short status[])
{
    return 10;
}

__declspec(dllexport) void __stdcall EndTask(double outZero)
{
    return;
}

I've also attached the compiled DLL, which checks out in the DLL Checker program linked above, and the test VI.  Maybe someone here can find the problem or offer an alternitive.  I'm also very interested in finding out if the DDK-based DLL should be compatible with Labview RTX.  Thanks for everyone's time and help.

Aaron

 
0 Kudos
Message 5 of 12
(8,666 Views)
Sorry, I just realized my attachments were lost when I previewed the post.  I've also found out that DLLs are not allowed, so I renamed RTX_DAQ_DLL.dll to RTX_DAQ_DLL_dll.txt, so whomever downloads this will have to rename it back to the original.  Thanks.
Download All
0 Kudos
Message 6 of 12
(8,642 Views)
To get dlls to work with RTX and LabVIEW:
1. Your dlls must be of type .rtdll.  The example you sent, RTX_DAQ_DLL.dll, won't work because of this.
2. Your dlls must not depend on other files, like other dlls.
3. You must register your .rtdlls with RTX by using the following command in a command window: rtssrun /dll <path to my dll>.rtdll
4. In the Call Library Node, you must specify the name of the dll as "mydll.*" and not "mydll.rtdll".  Also, once the dll is registered in step 3, you don't need to include the full path to the rtdll.  Just type in the name of the dll "mydll.*"
5. We tried to get the sample you sent, sampleRtdll.rtdll, to work, but it wouldn't, and upon investigation it looks like the RTX tools may have some C++ compiler components, because the actual function names were mangled.  We checked the names using the MS Visual Studio 6 Depends tool and the function Toggle was actually renamed '_Toggle@0'.  Putting this in as the function name in the Call Library Node worked.  Note that you will always have to explicitly type in the function name.

NOTE: Don't actually use quotes "" or angle brackets <> when specifying paths and filenames.

Message Edited by Doug M on 01-17-2006 09:43 PM

Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
Message 7 of 12
(8,619 Views)
Thank you for the information.  To my knowledge, this is not documented anywhere, and I never would have found how to make it work without your help.

Aaron
0 Kudos
Message 8 of 12
(8,595 Views)
Aaron, I will try to add this to a KnowledgeBase for future reference.  Very few people have the RTX tools and this is not something a lot of people have tried, but we're glad we could help.
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 9 of 12
(8,583 Views)
Well, I've followed your instructions to the letter, but I'm still having a problem.  When I follow step 4 and replace the "Library Name or Path" with "sampleRtdll.*", put in _Toggle@0 (and I tried just Toggle) for the "Function Name", and set the return type to Signed 32-bit Integer, I get a Labview error saying "Call Library Function Node: function not found in library".  This results in the broken run button, so now it isn't even downloading to RTX anymore.  I have the rtdll in the same directory as my test VI in case Labview needs to find the appropriate functions in the rtdll before it transfers the file to RTX.  Can you offer any advice on where I'm not following procedure?  Thanks for all your help.

Aaron
0 Kudos
Message 10 of 12
(8,578 Views)