LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxCreateTask when called,the GUI hangs

 

Hello Guys,

 

I have created a UI which connects to a hardware. I have started writing code for the hardware connection in my UI source code which can be seen below. As soon as the code executes the DAQmx configure code: -DAQmxCreateTask("Dev0-R",&taskHandle[0]);, the UI hangs and does not work further. Can anyone tell me what exactly is the problem. I an not connected to any hardware currently but creating a task command should work in my case. I am confused how to go further. Please help.

 

// Code is shown below

 

TaskHandle    taskHandle[4];

int main (int argc, char *argv[])
{
    int error = 0;
    
    /* initialize and load resources */
    nullChk (InitCVIRTE (0, argv, 0));
    errChk (panelHandle = LoadPanel (0, "PintschBamag.uir", PANEL));
    errChk (AttributePanelHandle = LoadPanel (0, "PintschBamag.uir", ATTR_PANEL));
    
    /* display the panel and run the user interface */
    errChk (DisplayPanel (panelHandle));
    
    /* Place for configuring the Hardware Channel connection*/
    
    /*FOr the DAQMx*/
    //char        errBuff[2048]={'\0'};
    
    /*********************************************/
    // DAQmx Configure Code
    /*********************************************/
    DAQmxCreateTask("Dev0-R",&taskHandle[0]);
    DAQmxCreateTask("Dev3-R",&taskHandle[1]);
    DAQmxCreateTask("Dev4-R",&taskHandle[2]);
    DAQmxCreateTask("Dev5-R",&taskHandle[3]);

 

//code ends here

 

 

Thanks,

Raunak

 

 

0 Kudos
Message 1 of 11
(4,607 Views)

The most evident fact is that RunUserInterface () is missing: did you simply miss to copy it or is not present in your actual code? RunUserInterface if the fundamental instruction that start all UI processing: if it is not called you won't be able to handle the UI.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 11
(4,611 Views)


    RunUserInterface () is definately called after creating the tasks (not mentioned in the above code).  But the thing is the intruction does not reach it and stops at DAQmxCreateTask("",&taskHandle[0])

0 Kudos
Message 3 of 11
(4,609 Views)

Does the function return any error code? Pass it to DAQmxGetErrorString to get a description of the error, if any.

What happen if you pass an empty string as the task name?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 11
(4,605 Views)

The function does not return any error code. It just displays the GUI and hangs. If I pass " " empty string as the nask name, still I get the same scenario. The only difference is that I get a warning:

 

   warning: incompatible pointer types passing 'char [1]' to parameter of type 'TaskHandle *' (aka 'void **')

 

Br/

Raunak

0 Kudos
Message 5 of 11
(4,601 Views)

That's a very strange error indeed: it should not happen if the environment is properly configured.

Which version of CVI are you using? And DAQmx? Can you run any of the examples shipped with DAQmx?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 11
(4,588 Views)

I am using the latest 2015 evaluation version of both CVI and DAQmx.

 

I ran the same scenario where the system hangs, then after wating for about a minute I create task is executed. But still I do not understand why this takes so much time??

0 Kudos
Message 7 of 11
(4,583 Views)

So you are saying that:

  1. You run the code and it hangs on the first CreateTask
  2. You wait for ~1 min
  3. You run again the same code without any modification and it runs correctly

Am I correct?

Do you abort the code when it hangs on step 1? Or simply wait and the code proceeds after the pause/timeout?

I seem to understand that you are in the initial steps of development: can you post your complete code?

 

 

Again I'm asking if the same behaviour applies to DAQmx built-in examples.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 11
(4,570 Views)

I run the code only once. I wait for the code line createtask to execute (It takes 1-2 min), then the code jumps to nect nile which displays the panel and then RunUserInterface (see below).

 

 

(Again I'm asking if the same behaviour applies to DAQmx built-in examples) - Yes I checked one of the Daqmx code name -(Read Digital port).

It also did the same (took time on create task).

 

 

MY CODE:

int main (int argc, char *argv[])
{
    int error = 0;
    
    /* initialize and load resources */
    nullChk (InitCVIRTE (0, argv, 0));
    errChk (panelHandle = LoadPanel (0, "PintschBamag.uir", PANEL));
    errChk (AttributePanelHandle = LoadPanel (0, "PintschBamag.uir", ATTR_PANEL));
    
    
    /* Place for configuring the Hardware Channel connection*/
    
    /*FOr the DAQMx*/
    //char        errBuff[2048]={'\0'};
    
    /*********************************************/
    // DAQmx Configure Code
    /*********************************************/
    //Read Tasks
    
    DAQmxCreateTask("Dev0-R",&taskHandle[0]);
    DAQmxCreateTask("Dev3-R",&taskHandle[1]);
    DAQmxCreateTask("Dev4-R",&taskHandle[2]);
    DAQmxCreateTask("Dev5-R",&taskHandle[3]);
    
    //Write Tasks  
    
    DAQmxCreateTask("Dev0-W3",&taskHandle[4]);
    DAQmxCreateTask("Dev0-W4",&taskHandle[5]);
    DAQmxCreateTask("Dev0-W5",&taskHandle[6]);
    DAQmxCreateTask("Dev3-W3",&taskHandle[7]);
    DAQmxCreateTask("Dev3-W4",&taskHandle[8]);
    DAQmxCreateTask("Dev3-W5",&taskHandle[9]);
    DAQmxCreateTask("Dev4-W3",&taskHandle[10]);
    DAQmxCreateTask("Dev4-W4",&taskHandle[11]);
    DAQmxCreateTask("Dev4-W5",&taskHandle[12]);
    DAQmxCreateTask("Dev5-W3",&taskHandle[13]);
    DAQmxCreateTask("Dev5-W4",&taskHandle[14]);
    DAQmxCreateTask("Dev5-W5",&taskHandle[15]);
    
    // Read Barrier Task
    DAQmxCreateTask("Dev1_2-R1_2",&taskHandle[16]);
    */
    

//    /*    Creating Reading Channels        */
//    /*    LED - Creating channels for EA48_1 and half EA48_2*/
//    DAQmxCreateDIChan(taskHandle[0],"Dev0/port0/line0:7,Dev0/port1/line0:7,Dev0/port2/line0:7","",DAQmx_Val_ChanForAllLines);
//
//    /*    LED - Creating channels for EAÜS_1, EAÜS_2, EAÜS_3, EAÜS_4 */
//    DAQmxCreateDIChan(taskHandle[1],"Dev3/port0/line0:7,Dev3/port1/line0:7,Dev3/port2/line0:7","",DAQmx_Val_ChanForAllLines);
//
//    /*    LED - Creating channels for half EA48_2 and EA48_3 */
//    DAQmxCreateDIChan(taskHandle[2],"Dev4/port0/line0:7,Dev4/port1/line0:7,Dev4/port2/line0:7","",DAQmx_Val_ChanForAllLines);
//
//    /*    LED - Creating channels for EA-BÜBÜ1, EA-BÜBÜ2 and EA48_4*/
//    DAQmxCreateDIChan(taskHandle[3],"Dev5/port2/line0:7,Dev5/port0/line0:7,Dev5/port1/line0:7","",DAQmx_Val_ChanForAllLines);
//    
//    /*    LED - Creating channels for H1-H8 Barriers*/
//    DAQmxCreateDIChan(taskHandle[16],"Dev1/port0/line0:7,Dev1/port1/line0:7,Dev1/port2/line0:7,Dev2/port0/line0:7,Dev2/port1/line0:7","",DAQmx_Val_ChanForAllLines);
//    
//    /*    Creating Writing Channels        */
//    /*    Taster/Schaltet - GSM_1 & GSM_2    */
//    DAQmxCreateDOChan(taskHandle[4],"Dev0/port3/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[5],"Dev0/port4/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[6],"Dev0/port5/line0:7","",DAQmx_Val_ChanForAllLines);
//
//    /*    Taster/Schaltet - HSM_1 & HSM_2    */
//    DAQmxCreateDOChan(taskHandle[7],"Dev3/port3/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[8],"Dev3/port4/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[9],"Dev3/port5/line0:7","",DAQmx_Val_ChanForAllLines);
//
//    /*    Taster/Schaltet - Eingänge EA48_1,EA48_2 & EA48_3 */
//    DAQmxCreateDOChan(taskHandle[10],"Dev4/port3/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[11],"Dev4/port4/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[12],"Dev4/port5/line0:7","",DAQmx_Val_ChanForAllLines);
//    
//    /*    Taster/Schaltet - Eingänge EA48_4 */
//    DAQmxCreateDOChan(taskHandle[13],"Dev5/port3/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[14],"Dev5/port4/line0:7","",DAQmx_Val_ChanForAllLines);
//    DAQmxCreateDOChan(taskHandle[15],"Dev5/port5/line0:7","",DAQmx_Val_ChanForAllLines);       
//    
//    /*********************************************/
//    // DAQmx Start Code
//    /*********************************************/
//    DAQmxStartTask(taskHandle[0]);
//    DAQmxStartTask(taskHandle[1]);
//    DAQmxStartTask(taskHandle[2]);
//    DAQmxStartTask(taskHandle[3]);
//    DAQmxStartTask(taskHandle[4]);
//    DAQmxStartTask(taskHandle[5]);
//    DAQmxStartTask(taskHandle[6]);
//    DAQmxStartTask(taskHandle[7]);
//    DAQmxStartTask(taskHandle[8]);
//    DAQmxStartTask(taskHandle[9]);
//    DAQmxStartTask(taskHandle[10]);
//    DAQmxStartTask(taskHandle[11]);
//    DAQmxStartTask(taskHandle[12]);
//    DAQmxStartTask(taskHandle[13]);
//    DAQmxStartTask(taskHandle[14]);
//    DAQmxStartTask(taskHandle[15]);
//    DAQmxStartTask(taskHandle[16]);

    /* display the panel and run the user interface */
    errChk (DisplayPanel (panelHandle));
    
    CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED);
    loadDefaultFile(pathDefault);
    errChk (RunUserInterface ());
    

Error:
    /* clean up */
    if (panelHandle > 0)
        DiscardPanel (panelHandle);
    if(AttributePanelHandle>0)
        DiscardPanel(AttributePanelHandle);
    return 0;
}

0 Kudos
Message 9 of 11
(4,566 Views)

Hello Roberto,

 

Today I reinstalled the NIDAQmx software. Now I do not get a delay in executing the CreateTaskHandle function.

I think it might be some installation problem.

 

Thanks

Raunak

0 Kudos
Message 10 of 11
(4,550 Views)