gecko-systems:gecko3com:installing_linux

Install Linux driver

Kernel 2.6.28 and newer are buggy! The usbtmc driver that is built in the kernel does not work!

Please follow the instructions here and install the older usbtmc driver.

Some of the scripts found in the original driver distribution are incomplete, please download and start with this slightly modified version of the drivers and scripts .

The original version can still be found here:

http://www.home.agilent.com/agilent/redirector.jspx?action=ref&lc=eng&cc=US&nfr=&ckey=1353201&cname=AGILENT_EDITORIAL

Original driver manual:
http://www.home.agilent.com/upload/cmc_upload/All/usbtmc.html

The installation instructions on the driver manual are good but need a few adjustments for an easy use and to get them work on newer kernels.

1. Copy the driver's TAR archive (usbtmc.tar) to an empty directory, change to that directory and extract the files using:

tar -xvf usbtmc.tar

This will extract a number of files in the directory, including the driver source files and a makefile.

2. Compile the driver using that makefile:

make
Note: As a prerequisite, you need the kernel headers to be installed on your system. It is usually available on your distribution's media but often not installed by default. Usually the following command will do the job:
sudo apt-get install linux-headers-$(uname -r)

3. make will create a kernel object file, usbtmc.ko. This kernel module can be installed dynamically (in the running kernel) using the insmod command (with root privilege). Next, the device files under /dev need to be created. You can do all this manually if you prefer, but the usbtmc_load script does it for you. Run it as follows:

sudo ./usbtmc_load

4. There is an additional utility named usbtmc_ioctl for special instrument operations such as device clear (see below for more information). Compile is using the command:

gcc usbtmc_ioctl.c -o usbtmc_ioctl

5. Plug in a USBTMC device and do some testing with your new compiled driver to see if it works as expected. For example use commands like that to see if your device was detected and is accessible (do this as unprivileged user):

dmesg
cat /dev/usbtmc0
echo "*idn?" > /dev/usbtmc1
cat /dev/usbtmc1

6. Great, we can work now with our device but we have to repeat the steps 3 after every restart and only root can do it. So do some more steps to make it automatic. First we replace the original usbtmc kernel module with our own:

sudo mv /lib/modules/$(uname -r)/kernel/drivers/usb/class/usbtmc.ko usbtmc.ko.orig
sudo cp usbtmc.ko /lib/modules/$(uname -r)/kernel/drivers/usb/class/

7. Install the usbtmc_ioctl and usbtmc_load tool:

cp usbtmc_ioctl usbtmc_load /usr/local/bin/

8. Create an init script that executes usbtmc_load during boot and add it to your boot sequence (I show here only the how to do it on Debian based distributions. Check your distribution manual how to do it on your system):

Download this file (usbtmc_init.tar), extract it and copy it into /etc/init.d/:

sudo cp usbtmc_init /etc/init.d

Make script executable:

sudo chmod +x /etc/init.d/usbtmc_init

Then add it to your boot sequence:

sudo update-rc.d usbtmc_init defaults

9. Reboot your machine, plug in your USBTMC device and test it again as under step 5.

As in the installation manual above, for simple tasks you can access your USBTMC device directly from the command line with the echo and cat commands. For example like this:

echo "*idn?" > /dev/usbtmc1
cat /dev/usbtmc1

The other way is to access the device files in /dev/usbtmc* with your programming language of choice in the same way you would access any other file. In the driver manual are examples for C.

The commands you can use with your device are specified in the manual that comes with your device. There is a mandatory subset but anything else is device dependent. Here you can find the GECKO3COM Command Reference.

For a command reference for the usbtmc_ioctl tool go to the driver manual homepage:
Reference: usbtmc_ioctl

Download and install (standard installation with restart) the NI-VISA Runtime Engine:

  • gecko-systems/gecko3com/installing_linux.txt
  • Last modified: 2021/12/20 10:49
  • (external edit)