From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i program a usb interface using ni-visa

I have a feeling that FF6 has some nulls in the middle of it. Is that character in the [1] index a 0? 

This Discussion Forum discusses has some suggestions, this is a basic tenant of C programing.
-Marshall R
0 Kudos
Message 11 of 15
(1,342 Views)
Thanks a lot that was the problem and i did not notice before, the 2nd byte on the string is a cero, so that´s why it only shows the 1st byte fo the string. Your support have been excellent.





0 Kudos
Message 12 of 15
(1,321 Views)
Hi Marshall now i have another problem with respect the data Type.I read some attributes from my device but the problem comes when I want to show them on the pront panel of the user interface because the commands need a diferente type of values. For example when i use this function:  viGetAttribute (instrument, VI_ATTR_USB_BULK_OUT_PIPE, &bulkoutpipe); i can only put the name of the variable that i will use to save the value of the data, and by default this variable is an integer (teh program uses ViInt16) and till here is ok, i got the value from my device with any problem, but now the next step is display this value on the user interface using a text box and i have to use the next command:      InsertListItem (panelHandle, PANEL_CONFIG, 1, bulkoutpipe, bulkoutpipe); but here by default the variable to show is a character array and i can not select another type of variable, so when i run the program i got the message error that says: Type error in argument 4 to 'InsertListItem';found 'ViInt16' expected 'pointer to const char'
Here is the code in the function where i have the problem:
 
int CVICALLBACK GetConfig (int panel, int control, int event,void *callbackData, int eventData1, int eventData2)
{
// char bulkoutpipe[256];
 ViInt16 bulkoutpipe;
 ViChar name[256];
 unsigned char idnresult[72];
 ViUInt32 retcount;
 
 switch (event)
  {
  case EVENT_COMMIT:
    DeleteListItem (panelHandle, PANEL_CONFIG, 0, -1);
    viGetAttribute (instrument, VI_ATTR_RSRC_NAME, name);
       InsertListItem (panelHandle, PANEL_CONFIG, 0, name, 0);
    viGetAttribute (instrument, VI_ATTR_USB_BULK_OUT_PIPE, &bulkoutpipe);
  
  
  //  viGetAttribute (instrument, VI_ATTR_USB_BULK_IN_PIPE, &bulkinpipe);
    InsertListItem (panelHandle, PANEL_CONFIG, 1, bulkoutpipe, bulkoutpipe);
   
   
    //viGetAttribute (instrument, VI_ATTR_USB_BULK_IN_PIPE, &bulkinpipe[0]);
          
   
  //  viWrite (instrument, "*IDN?\n", 6, &retcount);
  //  viRead (instrument, idnresult, 72, &retcount);
  //  InsertListItem (panelHandle, PANEL_CONFIG, 1, idnresult, 0);
      
    SetCtrlAttribute (panelHandle, PANEL_SAVE, ATTR_DIMMED, 1); //enable the button SAVE 
   break;
  case EVENT_RIGHT_CLICK:
   break;
  }
 return 0;
}
 
 
 
Can you help me again please?. Thanks , bye
0 Kudos
Message 13 of 15
(1,318 Views)
I believe the command you are looking for is sprintf, I will refer you to the CVI help as to how to properly use the command since there are various formats you can choose from. I would highly recommend checking this resource in the future as it is very well written and helpful for gaining a simple understanding of the commands available in CVI
-Marshall R
0 Kudos
Message 14 of 15
(1,303 Views)
Ok, thanks for all your help, your support was very good 🙂 .
 
Bye
0 Kudos
Message 15 of 15
(1,255 Views)