pttdevice

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: GPL-2.0 Imports: 9 Imported by: 0

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

View Source
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.

Jump to

Keyboard shortcuts

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