USB::TMC - Perl interface to USBTMC Test&Measurement backend.
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};
This module provides a user-space USBTMC driver based on USB::LibUSB.
Errors with USB transfers are handled internally and are handled with croak.
Use default timeout if timeout arg is not given.
timeout
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 );
$usbtmc->write(data => $data, timeout => $timeout);
Do DEV_DEP_MSG_OUT transfer.
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".
my $data = $usbtmc->query(data => $data, length => $read_length, timeout => $timeout);
Send a query command and read the result.
my $capabilites = $usbtmc->get_capabilities(timeout => $timeout);
Do GET_CAPABILITIES request.
The $capabilities hash contains the following keys:
$capabilities
To install USB::TMC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm USB::TMC
CPAN shell
perl -MCPAN -e shell install USB::TMC
For more information on module installation, please visit the detailed CPAN module installation guide.