Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating with a usb camera with NI-VISA and LabWindows

I want to communicate with a USB camera using NI-VISA (4.4) and LabWindows CVI (8.0) under Windows (XP Professional).  I have tried 3 different cameras (Microsoft Lifecam, Logitech, ImagingSource) and I keep getting an error when trying to write a simple "*IDN?\n" request:  "(BFFF003A) Unable to start operation because setup is invalid (due to attributes being set to an inconsistent state)".

 

I have used the NI-VISA wizard to create .inf files, "installed" them,  and then with Windows device manager, used "update driver" to assign the NIVIUSBK.sys driver to the camera.  Every camera had to be defined as a composite USB device to be able to use "update driver".

 

According to the VISA Test Panel (NIMAX), attributes  are:

 

VI_ATTR_TMO_VALUE = 2000
VI_ATTR_MAX_QUEUE_LENGTH = 50
VI_ATTR_TERMCHAR = 0x0A
VI_ATTR_TERMCHAR_EN = VI_FALSE
VI_ATTR_IO_PROT = 1
VI_ATTR_SUPPRESS_END_EN = VI_FALSE
VI_ATTR_USB_MAX_INTR_SIZE = 16
VI_ATTR_USB_CTRL_PIPE = 0x0000
VI_ATTR_USB_BULK_OUT_PIPE = 0xFFFF
VI_ATTR_USB_BULK_IN_PIPE = 0xFFFF
VI_ATTR_USB_INTR_IN_PIPE = 0x0087
VI_ATTR_USB_ALT_SETTING = 0
VI_ATTR_USB_BULK_OUT_STATUS = -1
VI_ATTR_USB_BULK_IN_STATUS = -1
VI_ATTR_USB_INTR_IN_STATUS = 0
VI_ATTR_USB_END_IN = 5

 

Could the "inconsistent state" due to the fact that both bulk-in/out pipes are -1? If so, where did I go wrong ...  Any comment or suggestions ?

 

Thanks,

Richard 

 

0 Kudos
Message 1 of 5
(4,741 Views)

Hey Richard,

 

By looking at your instruments attributes, I can tell that your bulk-in/bulk-out pipes are in an unknown state (=-1). Why are you creating the .inf as a composite device? I don't think this is correct. Try and recreate the .inf file without setting the composite device option.

 

I also need to set the expectation that even though we can probably get this device to work, not all devices will be recognized by VISA. But I will try and assist you to get at least one of these cameras identified.

 

Thanks,

Ryan

National Instruments
Applications Engineer
0 Kudos
Message 2 of 5
(4,729 Views)

Hey Ryan,

 

Thanks for your reply.  I created the .inf file as a composite USB device for two reasons.

 

First, two of my cameras have microphones (they're web cams) and when I plug in a camera, it shows in "device manager" under "imaging devices - USB video device", "Sound, video and game controllers - USB audio device", and "Universal serial bus controllers - USB Composite device".  So that made sense to me to have separate interfaces for the camera and the mic.  The third camera (Imaging source) doesn't have a mic and shows under "imaging devices - USB video device" and also under "Universal serial bus controllers - USB Composite device".

 

The second reason is that that was the only way I could install the driver without errors.  If I use a regular .inf file (for the camera with no mic),  then I get an error (device can not start - code 10) when I "update" the driver (whether I click on the "imaging device" entry or the "composite device" entry) . There is also a yellow exclamation mark next to the device (in device manager) in NIMAX does not see the device at all.

 

Richard 

0 Kudos
Message 3 of 5
(4,726 Views)

 

Hey Richard,

 

It makes more sense now. Because your camera is composite (a single USB device supporting multiple interfaces where each interface acts independently), there might be a few more things we can try.

 

1) Are there any firmware revisions that come with the device for single operation? (not composite)

2) When creating the .inf file, did you select "Compound Device" as shown in the screenshot below?

 

visawiz.JPG

 

Also after some research on the web I found that in order to recognize a Composite Device you will have to set

the bDeviceClass entry and the bDeviceSubClass entry in the Device Descriptor to 0.

The customer should be prepared to dig into the files that where created and quite possibly change some of the settings.

More notes on this device descriptor can be found here.

 

I also found another issue similar to this. In this case the descriptors had to be changed.

 

The problem was:
The Driver-Wizard assigned ONE name for three interfaces.


You can see this:

[Strings]

Vendor0="My Device Producer"

Vendor1="My Device Producer"

USB\VID_FFFE&PID_001A&MI_00.DeviceDesc="My device"

USB\VID_FFFE&PID_001A&MI_01.DeviceDesc="My device"

USB\VID_FFFE&PID_001A&MI_02.DeviceDesc="My device"

DeviceClassString="NI-VISA USB Devices"

NIVIUSBK.SvcDesc="NI-VISA USB Driver"

 

"My device" hast to be inserted in "Model Name".

The customer changes these names:

 

USB\VID_FFFE&PID_001A&MI_00.DeviceDesc="LLRF4 Board Command and Status Path"

USB\VID_FFFE&PID_001A&MI_01.DeviceDesc="LLRF4 Board Transmit Path"

USB\VID_FFFE&PID_001A&MI_02.DeviceDesc="LLRF4 Board Receive Path"

 

After this, everything works fine.

 

Let me know how it goes,

 

Ryan

 

National Instruments
Applications Engineer
0 Kudos
Message 4 of 5
(4,712 Views)

Hi Ryan,

 

There are no firmware revisions that I know of, and I do check the "compound device" box when creating the .inf file.  I don't think I can set values for bDeviceClass and bDeviceSubclass in the device descriptor (my understanding is that this information is sent to the host by the device, i.e. it is set in firmware).

 

I did manually change the names of the interfaces in the .inf file before "installing" them but that did not help.

 

I used UVCView to inspect the device descriptor and other info and I found out that 2 of my cameras (the composite devices) use the isochronous endpoint (not supported by NI-VISA) rather than the BULK transfer; so that won't work.  The third camera (camera only, no mic) does use the BULK-IN endpoint, but somehow it does not seem to be recognized by the NIVISA driver since NIMAX still shows the BULK-IN PIPE as being -1.

 

Conclusion: Unfortunately, I don't think we can use LabWindows and NI-VISA.  We will have to migrate to Visual Studio and the .NET environment, for which most camera manufacturers provide APIs.

 

Anyway, I just wanted to keep you posted.

 

Thanks a lot for your help.

 

Richard 

0 Kudos
Message 5 of 5
(4,690 Views)