llrp

package module
v0.0.0-...-8dcd56d Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 11 Imported by: 9

README

go-llrp

GoDoc Travis Build Status Coverage Status Go Report Card GitHub

The go-llrp package is a tiny library for simple LLRP message and paramter composition. See golemu for an example use of this package.

Installation

go get -v github.com/iomz/go-llrp

Benchmark

% go test -run=XXX -bench=BenchmarkUnmarshal -timeout=0 -v -benchmem
goos: linux
goarch: amd64
pkg: github.com/iomz/go-llrp
BenchmarkUnmarshal100Tags-32              100000             24435 ns/op            7344 B/op        114 allocs/op
BenchmarkUnmarshal200Tags-32               30000             45400 ns/op           14696 B/op        223 allocs/op
BenchmarkUnmarshal300Tags-32               20000             66518 ns/op           22616 B/op        335 allocs/op
BenchmarkUnmarshal400Tags-32               20000             91934 ns/op           29904 B/op        446 allocs/op
BenchmarkUnmarshal500Tags-32               10000            109674 ns/op           37256 B/op        555 allocs/op
BenchmarkUnmarshal600Tags-32               10000            135384 ns/op           45368 B/op        669 allocs/op
BenchmarkUnmarshal700Tags-32               10000            156957 ns/op           52976 B/op        779 allocs/op
BenchmarkUnmarshal800Tags-32               10000            179061 ns/op           59816 B/op        887 allocs/op
BenchmarkUnmarshal900Tags-32               10000            199013 ns/op           67928 B/op       1001 allocs/op
BenchmarkUnmarshal1000Tags-32              10000            227144 ns/op           75536 B/op       1111 allocs/op
PASS
ok      github.com/iomz/go-llrp 82016.381s
go test -run=XXX -bench=BenchmarkUnmarshal -timeout=0 -v -benchmem  158855.53s user 671.25s system 194% cpu 22:46:57.00 total

License

Licensed under the MIT license. Copyright (c) 2016-2019 Iori Mizutani.

Documentation

Index

Constants

View Source
const (
	GetReaderCapabilityHeader         = 1025 // type 1
	GetReaderConfigHeader             = 1026 // type 2
	SetReaderConfigHeader             = 1027 // type 3
	GetReaderCapabilityResponseHeader = 1035 // type 11
	GetReaderConfigResponseHeader     = 1036 // type 12
	SetReaderConfigResponseHeader     = 1037 // type 13
	AddRospecHeader                   = 1044 // type 20
	DeleteRospecHeader                = 1045 // type 21
	EnableRospecHeader                = 1048 // type 24
	AddRospecResponseHeader           = 1054 // type 30
	DeleteRospecResponseHeader        = 1055 // type 31
	EnableRospecResponseHeader        = 1058 // type 34
	DeleteAccessSpecHeader            = 1065 // type 41
	DeleteAccessSpecResponseHeader    = 1075 // type 51
	ROAccessReportHeader              = 1085 // type 61
	KeepaliveHeader                   = 1086 // type 62
	ReaderEventNotificationHeader     = 1087 // type 63
	EventsAndReportsHeader            = 1088 // type 64
	KeepaliveAckHeader                = 1096 // type 72
	ImpinjEnableCutomMessageHeader    = 2047 // type 1023
)

LLRP header values, the header is composed of 2 bytes where the first is set to 0x40 or 1024, so 1025 would be 0x0401

Variables

This section is empty.

Functions

func AddRospecResponse

func AddRospecResponse(messageID uint32) []byte

AddRospecResponse : Add ROSpec Response

func AntennaAirPort

func AntennaAirPort(id uint16) []byte

AntennaAirPort :

func AntennaAirPortList

func AntennaAirPortList(numOfAntennas int) []interface{}

AntennaAirPortList :

func AntennaConfiguration

func AntennaConfiguration(id uint16) []byte

func AntennaProperties

func AntennaProperties(id uint16) []byte

AntennaProperties :

func C1G2InventoryCommand

func C1G2InventoryCommand() []byte

func C1G2PC

func C1G2PC(pc uint16) []byte

C1G2PC generates C1G2PC parameter from hexpc string.

func C1G2RFControl

func C1G2RFControl() []byte

func C1G2ReadOpSpecResult

func C1G2ReadOpSpecResult(readData []byte) []byte

C1G2ReadOpSpecResult generates C1G2ReadOpSpecResult parameter from readData.

func C1G2SingulationControl

func C1G2SingulationControl() []byte

