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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB Control in Labview

Hi Sir, 

 

Could you give a samples for USB communication ?

a. sending the commands to usb device;

b. transfer files to usb device;

 

The precondition is that we can find the device in NI MAX, right ?

Thanks.

 

 

 

Brzhou_0-1679988505517.png

 

Learning from other people
0 Kudos
Message 1 of 10
(1,444 Views)

Depends. If the device can officially be integrated into the LabVIEW ecosphere, because it was bought from NI, then yes. If not, the device probably already comes with ready-to-use VIs that access a DLL that accesses the driver. Direct access to USB devices on driver level isn't usual.

 

Apart from that, how does the USB device in question presents itself to the system? As COM port, as HID, as what?

0 Kudos
Message 2 of 10
(1,438 Views)

The VISA USB palette was created more than 20 years ago. At that time there was no standard WinUSB or LibUSB available and OSes did happily let any user load device drivers at will that he wrote themselves, downloaded from some obscure or not so obscure site or got as installer on a device CD.

 

It was useful in very few cases but it was usable. You need to have the full programmer manual for the device that describes the actual protocol over the USB bus in terms of endpoints, and transfer modes (control, bulk, isochronous and interrupt). Most devices do NOT come with such a document and the manufacturer most often treats this information as trade secret.

 

In addition, Windows and Mac OS (and even Linux to some extent) and pretty much every other OS that is more than a hobby project, has strong restrictions on what device drivers it even will allow to be loaded. Currently they need to be signed with a code signing certificate that you as driver creator need to purchase and that costs anywhere from 150 to 500 dollar per year, depending what level and signing authority you choose.

 

And a VISA device driver is simply a device driver too even if the actual code itself is contained in the VISA software, the INF file that you generate to access your specific device is considered a device driver by Windows and needs to be signed too, before Windows will load it.

 

So the VISA USB control functions are a legacy feature that was at some time in some rare cases useful but nowadays pretty much just is there because it costs time and money to remove it from VISA.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 10
(1,400 Views)

Hi Sir,

 

Noted with thanks for the history.

 

Now for example, i have a smart watch with usb interface&RTOS or wearos.

Then do you know what method to communicate with them ? for wearos, i know, i can use ADB tool, but how about  RTOS ?

 

Thanks.

Learning from other people
0 Kudos
Message 4 of 10
(1,386 Views)

Not COM, how about HID ?

Thanks.

Learning from other people
0 Kudos
Message 5 of 10
(1,383 Views)

HID you would interface through the Windows HID.DLL (if you are on Windows). There is not much sense in trying to implement your own HID interface on top of NI VISA USB For one it is quite a bit of work, and second due to the signing requirements for device drivers also an extra hassle and investment.

 

As to if ADB would be the most advisable one for Wearos, I really don't know. It seems to be Android based, so yes ADB would seem like a viable choice but certainly not the only one. And again you don't really want to implement the ADB protocol on your own on top of NI VISA USB.

 

RTOS just as its name says simply is a Realtime OS. Which one of the many your device are using is not quite clear. Is it FreeRTOS, or maybe VxWorks, or rather QNX? What about Zephyr or ThreadX?

 

And while the naming you use most likely would indicate that you mean FreeRTOS, your question still can't be answered just like that. What protocols this device supports totally depends on the configuration the device developer chose when compiling the OS kernel for his device.

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

3 cases:

 

1. If it is USB HID, how to use labview for communication ? or other method to call the HID.dll ?

2. For ADB, I think we can just use labview system exec.vi to execute the commands in the ADB tool directory;

3. We use ARM Cortex+freeRTOS for our device, and it has a usb interface for commands and download FW.

 

Thanks very much.

Learning from other people
0 Kudos
Message 7 of 10
(1,340 Views)

1) There probably is a command line tool somewhere to do simple HID communication. I always used HID.DLL for that.

 

2) Indeed

 

3) There must be a command line tool to download firmware and such. Use that.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 10
(1,333 Views)

1)we could use labview call library function, right ?

3)  but normally for this kind of tool, need coding by c or c++, right ? and provided by  ? actually, I am thinking about how to do the test program and auto-control this.

 

Thanks.

 

Learning from other people
0 Kudos
Message 9 of 10
(1,325 Views)

1) Yes that is how you would need to interface to HID.DLL. And no I can't post code for this.

3) I thought you mentioned you already could download new firmware. There must be surely a tool for that. If it is callable as command line tool is an entirely different question of course. Most embedded controller toolchains should have something like that, however. Otherwise it would be like selling a car, but you need to acquire the wheels and steering wheel separately.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(1,320 Views)