Documentation ¶
Index ¶
- type Conn
- type Manager
- func (m *Manager) AddDevice(d *udev.Device) error
- func (m *Manager) Close()
- func (m *Manager) Init()
- func (m *Manager) List(w http.ResponseWriter, r *http.Request)
- func (m *Manager) RemoveDevice(name string) error
- func (m *Manager) RunCommand(w http.ResponseWriter, r *http.Request)
- func (m *Manager) Symlink() error
- func (m *Manager) Updates(w http.ResponseWriter, r *http.Request)
- type Message
- type Modem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a device serial connection
func (*Conn) Exec ¶
Exec sends the command over serial port and rrturns the response. If the port is closed it is opened before sending the command.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages devices that are plugged into the system. It supports auto detection of devices.
Serial ports are opened each for a device, and a clean API for communicating is provided via Read, Write and Flush methods.
The devices are monitored via udev, and any changes that requires reloading of the ports are handled by reloading the ports to the devices.
This is safe to use concurrently in multiple goroutines
func (*Manager) AddDevice ¶
AddDevice adds device name to the manager
WARNING: The way modems are picked is a hack. It asserts that the modem with the lowest tty number is the control modem( Which I'm not so sure is always correct).
TODO: comeup with a proper way to identify modems
func (*Manager) Close ¶
func (m *Manager) Close()
Close shuts down the device manager. This makes sure the udev monitor is closed and all goroutines are properly exited.
func (*Manager) Init ¶
func (m *Manager) Init()
Init initializes the manager. This involves creating a new goroutine to watch over the changes detected by udev for any device interaction with the system.
The only interesting device actions are add and reomove for adding and removing devices respctively.
func (*Manager) List ¶
func (m *Manager) List(w http.ResponseWriter, r *http.Request)
List serves the list of current devices. The list wont cover all devices , only the significant ones( modems for now)
func (*Manager) RemoveDevice ¶
RemoveDevice removes device name from the manager
func (*Manager) RunCommand ¶
func (m *Manager) RunCommand(w http.ResponseWriter, r *http.Request)
RunComand runs commands to the exposed devices over serial ports