func C1G2UHFModeRFTable

func C1G2UHFModeRFTable() []byte

C1G2UHFModeRFTable :

func C1G2UHFModeRFTableEntry

func C1G2UHFModeRFTableEntry(mode int) []byte

C1G2UHFModeRFTableEntry :

func C1G2llrpCapabilities

func C1G2llrpCapabilities() []byte

C1G2llrpCapabilities : Generates C1G2llrpCapabilities

func ChannelIndex

func ChannelIndex() []byte

ChannelIndex : Generates channelIndex for EPC tag

func ConnectionAttemptEvent

func ConnectionAttemptEvent() []byte

ConnectionAttemptEvent generates ConnectionAttemptEvent parameter.

func DeleteAccessSpecResponse

func DeleteAccessSpecResponse(messageID uint32) []byte

DeleteAccessSpecResponse : Delete Access Spec Response

func DeleteRospecResponse

func DeleteRospecResponse(messageID uint32) []byte

DeleteRospecResponse : Delete RoSpec Response

func EPCData

func EPCData(length uint16, epcLengthBits uint16, epc []byte) []byte

EPCData generates EPCData parameter from its length and epcLength, and epc.

func EnableRospecResponse

func EnableRospecResponse(messageID uint32) []byte

EnableRospecResponse : Enabled Rospec Response

func FrequencyHopTable

func FrequencyHopTable() []byte

FrequencyHopTable :

func FrequencyInformation

func FrequencyInformation() []byte

FrequencyInformation :

func GPIOCapabilities

func GPIOCapabilities() []byte

GPIOCapabilities : Generates GPIO capabilities proeprty

func GeneralDeviceCapabilities

func GeneralDeviceCapabilities() []byte

GeneralDeviceCapabilities : Generates General Device Capabilities

func GetReaderCapability

func GetReaderCapability(messageID uint32) []byte

GetReaderCapability :

func GetReaderCapabilityResponse

func GetReaderCapabilityResponse(messageID uint32) []byte

GetReaderCapabilityResponse :

func GetReaderConfigResponse

func GetReaderConfigResponse(messageID uint32) []byte

GetReaderConfigResponse :

func GetReaderConfigResponseIdentification

func GetReaderConfigResponseIdentification() []byte

GetReaderConfigResponseIdentification : Generate Identification

func ImpinjEnableCutomMessage

func ImpinjEnableCutomMessage(id uint32) []byte

func Keepalive

func Keepalive(messageID uint32) []byte

Keepalive generates Keepalive message.

func KeepaliveAck

func KeepaliveAck(messageID uint32) []byte

KeepaliveAck generates KeepaliveAck message.

func KeepaliveSpec

func KeepaliveSpec() []byte

KeepaliveSpec generates KeepaliveSpec parameter.

func LastSeenTimestampUTC

func LastSeenTimestampUTC() []byte

LastSeenTimestampUTC : Returns the a UNIX timestamp in microseconds

func LlrpCapabilities

func LlrpCapabilities() []byte

LlrpCapabilities : generates LLRP_CAPABILITIES

func NewTagReportDataParam

func NewTagReportDataParam(tag *Tag) []byte

BuildTagReportDataParameter takes one Tag struct and build TagReportData parameter payload in []byte FIXME: Take SetReaderConfig or ROSpec configuration parameters

func Pack

func Pack(data []interface{}) []byte

Pack the data into (partial) LLRP packet payload. TODO: count the data size and return resulting length ?

func PeakRSSI

func PeakRSSI() []byte

PeakRSSI generates PeakRSSI parameter.

func RFReceiver

func RFReceiver() []byte

func RFTransmitter

func RFTransmitter() []byte

func ReaderEventNotification

func ReaderEventNotification(messageID uint32, currentTime uint64) []byte

ReaderEventNotification generates ReaderEventNotification message.

func ReaderEventNotificationData

func ReaderEventNotificationData(currentTime uint64) []byte

ReaderEventNotificationData generates ReaderEventNotification parameter.

func ReceiveSensitivityEntries

func ReceiveSensitivityEntries(numOfAntennas int) []interface{}

ReceiveSensitivityEntries : Generates ReceiveSensitivityEntries used in General capabilities

func ReceiveSensitivityEntry

func ReceiveSensitivityEntry(id uint16) []byte

ReceiveSensitivityEntry :

func ReguCapabilities

func ReguCapabilities() []byte

ReguCapabilities : generates Regulatory Capabilities

func SetReaderConfig

