Documentation
¶
Overview ¶
Package lxi provides a LAN eXtensions for Instrumentation (LXI) interface for controlling test equipment over Ethernet ports using SCPI commands. It implements the VISA LXI resource string format and serves as an instrument driver for the ivi and visa packages.
This package is part of the gotmc ecosystem. The visa package (github.com/gotmc/visa) defines a common interface for instrument communication across different transports (GPIB, USB, TCP/IP, serial). The asrl package provides the serial transport implementation. The ivi package (github.com/gotmc/ivi) builds on top of visa to provide standardized, instrument-class-specific APIs following the IVI Foundation specifications.
Devices are addressed using VISA resource strings of the form:
TCPIP<boardIndex>::<hostAddress>::<port>::SOCKET
For example:
TCPIP0::192.168.1.101::5025::SOCKET
Index ¶
- Variables
- type Device
- func (d *Device) Close() error
- func (d *Device) Command(ctx context.Context, cmd string, a ...any) error
- func (d *Device) Query(ctx context.Context, cmd string) (string, error)
- func (d *Device) Read(p []byte) (n int, err error)
- func (d *Device) ReadBinary(ctx context.Context, p []byte) (n int, err error)
- func (d *Device) Write(p []byte) (n int, err error)
- func (d *Device) WriteBinary(ctx context.Context, p []byte) (n int, err error)
- func (d *Device) WriteString(s string) (n int, err error)
- type VisaResource
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrResourceFormat = errors.New("visa: resource string does not match expected format") ErrInterfaceType = errors.New("visa: interface type was not TCPIP") ErrResourceClass = errors.New("visa: resource class was not SOCKET") ErrBoardIndex = errors.New("visa: board index error") ErrHostAddress = errors.New("visa: host address is required") ErrPort = errors.New("visa: port error") )
Sentinel errors returned by NewVisaResource.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
EndMark byte
// contains filtered or unexported fields
}
Device models an LXI device, which is currently just a TCPIP socket interface. An LXI Device implements the ivi.Transport interface.
func NewDevice ¶
NewDevice opens a TCPIP Device using the given VISA address resource string. The context controls the timeout/deadline for the TCP connection attempt.
func (*Device) Command ¶ added in v0.3.0
Command sends a SCPI/ASCII command to the underlying network connection. The command can be optionally formatted according to a format specifier. An endmark character, such as newline, is automatically added to the end of the string. The context deadline, if set, is applied to the underlying network connection.
func (*Device) Query ¶
Query writes the given SCPI/ASCII command to the underlying network connection and returns the response string. The device's endmark character (newline by default) is automatically added to the query command. The trailing endmark character is stripped from the response. The context deadline, if set, is applied to the underlying network connection for both the write and read operations.
func (*Device) ReadBinary ¶ added in v0.16.0
ReadBinary reads binary data from the network connection without terminator interpretation.
func (*Device) WriteBinary ¶ added in v0.16.0
WriteBinary writes binary data to the network connection without adding a terminator.
type VisaResource ¶
type VisaResource struct {
// contains filtered or unexported fields
}
VisaResource represents a VISA enabled piece of test equipment.
func NewVisaResource ¶
func NewVisaResource(resourceString string) (*VisaResource, error)
NewVisaResource creates a new VisaResource using the given VISA resourceString.
Example ¶
package main
import (
"fmt"
"log"
"github.com/gotmc/lxi"
)
func main() {
resource, err := lxi.NewVisaResource("TCPIP0::192.168.1.100::5025::SOCKET")
if err != nil {
log.Fatal(err)
}
fmt.Println(resource)
}
Output: TCPIP0::192.168.1.100::5025::SOCKET
func (*VisaResource) BoardIndex ¶ added in v0.12.0
func (v *VisaResource) BoardIndex() int
BoardIndex returns the VISA board index.
func (*VisaResource) HostAddress ¶ added in v0.12.0
func (v *VisaResource) HostAddress() string
HostAddress returns the hostname or IP address of the instrument.
func (*VisaResource) InterfaceType ¶ added in v0.12.0
func (v *VisaResource) InterfaceType() string
InterfaceType returns the VISA interface type (e.g., "TCPIP").
func (*VisaResource) Port ¶ added in v0.12.0
func (v *VisaResource) Port() int
Port returns the TCP port number of the instrument.
func (*VisaResource) ResourceClass ¶ added in v0.12.0
func (v *VisaResource) ResourceClass() string
ResourceClass returns the VISA resource class (e.g., "SOCKET").
func (*VisaResource) String ¶ added in v0.12.0
func (v *VisaResource) String() string
String returns the VISA resource string in canonical form.