Documentation
¶
Overview ¶
Package nanovna provides a Go API for communicating with and controlling NanoVNA devices over a serial (USB) connection. It enables device discovery, configuration, data acquisition, calibration management, and device information retrieval.
Index ¶
- func ListDevices() ([]string, error)
- type CalibrationData
- type CommandSet
- type Device
- func (d *Device) Close() error
- func (d *Device) DetectVersion() (string, error)
- func (d *Device) GetCalibration() (CalibrationData, error)
- func (d *Device) GetCapabilities() HardwareCapabilities
- func (d *Device) GetFrequencyRange() FrequencyRange
- func (d *Device) GetHardwareInfo() HardwareInfo
- func (d *Device) GetHardwareVariant() HardwareVariant
- func (d *Device) GetInfo() (DeviceInfo, error)
- func (d *Device) GetMaxSweepPoints() int
- func (d *Device) GetPortConfig() *PortConfig
- func (d *Device) GetPortDetails() string
- func (d *Device) GetPortHandle() SerialPort
- func (d *Device) GetSupportedPorts() []string
- func (d *Device) GetVersion() string
- func (d *Device) IsPortSupported(port string) bool
- func (d *Device) LoadCalibration(slot int) error
- func (d *Device) RunSweep() (SweepData, error)
- func (d *Device) SaveCalibration(slot int) error
- func (d *Device) SetCalibration(cal CalibrationData) error
- func (d *Device) SetPortHandle(sp SerialPort)
- func (d *Device) SetSweepConfig(startHz, stopHz int, points int) error
- type DeviceInfo
- type FrequencyRange
- type HardwareCapabilities
- type HardwareInfo
- type HardwareVariant
- type PortConfig
- type SerialPort
- type SweepData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListDevices ¶
ListDevices lists available NanoVNA serial ports (Windows only, stub).
Types ¶
type CalibrationData ¶
type CalibrationData struct {
}
CalibrationData holds calibration coefficients and metadata.
type CommandSet ¶
type CommandSet struct {
SweepCommand string
FreqCommand string
DataCommand string
InfoCommand string
VersionCommand string
CalibrationSave string
CalibrationLoad string
PromptPattern string
}
CommandSet defines the command set for different hardware variants.
type Device ¶
type Device struct {
Port string
// contains filtered or unexported fields
}
Device represents a connection to a NanoVNA device.
func AutoDetect ¶
AutoDetect attempts to find and connect to a NanoVNA device automatically.
func Open ¶
func Open(port string, custom ...SerialPort) (*Device, error)
Open connects to a NanoVNA on the specified serial port. Optionally accepts a custom SerialPort for debug/testing.
func OpenWithVariant ¶
func OpenWithVariant(port string, variant HardwareVariant) (*Device, error)
OpenWithVariant opens a device and forces a specific hardware variant (useful for testing or when auto-detection fails)
func (*Device) DetectVersion ¶
DetectVersion detects the NanoVNA version by sending CR and analyzing the response
func (*Device) GetCalibration ¶
func (d *Device) GetCalibration() (CalibrationData, error)
GetCalibration retrieves current calibration data.
func (*Device) GetCapabilities ¶
func (d *Device) GetCapabilities() HardwareCapabilities
GetCapabilities returns the hardware capabilities.
func (*Device) GetFrequencyRange ¶
func (d *Device) GetFrequencyRange() FrequencyRange
GetFrequencyRange returns the supported frequency range for this hardware.
func (*Device) GetHardwareInfo ¶
func (d *Device) GetHardwareInfo() HardwareInfo
GetHardwareInfo returns the hardware information and capabilities.
func (*Device) GetHardwareVariant ¶
func (d *Device) GetHardwareVariant() HardwareVariant
GetHardwareVariant returns the detected hardware variant.
func (*Device) GetInfo ¶
func (d *Device) GetInfo() (DeviceInfo, error)
GetInfo retrieves device information (model, firmware, serial number).
func (*Device) GetMaxSweepPoints ¶
GetMaxSweepPoints returns the maximum number of sweep points supported.
func (*Device) GetPortConfig ¶
func (d *Device) GetPortConfig() *PortConfig
GetPortConfig returns the port configuration details (for debugging).
func (*Device) GetPortDetails ¶
GetPortDetails returns detailed port information as a formatted string.
func (*Device) GetPortHandle ¶
func (d *Device) GetPortHandle() SerialPort
GetPortHandle returns the underlying serial port (for debug wrapping).
func (*Device) GetSupportedPorts ¶
GetSupportedPorts returns the supported S-parameter ports.
func (*Device) GetVersion ¶
GetVersion returns the detected NanoVNA version.
func (*Device) IsPortSupported ¶
IsPortSupported checks if a specific S-parameter port is supported.
func (*Device) LoadCalibration ¶
LoadCalibration loads calibration data from device memory.
func (*Device) RunSweep ¶
RunSweep triggers a sweep and returns measurement data. Uses hardware-specific commands and handles different port configurations.
func (*Device) SaveCalibration ¶
SaveCalibration saves calibration data to device memory.
func (*Device) SetCalibration ¶
func (d *Device) SetCalibration(cal CalibrationData) error
SetCalibration applies calibration data.
func (*Device) SetPortHandle ¶
func (d *Device) SetPortHandle(sp SerialPort)
SetPortHandle allows replacing the underlying serial port (for debug wrapping)
type DeviceInfo ¶
DeviceInfo contains information about the NanoVNA device.
type FrequencyRange ¶
FrequencyRange defines the frequency range for a hardware variant.
type HardwareCapabilities ¶
type HardwareCapabilities struct {
HasS21 bool
HasTimeDomain bool
HasCalibration bool
HasMultiplePorts bool
HasGenerator bool
HasSpectrumMode bool
}
HardwareCapabilities defines what each hardware variant can do.
type HardwareInfo ¶
type HardwareInfo struct {
Variant HardwareVariant
FrequencyRange FrequencyRange
MaxSweepPoints int
SupportedPorts []string // S11, S21, S12, S22
CommandSet CommandSet
Capabilities HardwareCapabilities
}
HardwareInfo contains hardware-specific information and capabilities.
type HardwareVariant ¶
type HardwareVariant int
HardwareVariant represents different NanoVNA hardware versions.
const ( VariantUnknown HardwareVariant = iota VariantV1 // Original NanoVNA v1 VariantVH // NanoVNA-H (Hardware version) VariantV2 // NanoVNA v2 (SAA2) VariantV2Plus // NanoVNA v2 Plus VariantV2Plus4 // NanoVNA v2 Plus4 VariantSAA2 // Standalone SAA2 VariantTinysa // TinySA variant VariantLiteVNA // LiteVNA variant )
func (HardwareVariant) String ¶
func (hv HardwareVariant) String() string
String returns the string representation of the hardware variant.
type PortConfig ¶
type PortConfig struct {
Name string
Baud int
ReadTimeout time.Duration
Size byte
Parity serial.Parity
StopBits serial.StopBits
}
PortConfig holds serial port configuration details for debugging.
type SerialPort ¶
SerialPort is the interface for serial port operations (exported for debug wrapping).
type SweepData ¶
type SweepData struct {
Frequencies []float64
S11 []complex128
S21 []complex128
}
SweepData holds measurement data from a sweep.