Documentation
¶
Overview ¶
Package pttdevice enumerates serial ports, GPIO chips, and CM108 HID devices that can be used for push-to-talk control.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotGpioChip = errors.New("not a gpiochip device")
ErrNotGpioChip is returned by EnumerateGpioLines when the supplied path exists but is not a GPIO character device (e.g., a serial tty). Callers map this to a 400 rather than a 500: the caller supplied a bad path.
Functions ¶
func SetModemPath ¶
func SetModemPath(_ string)
SetModemPath is a no-op on Linux where CM108 enumeration uses sysfs directly. Non-linux platforms store this for modem shell-out enumeration.
Types ¶
type AvailableDevice ¶
type AvailableDevice struct {
Path string `json:"path"`
Type string `json:"type"` // serial, gpio, cm108
Name string `json:"name"`
Description string `json:"description"` // human-friendly label (USB product, GPIO chip)
USBVendor string `json:"usb_vendor,omitempty"`
USBProduct string `json:"usb_product,omitempty"`
// Recommended is true for the device path users should prefer. On macOS
// we recommend /dev/cu.* over /dev/tty.* (which blocks until DCD).
Recommended bool `json:"recommended"`
// Warning is set when there's a known gotcha with this path.
Warning string `json:"warning,omitempty"`
}
AvailableDevice describes a detected PTT-capable device.
func Enumerate ¶
func Enumerate() []AvailableDevice
Enumerate returns all detected PTT-capable devices on the host.
type GpioLineInfo ¶
type GpioLineInfo struct {
// Offset is the 0-indexed line offset within the chip.
Offset uint32 `json:"offset"`
// Name is the kernel-assigned line name. May be empty if the line is
// unnamed on this chip.
Name string `json:"name"`
// Consumer is the label of the driver currently holding the line, if any.
Consumer string `json:"consumer,omitempty"`
// Used is true when another driver has claimed this line (e.g. SPI, I2C,
// UART, or a previously-running graywolf process).
Used bool `json:"used"`
}
GpioLineInfo describes a single GPIO line on a gpiochip character device. Returned by EnumerateGpioLines; consumed by the PTT web API to populate the GPIO line selector in the UI.
func EnumerateGpioLines ¶
func EnumerateGpioLines(chipPath string) ([]GpioLineInfo, error)
EnumerateGpioLines opens the given gpiochip character device and returns information for every line on the chip. The chip is closed before return.
chipPath should be an absolute path to a gpiochip device node (for example, "/dev/gpiochip0"). Errors from the kernel are wrapped with chipPath context. When chipPath resolves to a file that isn't a GPIO character device (the typical case is a stale tty left in a PTT form when the user flips method to "gpio"), the wrapped error includes ErrNotGpioChip so callers can distinguish client mistakes from genuine server faults.
type ProbeResult ¶ added in v0.14.13
type ProbeResult struct {
// Exists is true when the path resolves to a filesystem node.
Exists bool
// CharDevice is true when the node is a character device (the shape
// every real PTT device — serial, hidraw, gpiochip — takes). A path
// that exists but is not a char device is almost always a mistake.
CharDevice bool
// Detail is a short human-readable summary of the outcome.
Detail string
}
ProbeResult reports what a lightweight, side-effect-free inspection of a device path found. It backs the UI's advisory for manually-entered PTT device paths (e.g. a udev-renamed /dev/aioc-aprs-ptt).
The probe deliberately does NOT open the device: opening a serial tty can toggle DTR/RTS and briefly key the radio, and opening it without O_NONBLOCK can block on carrier detect. os.Stat has neither hazard, so existence and node-type are all we report — enough to catch the common mistakes (typo'd path, pointing at a regular file) without ever touching the wire.
func Probe ¶ added in v0.14.13
func Probe(path string) ProbeResult
Probe inspects path without opening it. It is safe on every platform and never keys the radio. An empty path is treated as "not present" rather than an error, so callers can probe eagerly as the operator types.