usb

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(config ServerConfig, logger *slog.Logger, rawLogger log.RawLogger) *Server

func (*Server) AddBus

func (s *Server) AddBus(bus *virtualbus.VirtualBus) error

AddBus registers a bus with the server. If the bus number is already present, an error is returned.

func (*Server) Addr added in v0.3.2

func (s *Server) Addr() string

func (*Server) Close

func (s *Server) Close() error

Close stops the USB server by closing its listener.

func (*Server) GetBus

func (s *Server) GetBus(busID uint32) *virtualbus.VirtualBus

GetBus returns a bus by ID or nil if not present.

func (*Server) GetListenPort

func (s *Server) GetListenPort() uint16

GetListenPort extracts and returns the port number from the server's listen address.

func (*Server) ListBuses

func (s *Server) ListBuses() []uint32

ListBuses returns a snapshot of active bus numbers.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the USB-IP server and handles incoming connections.

func (*Server) NextFreeBusID added in v0.3.0

func (s *Server) NextFreeBusID() uint32

func (*Server) Ready

func (s *Server) Ready() <-chan struct{}

Ready returns a channel that is closed once the server has successfully bound to its listen address and is ready to accept connections.

func (*Server) RemoveBus

func (s *Server) RemoveBus(busID uint32) error

RemoveBus unregisters a bus from the server.

func (*Server) RemoveDeviceByID

func (s *Server) RemoveDeviceByID(busID uint32, deviceID string) error

RemoveDeviceByID removes a device by busId and cancels its connections.

type ServerConfig

type ServerConfig struct {
	Addr              string        `help:"USB-IP server listen address" default:":3241" env:"VIIPER_USB_ADDR"`
	ConnectionTimeout time.Duration `kong:"-"`
	BusCleanupTimeout time.Duration `help:"-"`
}

ServerConfig represents the server subcommand configuration.

Jump to

Keyboard shortcuts

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