03-18-2010 10:40 AM - edited 03-18-2010 10:46 AM
I have created VI from a .dll (using the Import->Shared Library menu in LabVIEW). The .dll was created in CVI from a C function that calls ni845xFindDevice(). When I try to run my VI, LabVIEW instantly crashes. The first time this happened, it threw an Internal Error (window.cpp (17347)), but it doesn't seem to be throwing that error any more, it just crashes without explanation.
Here's my c file that calls ni845xFindDevice():
//my_code.c #include <ansi_c.h> #include "fundtypes.h" #include "extcode.h" #include "my_code.h" #include <stdio.h> #include "ni845x.h" EXPORT unsigned char proc_cmd(unsigned char char_in) { unsigned char device[50]; uInt32 device_handle; uInt32 num_found; unsigned char *pdevice; uInt32 *pdevice_handle; uInt32 *pnum_found; pnum_found = &num_found; pdevice = &device[0]; pdevice_handle = &device_handle; ni845xFindDevice(pdevice, pdevice_handle, pnum_found); return 0; }//end proc_cmd()
and here is the corresponding header:
//my_code.h
#include "extcode.h" #pragma pack(push) #pragma pack(1) #ifdef __cplusplus extern "C" { #endif #define EXPORT __declspec(dllexport) EXPORT unsigned char proc_cmd(unsigned char char_in); #ifdef __cplusplus } // extern "C" #endif #pragma pack(pop)
Can someone explain why this is happening, or at least how to fix it? I should mention that I plan to call more ni845x functions than ni845xFindDevice(), but wanted to get a basic ni845x function working first.
03-19-2010 02:27 PM
03-22-2010 08:23 AM
Andy C., thanks for your interest. I'm using LabVIEW 2009 Version 9.0f3 (32 bit).
I've attached a zip file containing everything related to this project. The error log is also included.
One important thing to note is that LabVIEW only crashes if you have the NI USB-8451 attached. If it is not attached, the VI runs fine (but of course ni845xFindDevice() finds nothing).
Thanks for your help!
03-23-2010 11:23 AM - edited 03-23-2010 11:32 AM
Hi ryan33,
You've provided some great information to troubleshoot. Although, I do have some additional questions. Have you tested this VI on another computer? Does LV still crash? Have you determined if the crash is specific to this function or device?
I was able to find a bug report for the same "window.cpp line 17347" error (CAR # 201554). However, it was caused by a different situation, so I am unsure if the fix will also apply to this situation.
Also, there was a second case of a customer that received the error only when he installed a Nvidia video driver. Do you have such a driver installed?
03-23-2010 01:16 PM
Ryan,
I wrote my own dll which I complied with CVI which calls ni845xFindDevice() inside an exported function. When calling from LV 2009 and LV 8.6.1, I was able to get ni845xFindDevice() to return "1" as the pNumberFound with 1 USB-8451 connected to my computer.
I've attached my code below, you might want to try it to see if you continue to get the same window.cpp error.
03-23-2010 02:44 PM
Kristen H.,
At this moment, I am unable to test my VI on another computer (no other computers here have LabVIEW 2009 installed). Would I be violating any Terms of Use if I downloaded another evaluation version of LV 2009 and installed it on another machine? I just don't want NI's lawyers to come knocking on my door.
I know that calling the ni845xFindDevice() function is causing the crash because when I comment it out, LabVIEW no longer crashes.
I don't have an Nvidia video driver installed. According to device manager, the only video drivers I have installed are "ATI MOBILITY FireGL V5200" and "Microsoft SMS Mirror Driver."
Thanks,
Ryan
03-23-2010 02:51 PM
Burban,
Thanks for creating that test program, but unfortunately I'm having trouble using it. When I try to import your dll into LV, it throws an error saying that it can't find cvidef.h or ni845x.h. I tried manually adding them to the folder, but when I do that LabVIEW crashes during the Parse Header File stage.
Did you try to run my VI?
Thanks for the help,
Ryan
03-24-2010 10:14 AM
Hi Ryan,
Installing the evaluation version of LV on another machine does not violate any agreements. It would be a violation if it were not an evaluation version. Since you saw a crash when working with the other DL, it may be that LV needs repaired. Go to Control Panel >> Add/Remove Programs >> National Instruments Software >> LabVIEW and select repair. (you will need your installation disk if you did not copy the disk contents to your HD)
03-25-2010 02:10 PM
Kristen H.,
I installed an evaluation version of LV 2009 on another machine and I'm seeing the same behavior (LV instantly closes when I run my VI, but no error is thrown). When the 8451 is not plugged in the VI runs fine. Just for reference, that machine's display driver is reported to be an "Intel 82865G Graphics Controller."
I also tried repairing my install of LabVIEW, but that did not cure the crashing.
Any ideas?
Thanks,
Ryan
03-26-2010 10:50 AM
Ryan,
If you only want to call that function, you can access the 845x DLL directly from labview without having to add a CVI wrapper. If you double click on one of the VI's that ships with LabVIEW you will see that we are making calls into the driver for you. From this call library function node you can call any of the functions available in the DLL. If you try this does your LabVIEW still crash?