instr

package
v0.1.1-0...-4026904 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Lf eol = iota
	Cr
	CrLf
	LfCr
	None
)

Character constants for line terminators

View Source
const (
	OFF = iota
	DC
	AC
	GND
	HfReject
	LfReject
	NoiseReject
)

Coupling constants are normal scope types

Variables

This section is empty.

Functions

func CheckSerialPort

func CheckSerialPort(port string) error

CheckSerialPort takes a serial port name and test if it exists and are not used already. It returns nil if the port is ok, and an error message if not

func EnumerateSerialPorts

func EnumerateSerialPorts() ([]string, []string, error)

EnumerateSerialPorts will return a list of port names and a list of descriptions

func FindSerialPort

func FindSerialPort(id string, baudrate int, eol eol) string

FindSerialPort will return the name of the last (highest numbered) serial port that is not in use already

func SetupDiDestroyDeviceInfoList

func SetupDiDestroyDeviceInfoList(DeviceInfoSet DevInfo) (err error)

func SetupDiEnumDeviceInfo

func SetupDiEnumDeviceInfo(DeviceInfoSet DevInfo, MemberIndex int, data *DevInfoData) (err error)

SetupDiEnumDeviceInfo function returns a SP_DEVINFO_DATA structure that specifies a device information element in a device information set.

func SetupDiGetDeviceRegistryProperty

func SetupDiGetDeviceRegistryProperty(deviceInfoSet DevInfo, deviceInfoData *DevInfoData, property SPDRP) (value interface{}, err error)

SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.

func TimeToStr

func TimeToStr(t float64) string

TimeToStr will return a string with sec/ms/uS/nS units

func ToString

func ToString(buf []byte) string

ToString converts a byte array to string and strips invalid characters

func VoltToStr

func VoltToStr(v float64) string

VoltToStr will return a voltage with V/mV/uV units

Types

type Chan

type Chan int

Chan is used for channel numbers. Note that Channel 1 is number 1 (the Ch1 constant).

const (
	TRIG Chan = iota
	Ch1
	Ch2
	Ch3
	Ch4
	Ch5
	EXT
	EXT5
	EXT10
	MAINS
)

Channel constants

type Connection

type Connection struct {
	Port     string
	Eol      eol           // Command string terminator
	Timeout  time.Duration // Timeout on read operations
	Baudrate int           // Baudrate for serial ports
	Name     string        // Identifier read from the instrument by *IDN? or similar
	// contains filtered or unexported fields
}

Connection contains the local data for the connection to an instrument.

func (*Connection) Ask

func (i *Connection) Ask(query string, args ...interface{}) (string, error)

Ask will query the instrument for a string response

func (*Connection) Close

func (i *Connection) Close()

Close will close a connection already opened

func (*Connection) Flush

func (i *Connection) Flush()

Flush will empty the read queue

func (*Connection) Open

func (i *Connection) Open(portName string) error

Open will open a connection defined by portName The parameter is a TCP/IP address or a com port name

func (*Connection) PollFloat

func (i *Connection) PollFloat(query string, args ...interface{}) (float64, error)

PollFloat will read a float64 value

func (*Connection) QueryIdn

func (i *Connection) QueryIdn() (string, error)

QueryIdn will read the instrument identification string It uses *IDN? which most instruments implement

func (*Connection) Read

func (i *Connection) Read(b []byte) int

ReadBinary will return an array of bytes

func (*Connection) ReadByte

func (i *Connection) ReadByte() byte

ReadByte will return a single byte

func (*Connection) ReadString

func (i *Connection) ReadString() string

ReadString will read any response from the instrument, with given timeout

func (*Connection) SetTimeout

func (i *Connection) SetTimeout(t time.Duration)

SetTimeout sets the read timeout

func (*Connection) Write

func (i *Connection) Write(s string, args ...interface{}) error

Write will send a commend to the instrument, adding end of line characters

type Coupling

type Coupling int

Coupling is for oscilloscope prope coupling

type DIGCF

type DIGCF uint32

DIGCF flags controll what is included in the device information set built by SetupDiGetClassDevs

