Documentation
¶
Index ¶
- Constants
- Variables
- func ClearParam(s *Session, ref uint8, timeout time.Duration) error
- func GetParam(s *Session, name string, timeout time.Duration) ([]byte, error)
- func ReadDoubleMetrics(s *Session, ref uint8, timeout time.Duration) ([]float64, error)
- func ReadFile(s *Session, file string, report func(uint32), timeout time.Duration) ([]byte, error)
- func ReadFileRange(s *Session, file string, offset, length uint32, report func(uint32), ...) ([]byte, error)
- func ReadFloatMetrics(s *Session, ref uint8, timeout time.Duration) ([]float32, error)
- func ReadLongMetrics(s *Session, ref uint8, timeout time.Duration) ([]int32, error)
- func ReadMetrics(s *Session, ref uint8, timeout time.Duration) ([]byte, error)
- func ReadParam(s *Session, ref uint8, timeout time.Duration) ([]byte, error)
- func RemovePath(s *Session, path string, timeout time.Duration) error
- func RenamePath(s *Session, from, to string, timeout time.Duration) error
- func SHA256File(s *Session, file string, timeout time.Duration) ([]byte, error)
- func SetParam(s *Session, name string, value []byte, timeout time.Duration) error
- func Update(s *Session, image []byte, report func(int), timeout time.Duration) error
- func Write(ch Channel, msg Message) error
- func WriteFile(s *Session, file string, data []byte, report func(uint32), ...) error
- func WriteParam(s *Session, ref uint8, value []byte, timeout time.Duration) error
- type Channel
- type Device
- type FSInfo
- type ManagedDevice
- func (d *ManagedDevice) Activate() error
- func (d *ManagedDevice) Active() bool
- func (d *ManagedDevice) Deactivate()
- func (d *ManagedDevice) Device() Device
- func (d *ManagedDevice) Locked() bool
- func (d *ManagedDevice) NewSession() (*Session, error)
- func (d *ManagedDevice) Stop()
- func (d *ManagedDevice) UseSession(fn func(*Session) error) error
- type Message
- type MetricInfo
- type MetricKind
- type MetricLayout
- type MetricType
- type ParamInfo
- type ParamMode
- type ParamType
- type ParamUpdate
- type Queue
- type Session
- func (s *Session) End(timeout time.Duration) error
- func (s *Session) GetMTU(timeout time.Duration) (uint16, error)
- func (s *Session) ID() uint16
- func (s *Session) Ping(timeout time.Duration) error
- func (s *Session) Query(endpoint uint8, timeout time.Duration) (bool, error)
- func (s *Session) Receive(endpoint uint8, expectAck bool, timeout time.Duration) ([]byte, error)
- func (s *Session) Send(endpoint uint8, data []byte, ackTimeout time.Duration) error
- func (s *Session) Status(timeout time.Duration) (Status, error)
- func (s *Session) Unlock(password string, timeout time.Duration) (bool, error)
- type Status
Constants ¶
const ( ParamModeVolatile = ParamMode(1 << 0) ParamModeSystem = ParamMode(1 << 1) ParamModeApplication = ParamMode(1 << 2) ParamModeLocked = ParamMode(1 << 4) )
The available parameter modes.
const (
StatusLocked = Status(1 << 0)
)
The available session status flags.
const SystemEndpoint = 0xFD
The SystemEndpoint number.
Variables ¶
var ( SessionInvalidMessage = errors.New("invalid message") SessionUnknownMessage = errors.New("unknown message") SessionEndpointError = errors.New("endpoint error") SessionLockedError = errors.New("session locked") SessionExpectedAck = errors.New("expected ack") )
The available session errors.
var Ack = errors.New("acknowledgement")
Ack is an error returned when an acknowledgement is received.
Functions ¶
func ClearParam ¶
ClearParam clears the value of the referenced parameter.
func ReadDoubleMetrics ¶
ReadDoubleMetrics reads double metrics.
func ReadFileRange ¶
func ReadFileRange(s *Session, file string, offset, length uint32, report func(uint32), timeout time.Duration) ([]byte, error)
ReadFileRange reads a range of bytes from a file.
func ReadFloatMetrics ¶
ReadFloatMetrics reads float metrics.
func ReadLongMetrics ¶
ReadLongMetrics reads long metrics.
func ReadMetrics ¶
ReadMetrics reads metrics.
func RemovePath ¶
RemovePath removes a file system entry.
func RenamePath ¶
RenamePath renames a file system entry.
func SHA256File ¶
SHA256File retrieves the SHA-256 hash of a file.
Types ¶
type Channel ¶
type Channel interface { Device() Device Subscribe(Queue) Unsubscribe(Queue) Write([]byte) error Close() }
Channel provides the mechanism to exchange messages between a device and a client.
type Device ¶
type Device interface { // ID returns a stable identifier for the device. ID() string // Open opens a channel to the device. An opened channel must fail or be // closed before another channel can be opened. Open() (Channel, error) }
Device represents a device that can be communicated with.
func NewHTTPDevice ¶
NewHTTPDevice creates a new HTTP device.
type FSInfo ¶
FSInfo describes a file system entry.
type ManagedDevice ¶
type ManagedDevice struct {
// contains filtered or unexported fields
}
ManagedDevice represents a managed device.
func NewManagedDevice ¶
func NewManagedDevice(dev Device) *ManagedDevice
NewManagedDevice creates a new managed device.
func (*ManagedDevice) Activate ¶
func (d *ManagedDevice) Activate() error
Activate activates the device.
func (*ManagedDevice) Active ¶
func (d *ManagedDevice) Active() bool
Active returns whether the device is active.
func (*ManagedDevice) Deactivate ¶
func (d *ManagedDevice) Deactivate()
Deactivate deactivates the device.
func (*ManagedDevice) Device ¶
func (d *ManagedDevice) Device() Device
Device returns the underlying device.
func (*ManagedDevice) Locked ¶
func (d *ManagedDevice) Locked() bool
Locked returns whether the device is locked.
func (*ManagedDevice) NewSession ¶
func (d *ManagedDevice) NewSession() (*Session, error)
NewSession creates a new session.
func (*ManagedDevice) UseSession ¶
func (d *ManagedDevice) UseSession(fn func(*Session) error) error
UseSession uses the managed session.
type Message ¶
Message represents a message exchanged between a device and a client.
type MetricInfo ¶
type MetricInfo struct { Ref uint8 Kind MetricKind Type MetricType Name string Size uint8 }
MetricInfo describes a metric.
func ListMetrics ¶
func ListMetrics(s *Session, timeout time.Duration) ([]MetricInfo, error)
ListMetrics lists all metrics.
type MetricKind ¶
type MetricKind uint8
MetricKind represents a metric kind.
const ( MetricKindCounter MetricKind = iota MetricKindGauge )
The available metric kinds.
type MetricLayout ¶
MetricLayout describes a metric layout.
func DescribeMetric ¶
DescribeMetric describes a metric.
type MetricType ¶
type MetricType uint8
MetricType represents a metric type.
const ( MetricTypeLong MetricType = iota MetricTypeFloat MetricTypeDouble )
The available metric types.
type ParamType ¶
type ParamType uint8
ParamType represents a parameter type.
type ParamUpdate ¶
ParamUpdate describes a parameter update.
func CollectParams ¶
func CollectParams(s *Session, refs []uint8, since uint64, timeout time.Duration) ([]ParamUpdate, error)
CollectParams returns a list of parameter updates.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a communication session with a NAOS device.
func OpenSession ¶
OpenSession opens a new session using the specified channel.