Skip to content
/ usbtmc Public

Go library to communicate with a USB Test and Measurement Class (USBTMC) interface

License

Notifications You must be signed in to change notification settings

gotmc/usbtmc

Repository files navigation

usbtmc

Go library to communicate with a USB Test and Measurement Class (USBTMC) enabled USB device.

GoDoc Go Report Card Build Status License Badge

Overview

USBTMC is a USB device class specification for test equiment and instrumentation devices, such as oscilloscopes, digital multimeters, and function generators. USBTMC requires three endpoints:

  • Control endpoint
  • Bulk-OUT endpoint
  • Bulk-IN endpoint

Additionally, the USBTMC subclass USB488 has an Interrupt-IN endpoint.

This packages enables controlling USBTMC compatible test equipment (e.g., oscilloscopes, function generators, multimeters, etc.) over USB. While this package can be used by itself to send Standard Commands for Programmable Instruments (SCPI) commands to a piece of test equipment, it also serves to provide an Instrument interface for both the ivi and visa packages. The ivi package provides standardized APIs for programming test instruments following the Interchangeable Virtual Instrument (IVI) standard.

USBTMC Descriptors

  • Interface class = 0xFE (application-specific)
  • Interface subclass = 0x03 (indicates USBTMC)

Installation

$ go get github.com/gotmc/usbtmc

Usage

To use the usbtmc package, you must register which Go-based libusb interface library should be used. libusb is "a C library that provides generic access to USB devices." There are two Go-based libusb hardware interface libraries available:

You'll need to install one of the above libraries using:

$ go get -v github.com/google/gousb
$ go get -v github.com/gotmc/gotmc

To indicate which libusb interface library should be used, include one of the following blank imports:

import _ "github.com/gotmc/usbtmc/driver/google"
import _ "github.com/gotmc/usbtmc/driver/gotmc"

Documentation

Documentation can be found at either:

Contributing

Contributions are welcome! To contribute please:

  1. Fork the repository
  2. Create a feature branch
  3. Code
  4. Submit a pull request

Testing

Prior to submitting a pull request, please run the tests using either GNU Make:

$ make check
$ make lint

or you can use Just:

$ just check
$ just lint

To update and view the test coverage report using Make run:

$ make cover

or you can use Just:

$ just cover

Disclosure and Call for Help

While this package works, it does not fully implement the USBTMC specification. Please submit pull requests as needed to increase functionality, maintainability, or reliability.

License

usbtmc is released under the MIT license. Please see the LICENSE.txt file for more information.