The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

USB::TMC - Perl interface to USBTMC Test&Measurement backend.

SYNOPSIS

 use USB::TMC;

 # Open usb connection to  Agilent 34410A digital multimeter
 my $usbtmc = USB::TMC->new(vid => 0x0957, pid => 0x0607,
                         serial => 'MY47000419' # only needed if vid/pid is ambiguous
 );
 
 $usbtmc->write(data => "*CLS\n");
 $usbtmc->write(data => "VOLT:NPLC 10\n");

 print $usbtmc->query(data => ":read?\n", length => 100);
 
 my $capabilities = $usbtmc->get_capabilities();
 my $support_term_char = $capabilities->{support_term_char};

DESCRIPTION

This module provides a user-space USBTMC driver based on USB::LibUSB.

METHODS

Errors with USB transfers are handled internally and are handled with croak.

Use default timeout if timeout arg is not given.

new

 my $usbtmc = USB::TMC->new(
     vid => $vid,
     pid => $pid,
     serial => $serial, # optional
     reset_device => 0, # default: do device reset
     debug_mode => 1,   # print lots of debug messages
     libusb_log_level => LIBUSB_LOG_LEVEL_DEBUG,
     term_char => "\n", # Stop a read request if the term_char occurs in the
                        # byte stream. Default: do not use term char.
     timeout => 10,     # timeout in seconds. default: 5
 );

write

 $usbtmc->write(data => $data, timeout => $timeout);

Do DEV_DEP_MSG_OUT transfer.

read

 my $data = $usbtmc->read(length => $read_length, timeout => $timeout);

Do REQUEST_DEV_DEP_MSG_IN and DEV_DEP_MSG_IN transfers.

Typically you will not need this method and only use "query".

query

 my $data = $usbtmc->query(data => $data, length => $read_length, timeout => $timeout);

Send a query command and read the result.

get_capabilities

 my $capabilites = $usbtmc->get_capabilities(timeout => $timeout);

Do GET_CAPABILITIES request.

The $capabilities hash contains the following keys:

bcdUSBTMC
listen_only
talk_only
accept_indicator_pulse
support_term_char