I have found the problem, it was that i have declared on the user interface stripchart and i was trying to setup a normal graph on the C code, now this issue is solve, thanks for your sugestions.
Now i have another problem may be you can help me. I am sending data from my USB RAW and i want to enable the USB interrupt with visa commands in order that when there is an interrupt my program in CVI gets the values from the USB.
i have tryed in diferent ways but always i got an error setup on the function, and the programm dos not run.I have read the only example that is on the user manual but i have still the problem, i have declarated my funciton, installed the handler, but when i want to eneble the VI_EVENT_USB_INT is when the problem appears, the error code says :
ViEnableEvent : Unable to start operation because setup is invalid (due to attributes being set to an inconsistent state)
The code that i am using is the next:
//headers files
static unsigned char FF6[513];
static ViStatus status;
static ViSession defaultRM;
static ViSession instrument;
static ViObject instrument;
static int panelHandle;
static int start=0;
static ViBuf Userhandle;
static ViEvent eventContext;
static ViUInt32 retcount;
static ViEventType etype;
//USB int event handler
ViStatus _VI_FUNCH myCallback(ViSession instrument, ViEventType etype, ViEvent eventContext, ViAddr UserHandle)
{
//printf("hola");
//ViUInt32 retcount;
//ViJobId jobID;
//ViUInt16 stb;
//status = viReadSTB (instrument, &stb);
//status = viReadSTB(vi, &stb);
//status = viReadAsync(vi,(ViBuf)UserHandle,512,&jobID);
status = viRead (instrument, FF6, 512, &retcount); //read the values of fifo6
return VI_SUCCESS;
}
int main (int argc, char *argv[])
{
// ViBuf Userhandle;
// ViEvent eventContext;
// ViEventType etype;
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "usb.uir", PANEL)) < 0)
return -1;
status = viOpenDefaultRM (&defaultRM); //we open the Resource Manager
if (status < VI_SUCCESS) /*Check if we have an Error Initializing VISA...exiting*/
return -1;
status = viOpen (defaultRM, "USB0::0x04B4::0x1002::NI-VISA-0::RAW", VI_NULL, VI_NULL, &instrument); //we open the communication with our instrument
if (status < VI_SUCCESS) /*Check if we have an Error Initializing instrument...exiting*/
return -1;
viFlush (instrument, VI_WRITE_BUF_DISCARD);
viFlush (instrument, VI_READ_BUF_DISCARD);
Userhandle = (ViBuf)malloc(512);
status = viInstallHandler (instrument, VI_EVENT_USB_INTR, myCallback, Userhandle);
if (status < VI_SUCCESS) /*Check if we have an Error to istall the handler for the USB INT */
return -1;
status = viEnableEvent (instrument, VI_EVENT_USB_INTR, VI_HNDLR, VI_NULL);
if (status < VI_SUCCESS) /*Check if we have an Error to istall the handler for the USB INT ************************** Here is the problem ***************************/
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
I hope you can indentify where is my mistake, also i would like to know if you can send me and example using events, that will be very usefull for me, Thanks