05-25-2010 09:30 AM
Thank you for your help,but there is error too
the code bellow:
int CVICALLBACK Cofig(int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
ViUInt16 RcCount;
ViUInt8 RcCounteel;
ViStatus STATUS;
ViSession USB_INICIO;
ViString identificador_usb = "USB0::0x10C4::0x0000::NI-VISA-0::RAW";
ViFindList findList;
ViUInt32 numInstrs;
char instrDescriptor[256];
ViSession USB_FIND;
ViEventType tipoEvento=-5;
ViEvent evento;
unsigned char bufferLido[50];
ViUInt16 tamanhoBufferLeitura=5;
ViUInt32 contLei;
switch (event)
{
case EVENT_COMMIT:
STATUS = viOpenDefaultRM (&USB_INICIO);
if(STATUS != VI_SUCCESS)
{
MessagePopup("ATEN??O","N?o foi possivel abrir a viOpenDefaultRM");
break;
}
STATUS = viFindRsrc (USB_INICIO, identificador_usb, &findList, &numInstrs, instrDescriptor);
if(STATUS != VI_SUCCESS)
{
MessagePopup("ATEN??O","N?o foi possivel abrir a viFindRsrc");
QuitUserInterface (0); // for?a o fechamento do programa
};
STATUS = viOpen (USB_INICIO, &instrDescriptor[0], VI_NULL, VI_NULL, &USB_FIND);
viSetAttribute(USB_FIND,VI_ATTR_MAX_QUEUE_LENGTH,100);
if(STATUS != VI_SUCCESS)
{
MessagePopup("ATEN??O","N?o foi possivel abrir a VI_ATTR_MAX_QUEUE_LENGTH ");
QuitUserInterface (0); // for?a o fechamento do programa
};
viSetAttribute(USB_FIND,VI_ATTR_USB_MAX_INTR_SIZE,64);
if(STATUS != VI_SUCCESS)
{
MessagePopup("ATEN??O","N?o foi possivel abrir a VI_ATTR_USB_MAX_INTR_SIZE ");
QuitUserInterface (0); // for?a o fechamento do programa
} ;
STATUS = viEnableEvent (USB_FIND, VI_EVENT_USB_INTR, VI_QUEUE, VI_NULL);
while (tipoEvento!=VI_EVENT_USB_INTR)
{
STATUS = viWaitOnEvent (USB_FIND, VI_EVENT_USB_INTR, 50, &tipoEvento, &evento);
}
STATUS = viGetAttribute (evento, VI_ATTR_USB_RECV_INTR_DATA,&RcCounteel);
SetCtrlVal(panelHandle,PANEL_Outdata,RcCounteel);
STATUS = viGetAttribute (evento, VI_ATTR_USB_RECV_INTR_SIZE, &RcCount);
SetCtrlVal(panelHandle,PANEL_NUMERIC,RcCount);
STATUS = viRead (USB_FIND, bufferLido, tamanhoBufferLeitura,&contLei);
SetCtrlVal(panelHandle,PANEL_TEXTBOX,bufferLido);
SetActiveCtrl(panelHandle,PANEL_TEXTBOX );
STATUS = viClose (USB_FIND);
STATUS = viClose (USB_INICIO);
break;
}
return 0;}