Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i enable an USB interruption

Hi i am working with a USB Raw, i can read and write from/to it with out any problem, now i produces data on my system (uC and USB) and show that data on a graph using Labwindows CVI, i received the data on an array but when i show tha data on the graph it moves along the x axis, so to avoid that i enable on my uC that only when it has data send it to the USB automatically, so to do that i have to enable on the Labwindows the USB Interrup, i have tryed to enable that event using a handler or a queue but always when i run the program the next error appears:
 
NON-FATAL RUN-TIME ERROR:   "usb.c", line 47, col 14, thread id 0x00000DD4:   Function viEnableEvent: (return value == -1073807302 [0xbfff003a]). Unable to start operation because setup is invalid (due to attributes being set to an inconsistent state).
 
Here is the code that i am using:
....headers  ......
#include "usb.h"
static ViAddr userHandle;
static unsigned char FF6[512];
static ViStatus status;
static ViSession defaultRM;
static ViSession inst;
//static ViObject inst;   
static int panelHandle;
static int start=0; 
 
ViStatus _VI_FUNC myCallback(ViSession vi, ViEventType eventType, ViEvent event, ViAddr userHandle)
{
FF6[0]=9;
return VI_SUCCESS;
}
 
int main (int argc, char *argv[])
{
 
 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, &inst); //we open the communication with our inst
 if (status < VI_SUCCESS)      /*Check if we have an Error Initializing inst...exiting*/
  return -1;
 viFlush (inst, VI_WRITE_BUF_DISCARD);
 viFlush (inst, VI_READ_BUF_DISCARD);

 status = viInstallHandler (inst, VI_EVENT_USB_INTR, myCallback, userHandle);
             
 status = viEnableEvent (inst, VI_EVENT_USB_INTR, VI_HNDLR, VI_NULL);      ********** Here is the problem *********************** ////
// status = viEnableEvent (inst, VI_EVENT_USB_INTR, VI_QUEUE, VI_NULL);
/* if (status < VI_SUCCESS)
 {
  printf("The event was not successfully enabled");
  viClose (inst);
  viClose (defaultRM);
  exit (EXIT_SUCCESS);
 }
 
*/
 DisplayPanel (panelHandle);
 RunUserInterface ();
 DiscardPanel (panelHandle);
 
If i tryed by the handler method i can install the handler but i can not enable the event, and for the queue i can not eneble niether the event
 
I hope somebody can help me, also i will thanks if you can send me and exmaple, thanks.
0 Kudos
Message 1 of 3
(3,844 Views)
Hi Siul,

I found a CVI example for getting USB RAW interrupts here. Hopefully that will be enough to get you started!
Rasheel
0 Kudos
Message 2 of 3
(3,804 Views)
Thanks a lot, with the example that you gave me was enough to make my project running. Now everything is ok.
0 Kudos
Message 3 of 3
(3,768 Views)