Documentation
¶
Index ¶
Constants ¶
const ( NoisePrefix byte = '#' PassingPrefix byte = '$' MaxTransponderID uint32 = ^uint32(0) >> 8 )
Variables ¶
var TransponderIDOverflow = errors.New("transponder id overflow")
TransponderIDOverflow is returned when transponder id is bigger than MaxUint24.
Functions ¶
func MarshalNoise ¶
MarshalNoise marshals uint16 noise value to byte array
func MarshalPassing ¶
MarshalPassing marshals Passing struct to byte array
func UnmarshalNoise ¶
UnmarshalNoise parses noise level from TranX2 encoded data. TranX2 lines are terminated with "\r\n". Unmarshaller allows you to pass lines with or without "\r\n".
Types ¶
type Client ¶
type Client struct {
Opts SerialOptions
Handler Tranx2Handler
Conn io.ReadCloser
}
Client provides high level callback API for TranX-2 serial connection.
func NewClient ¶
func NewClient(portName string, handler Tranx2Handler) *Client
NewClient returns TranX2 client with default configuration. Configuration can be modified before calling the Listen receiver.
type Passing ¶
type Passing struct {
TransponderID uint32 // ID of passing device
PassingTicks uint32 // milliseconds elapsed since the device was started.
Hits uint8 // number of reads while transponder passed the loop
Strength uint8 // signal strenght
Prefix uint16 // TODO: figure what is the meaning of this
Trailing uint8 // TODO: figure what is the meaning of this
}
Passing struct contains fields present in passing recordsend by TranX2 devices. Note that TransponderID is actually uint24 but is presented as uint32 so Marshalling message with something bigger than MaxTransponderID will result in TransponderIDOverflow error.
func UnmarshalPassing ¶
UnmarshalPassing creates Passing struct from TranX2 encoded data. TranX2 lines are terminated with "\r\n". Unmarshaller allows you to pass lines with or without "\r\n".
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader provides API for reading tranx2 encoded data
func (*Reader) ReadNoise ¶
ReadNoise is high level API for reading only noise levels and discarding everything else. It is suitable for applications that are only interested on noise levels and do not care about transponder data.
func (*Reader) ReadPassing ¶
ReadPassing is high level API for reading only Passing records and discarding everything else. It is suitable for applications that are only interested on passings and do not care about noise level records.
type SerialOptions ¶
type SerialOptions serial.OpenOptions
type Tranx2Handler ¶
Tranx2Handler interface requiresall callback functions that are needed for handling tranx2 events.
type UnmarshalError ¶
func (*UnmarshalError) Error ¶
func (e *UnmarshalError) Error() string
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer provides API for writing tranx2 encoded data
func (*Writer) WriteNoise ¶
WriteNoise writes noise level and returns the number of bytes writen or error.