func SetReaderConfig(messageID uint32) []byte

SetReaderConfig generates SetReaderConfig message.

func SetReaderConfigResponse

func SetReaderConfigResponse(messageID uint32) []byte

SetReaderConfigResponse generates SetReaderConfigResponse message.

func Status

func Status() []byte

Status generates LLRPStatus parameter.

func TagSeenCount

func TagSeenCount() []byte

TagSeenCount :

func TransmitPowerLevelEntry

func TransmitPowerLevelEntry(id uint16, powerLevel uint16) []byte

TransmitPowerLevelEntry :

func UHFCapabilities

func UHFCapabilities(numOfAntennas int) []byte

UHFCapabilities :

func UTCTimeStamp

func UTCTimeStamp(currentTime uint64) []byte

UTCTimeStamp generates UTCTimeStamp parameter at the current time.

Types

type ROAccessReport

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

ROAccessReport is a struct for ROAR message

func NewROAccessReport

func NewROAccessReport(tagReportData []byte, messageID uint32) *ROAccessReport

NewROAccessReport returns a pointer to a new ROAccessReport message.

func (*ROAccessReport) Send

func (roar *ROAccessReport) Send(conn net.Conn) error

Send the ROAR throgh the conn

type ReadEvent

type ReadEvent struct {
	ID []byte
	PC []byte
}

ReadEvent is the struct to hold data on RFTags

func UnmarshalROAccessReportBody

func UnmarshalROAccessReportBody(roarBody []byte) []*ReadEvent

UnmarshalROAccessReportBody extract ReadEvent from the message value in the ROAccessReport

type Tag

type Tag struct {
	PCBits uint16
	EPC    []byte
}

Tag holds a single virtual tag content

func NewTag

func NewTag(tagRecord *TagRecord) (*Tag, error)

NewTag onstructs a Tag struct from a TagRecord

func (*Tag) IsDuplicate

func (tag *Tag) IsDuplicate(tt *Tag) bool

IsDuplicate to test another Tag by comparing only EPC return true if the EPCs are the same

func (*Tag) IsEqual

func (tag *Tag) IsEqual(tt *Tag) bool

IsEqual to another Tag by taking one as its argument return true if they are the same

func (*Tag) MarshalBinary

func (tag *Tag) MarshalBinary() (_ []byte, err error)

MarshalBinary overwrites the marshaller in gob encoding *Tag

func (*Tag) UnmarshalBinary

func (tag *Tag) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary overwrites the unmarshaller in gob decoding *Tag

type TagRecord

type TagRecord struct {
	PCBits string `json:"PCBits"`
	EPC    string `json:"EPC"`
}

TagRecord stors the Tags contents in string with json tags

func NewTagRecord

func NewTagRecord(tag Tag) *TagRecord

type TagReportData

type TagReportData struct {
	Data     []byte
	TagCount uint
}

TagReportData holds an actual parameter in byte and how many tags are included in the parameter

type TagReportDataStack

type TagReportDataStack []*TagReportData

TagReportDataStack is a stack of TagReportData

func (TagReportDataStack) TotalTagCounts

func (trds TagReportDataStack) TotalTagCounts() uint

TotalTagCounts returns how many tags are included in the TagReportDataStack

type Tags

type Tags []*Tag

Tags holds a slice of pointers to Tag

func LoadTagsFromCSV

func LoadTagsFromCSV(inputFile string) Tags

LoadTagsFromCSV reads Tag data from the CSV strings and returns a slice of Tag struct pointers

func (Tags) BuildTagReportDataStack

func (tags Tags) BuildTagReportDataStack(pdu int) TagReportDataStack

BuildTagReportDataStack takes []*Tag and PDU value to build a new trds

func (Tags) GetIndexOf

func (tags Tags) GetIndexOf(t *Tag) int

GetIndexOf finds the index in []*Tag

func (*Tags) MarshalBinary

func (tags *Tags) MarshalBinary() (_ []byte, err error)

MarshalBinary overwrites the marshaller in gob encoding Tags

func (*Tags) UnmarshalBinary

func (tags *Tags) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary overwrites the unmarshaller in gob decoding Tags

Directories

Path Synopsis
cmd
uiigen
This file contains EPC binary encoding schemes This file contains ISO binary encoding scheme A tool to generate arbitrary UII (aka EPC)
This file contains EPC binary encoding schemes This file contains ISO binary encoding scheme A tool to generate arbitrary UII (aka EPC)

Jump to

Keyboard shortcuts

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