Coder Social home page Coder Social logo

gotmc / usbtmc Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 5.0 127 KB

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

License: MIT License

Go 97.37% Makefile 1.27% Just 1.35%
usbtmc libusb usb-devices test-automation gousb scpi scpi-commands scpi-instrument scpi-instruments scpi-lab-instruments

usbtmc's Introduction

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.

usbtmc's People

Contributors

andrerenaud avatar lehmrob avatar matthewrankin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

usbtmc's Issues

regString error in visa.go

regString := ^(?P<interfaceType>[A-Za-z]+)(?P<boardIndex>\d*):: +
(?P<manufacturerID>[^\s:]+):: +
(?P<modelCode>[^\s:]+) +
(::(?P<serialNumber>[^\s:]+))? +
::(?P<resourceClass>[^\s:]+)$

there is some error in this regString, when parse the string USB0::0x0957::0x2007::MY57004760::0::INSTR

Segfault on context creation

A MWE:

package main

import (
	"log"

	"github.com/gotmc/usbtmc"
	_ "github.com/gotmc/usbtmc/driver/truveris"
)

func main() {
	ctx, err := usbtmc.NewContext()
	if err != nil {
		log.Fatal(err)
	}
	ctx.SetDebugLevel(1)
}

Output:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x49c9c0]

goroutine 1 [running]:
<>/vendor/github.com/gotmc/usbtmc.NewContext(0x4c92e0, 0x78a790, 0x0)
	/media/psf/Home/go/src/<>/vendor/github.com/gotmc/usbtmc/context.go:20 +0x70
main.main()
	/media/psf/Home/go/src/<>/cmd/ldctest/main.go:19 +0x26

This is without any of the other drivers installed. If I uninstall this driver and install another, I get the same segfault with the other two.

Eliminate calls to log.Fatal

Instead of calling log.Fatal(), return an error, so that the end-user's higher level application can decide how to handle.

Add libusb driver

Add a USBTMC driver (usbtmc/driver/libusb) for the github.com/gotmc/libusb Go-based libusb driver.

Don't read fixed size of 1024

In device.go the Read(p []byte) method uses a fixed length of 1024 to read the USBTMC bulk-in endpoint. Seems like I should refactor this.

Add google/gousb driver

Add USBTMC driver (usbtmc/driver/gousb) for the github.com/google/gousb Go-based libusb driver.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.