const (
	DIGCF_DEFAULT         DIGCF = 0x00000001 // only valid with DIGCF_DEVICEINTERFACE
	DIGCF_PRESENT         DIGCF = 0x00000002
	DIGCF_ALLCLASSES      DIGCF = 0x00000004
	DIGCF_PROFILE         DIGCF = 0x00000008
	DIGCF_DEVICEINTERFACE DIGCF = 0x00000010
)

type DevInfo

type DevInfo windows.Handle

DevInfo holds reference to device information set

func SetupDiGetClassDevsEx

func SetupDiGetClassDevsEx(ClassGUID *windows.GUID, Enumerator string, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName string) (handle DevInfo, err error)

SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer.

func (DevInfo) Close

func (h DevInfo) Close() error

Close function deletes a device information set and frees all associated memory.

type DevInfoData

type DevInfoData struct {
	ClassGUID windows.GUID
	DevInst   uint32 // handle
	// contains filtered or unexported fields
}

DevInfoData is a device information structure (references a device instance that is a member of a device information set)

type Dmm

type Dmm interface {
	Close()
	Configure(setup Setup) error
	Measure() (float64, error)
	QueryIdn() (string, error)
}

Dmm is the interface for a digital multilmeter

type EngUnit

type EngUnit int

EngUnit defines the engineering unit of a measurement

const (
	Illegal EngUnit = iota
	VoltDc
	VoltAcRms
	VoltAcAvg
	CurrentDc
	CurrentAcRms
	CurrentAcAvg
	Hz
	Ohm
	Celcius
)

type Psu

type Psu interface {
	SetOutput(c Chan, voltage float64, current float64) error
	GetOutput(c Chan) (float64, float64, error)
	GetSetpoint(c Chan) (float64, float64, error)
	Disable(c Chan)
	QueryIdn() (string, error)
	Close()
	ChannelCount() int
}

Psu is a generic power supply interface

type SPDRP

type SPDRP uint32
const SPDRP_FRIENDLYNAME SPDRP = 0x0000000C // FriendlyName (R/W)

type SampleMode

type SampleMode int

SampleMode indicates the decimation mode going from the raw sampling interval to the time between stored samples

const (
	// MinMax uses two samples for the minimum or  maximum sample values
	MinMax SampleMode = iota
	// Sample uses a single sample for each sample interval
	Sample
	// Average will average all samples in the sample interval
	Average
)

type Scope

type Scope interface {
	// GetName will return the *IDN? string
	QueryIdn() (string, error)
	// DisableChannel will turn off channel (will no longer be sampled or returned by Curve())
	DisableChannel(ch Chan)
	// SetupChannel where rng is 10*volt/div
	SetupChannel(ch Chan, rng float64, offset float64, coupling Coupling) error
	// GetChanInfo is..
	GetChanInfo() []string
	// SetupTime will set sampling time and offset
	// sample time is typicaly timePrDiv/samplesPrDiv or f.ex. 10e-6/250 for 10uS/div
	// mode is
	SetupTime(sampleTime float64, offs float64, sampleMode SampleMode, sampleCount int) error
	// SetupTrigger will set main trigger parameters
	SetupTrigger(sourceChan Chan, coupling Coupling, slope Slope, trigLevel float64, auto bool, xPos float64) error
	// Measure data on channel. Type may vary, typical FREQUENCY, CRMS etc
	Measure(ch Chan, typ string) (float64, error)
	// Return the data points for a single scan on selected channels
	GetSamples() ([][]float64, error)
	// GetTime will return horizontal settings
	GetTime() (sampleIntervalSec float64, xPosSec float64)
	// Close will close communication channel
	Close()
	// ChannelCount is the maximum number of channels on this instrument
	ChannelCount() int
}

Scope is an oscilloscope definition

type Setup

type Setup struct {
	Chan       Chan
	Unit       EngUnit
	Range      string
	Resolution float64
	Rate       float64
}

type Slope

type Slope int

Slope is the trigger slope

const (
	Rising Slope = iota
	Falling
	Either
)

Slope types are rising/falling or either edge

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL