LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to communicate libusb to labview program

Dear All,

Thank to all.

I am trying to communicate a device which is having libusb to LabVIEW. in the NI-Max also the device is not showing but computer is able to detect the device. 

Please, somebody can tell me how to communicate with Labview with libusb.  

0 Kudos
Message 1 of 6
(1,199 Views)

libusb is a low level C programming API. It comes in its compiled form as a shared library and that means you can access it from LabVIEW through the Call Library Node.

 

But, this is C programming, and while there have been many attempts by various people to create a LabVIEW binding for libusb, I'm not aware of any that is publically available beyond of minimal example of how it could be done.

 

Even if you have such a binding in the form of a LabVIEW library, you are far from done. libusb allows you to communicate with pretty much any USB device (if it has not been claimed by the OS already) but it doesn't know how to talk to your specific device. USB is basically just the cable and connector and some basic signalling. How you talk to a keyboard, a video camera, or a microphone are totally different and libusb doesn't give you ready made functions to use the specific features of any such device. It is just the lego bricks that allow you to write such functions IF you know the particular protocol you have to use for your device.

 

So based on your very generic question I can only give you very generic answers (which are questions again):

 

- Have you enough programming knowledge to interface to the libusb API? This requires fairly good basic C programming knowledge!

 

- What device are you talking about? What USB class does it implement? Are you willing to read a few 1000 pages of USB protocol descriptions? If it is not one of the standard USB classes but a proprietary one, do you have the protocol description of the manufacturer?

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 6
(1,172 Views)

Dear Rolf,

Thank you.

I used NI-visa wizard to communicate but it showing error. Device Product ID (PID) is 0x6001and vendor ID is 0x1FA4. 

0 Kudos
Message 3 of 6
(1,140 Views)

The NI VISA Wizard is NOT used to communicate to your device. The Wizard installs the device with the according product and device ID as a Raw USB device in NI-VISA.

 

First you have still not said what device it is. Depending on that you may be all the time already have barked up the wrong tree. Or maybe not but then the real fun is only just starting.

 

If you really have to talk with this device over raw USB then it gets VERY complicated. After you got the device installed as USB Raw, you have to know what pipe endpoints to address in which way, with interrupt or bulk transfers and all that stuff. This is part of the USB protocol specification for your device. If you do not know what a bulk or interrupt transfer in USB terms is and how they are related to each other, and what pipe endpoints mean, you are already lost here. USB is not a simple interface where you can write a text command to a device and hope it answers in a meaningful way. You have to put together bits and bytes into very specific binary data packages and send them to the right endpoint and then receive the answer on the correct channel and decode the bits and bytes into meaningful information.

 

Without a very good and through protocol description for your device, which most manufacturers would not even give out to you if you pointed a gun at their head, you can simply forget to go about talking to your device in this way. 

 

libusb is ANOTHER means to do exactly the same as with NI-VISA USB Raw and the same caveats apply there.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 6
(1,128 Views)

Dear Rolf,

Thank for your support.

I am using device is eMorpho multichannel analyzer made of Bridgeport company (https://www.bridgeportinstruments.com/products/pmt/emorpho.html).   

 

They have given a PID, VID and serial number. 

Rolf, can you help me to make a LabVIEW program to acquire the data and display in a graph. 

 

Thank you.

 

  

 

0 Kudos
Message 5 of 6
(1,099 Views)

According to their product data page the recommended way to use this hardware is NOT to try to call the libusb API they install but instead launch their MDS software server and connect to it through TCP/IP. The MDS software then handles the communication with the actual hardware device(s) and provides their data to any client requesting it through the network API. This network API is supposedly based on JSON strings, so should be fairly simple to implement.

 

The relevant parts about how to interface to the different hardware devices through libusb are hidden behind precompiled python modules. So while it would likely be possible to reverse compile them it is IMHO to much trouble to do.

 

Try to talk to the MDS service instead!

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 6
(1,090 Views)