Talk to an USB HID device from within GNU Octave

859 Views Asked by At

I need to control a measurement instrument from within GNU Octave. The instrument has an USB HID interface. I just need to read or change the settings of the instrument. It's not about getting measurement data from the instrument.

What options are there to do this from within GNU Octave, and how do they work?

1

There are 1 best solutions below

0
On

The simplest approach would be to use an already made Octave package (like the instrument-control package). Then you could check the documentation and read /write to and from a USB device.

The package linked above (and here again) has a USB TMC set of functions if the USB device works with this library. See the function list to find out how to use the package. As far as I am aware this package only works on Linux for USBTMC (according to the wiki).

Otherwise if you are not running Linux, or the device is not supported, I cannot specifically see any other already-written set of Octave functions for communication.

However, if you have the time it could be worth writing just a singular MEX (C/C++) function to open the communication channel and read settings from the device.

You could then make this work on Windows as well. Most of this functionality is already implemented in libraries such as signal11 (just to name one...), which that library itself is already cross-platform. Using that library inparticular makes it look like a very short MEX file to write.

I hope this helps and check out the links for further information about the topics discussed :)