High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming NI-5122 in Visual Studio 2005 with multithread mode can cause hang

Hello,
 
I'm developing an application in Visual Studio 2005. I called NI-Scope APIs in a working thread. The software can talk to NI-5122 successfully, which I can see from NI-spy. However, after that, the UI hangs up. When I debug the program, Visual Studio tells me there is some deadlock among some threads. I attached the application used to reproduce this problem. To reproduce this problem, you just need to click the "Run" button on the dialog. Here is my developing settings.
 
Hardware: NI-PCI-5122 digitizer (the device name is "Dev1" in MAX)
 
Software: Windows XP+Visual Studio 2005+NI-Scope 3.3.0f0.
 
Please advise.
 
Thanks,
Jucao Liang
0 Kudos
Message 1 of 5
(7,860 Views)
Hello Jucao,

Before calling your thread which uses the scope driver, there are some components that must be loaded.  To load these required components you can simply call into the scope driver.  In your code if I place the following code into the OnBnClickedRun() method before creating the new thread everything works.

ViSession vi=VI_NULL;
niScope_Init("Dev1",VI_FALSE,VI_FALSE,&vi);
niScope_close(vi);

Regards,

Jesse O.
Applications Engineering
National Instruments

P.S. You might want to update your user profile to contain a valid email address.

Message Edited by Jesse O on 05-23-2007 06:01 PM

Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 5
(7,834 Views)

Dear Jesse,

Thank you so much. I tried your solution and it worked pretty well. Maybe you can add this as a KB so the other customers can also benefit from that.

As to Email address, I used to be NI employee and I just left NI. That's why you see jucao.liang@ni.com. 🙂

Thanks again.

Jucao

 

 

0 Kudos
Message 3 of 5
(7,831 Views)

Hi Jucao,

Keep in mind that you just need to call this extra code once within the main thread.  I have modified your .cpp file by placing these calls in your CMT_Test_NI_DGT_AWGDlg:: OnInitDialog().

Another solution is to call

#include

"ivi.h"
IviConfigStoreHandle handle=NULL;
Ivi_GetConfigStoreHandle(&handle);

from the main thread.  To use this solution, you will need to be sure to link to the ivi.lib library.  The attached file has both workarounds in place, with the IviConfigStoreHandle method commented out.

I hope this helps.

Regards,

Sean Close
Product Support Engineer: High Speed Digitizers

 

Message Edited by Sean C. on 05-24-2007 10:17 AM

Download All
Message 4 of 5
(7,816 Views)
Hello Jucao,

In order to recieve subscription notices from the NI Discussion Forums, you can change your email address by going to ni.com/profile and clicking Modify Profile. 

Regards,
Laura
Web Support & Operations
National Instruments
Message 5 of 5
(7,789 Views)