package driver
import "github.com/edgexfoundry/device-rfid-llrp-go/internal/driver"
Index ¶
- Constants
- Variables
- func CreateDriverConfig(configMap map[string]string) (*driverConfiguration, error)
- type DeviceSDKService
- func (s *DeviceSDKService) DriverConfigs() map[string]string
- func (s *DeviceSDKService) SetDeviceOpState(name string, state contract.OperatingState) error
- type Driver
- func Instance() *Driver
- func (d *Driver) AddDevice(deviceName string, protocols protocolMap, adminState contract.AdminState) error
- func (d *Driver) Discover()
- func (d *Driver) HandleReadCommands(devName string, p protocolMap, reqs []dsModels.CommandRequest) ([]*dsModels.CommandValue, error)
- func (d *Driver) HandleWriteCommands(devName string, p protocolMap, reqs []dsModels.CommandRequest, params []*dsModels.CommandValue) error
- func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *dsModels.AsyncValues, deviceCh chan<- []dsModels.DiscoveredDevice) error
- func (d *Driver) NewLLRPDevice(name string, address net.Addr, opState contract.OperatingState) *LLRPDevice
- func (d *Driver) RemoveDevice(deviceName string, p protocolMap) error
- func (d *Driver) Stop(force bool) error
- func (d *Driver) UpdateDevice(deviceName string, protocols protocolMap, adminState contract.AdminState) (err error)
- type ImpinjModelType
- type LLRPDevice
- func (l *LLRPDevice) Stop(ctx context.Context) error
- func (l *LLRPDevice) TrySend(ctx context.Context, request llrp.Outgoing, reply llrp.Incoming) error
- func (l *LLRPDevice) UpdateAddr(ctx context.Context, addr net.Addr) error
- type MultiErr
- type ServiceWrapper
- type VendorIDType
Constants ¶
const ( ServiceName = "edgex-device-rfid-llrp" ResourceReaderCap = "ReaderCapabilities" ResourceReaderConfig = "ReaderConfig" ResourceReaderNotification = "ReaderEventNotification" ResourceROSpec = "ROSpec" ResourceROSpecID = "ROSpecID" ResourceAccessSpec = "AccessSpec" ResourceAccessSpecID = "AccessSpecID" ResourceROAccessReport = "ROAccessReport" ResourceAction = "Action" ActionDelete = "Delete" ActionEnable = "Enable" ActionDisable = "Disable" ActionStart = "Start" ActionStop = "Stop" AttribVendor = "vendor" AttribSubtype = "subtype" )
const ( Impinj = VendorIDType(25882) Alien = VendorIDType(17996) Zebra = VendorIDType(10642) )
const ( SpeedwayR220 = ImpinjModelType(2001001) SpeedwayR420 = ImpinjModelType(2001002) XPortal = ImpinjModelType(2001003) XArrayWM = ImpinjModelType(2001004) XArrayEAP = ImpinjModelType(2001006) XArray = ImpinjModelType(2001007) XSpan = ImpinjModelType(2001008) SpeedwayR120 = ImpinjModelType(2001009) R700 = ImpinjModelType(2001052) )
Variables ¶
var ( // ErrUnexpectedConfigItems is returned when the input configuration map has extra keys // and values that are left over after parsing is complete ErrUnexpectedConfigItems = errors.New("unexpected config items") // ErrParsingConfigValue is returned when we are unable to parse the value for a config key ErrParsingConfigValue = errors.New("unable to parse config value for key") // ErrMissingRequiredKey is returned when we are unable to parse the value for a config key ErrMissingRequiredKey = errors.New("missing required key") )
Functions ¶
func CreateDriverConfig ¶
CreateDriverConfig creates a driverConfiguration object from the strings map provided by EdgeX
Types ¶
type DeviceSDKService ¶
type DeviceSDKService struct { *service.DeviceService // contains filtered or unexported fields }
func (*DeviceSDKService) DriverConfigs ¶
func (s *DeviceSDKService) DriverConfigs() map[string]string
DriverConfigs retrieves the driver specific configuration
func (*DeviceSDKService) SetDeviceOpState ¶
func (s *DeviceSDKService) SetDeviceOpState(name string, state contract.OperatingState) error
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver manages a collection of devices that speak LLRP and connects them to the EdgeX ecosystem.
A driver must be initialized before use. This is typically done by the Device Service SDK. This package maintains a package-global variable which it exports via driver.Instance.
The Driver's exported methods are safe for concurrent use.
func Instance ¶
func Instance() *Driver
Instance returns the package-global Driver instance, creating it if necessary. It must be initialized before use via its Initialize method.
func (*Driver) AddDevice ¶
func (d *Driver) AddDevice(deviceName string, protocols protocolMap, adminState contract.AdminState) error
AddDevice tells the driver attempt to actively manage a device.
The Device Service SDK calls this when a new Device associated with this Device Service is added, so this assumes the device is already registered with EdgeX.
func (*Driver) Discover ¶
func (d *Driver) Discover()
Discover performs a discovery of LLRP readers on the network and passes them to EdgeX to get provisioned
func (*Driver) HandleReadCommands ¶
func (d *Driver) HandleReadCommands(devName string, p protocolMap, reqs []dsModels.CommandRequest) ([]*dsModels.CommandValue, error)
HandleReadCommands triggers a protocol Read operation for the specified device.
func (*Driver) HandleWriteCommands ¶
func (d *Driver) HandleWriteCommands(devName string, p protocolMap, reqs []dsModels.CommandRequest, params []*dsModels.CommandValue) error
HandleWriteCommands passes a slice of CommandRequest struct each representing a ResourceOperation for a specific device resource. Since the commands are actuation commands, params provide parameters for the individual command.
func (*Driver) Initialize ¶
func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *dsModels.AsyncValues, deviceCh chan<- []dsModels.DiscoveredDevice) error
Initialize performs protocol-specific initialization for the device service.
func (*Driver) NewLLRPDevice ¶
func (d *Driver) NewLLRPDevice(name string, address net.Addr, opState contract.OperatingState) *LLRPDevice
NewLLRPDevice returns an LLRPDevice which attempts to connect to the given address.
func (*Driver) RemoveDevice ¶
RemoveDevice is a callback function that is invoked when a Device associated with this Device Service is removed
func (*Driver) Stop ¶
Stop the Driver, causing it to shutdown its active device connections and no longer process commands or upstream reports.
If force is false, the Driver attempts to gracefully shutdown active devices by sending them a CloseConnection message and waiting a short time for their response. If force is true, it immediately closes all active connections. In neither case does it tell devices to stop reading.
EdgeX says DeviceServices should close the async readings channel, but tracing their code reveals they call close on the channel, so doing so would cause a panic.
func (*Driver) UpdateDevice ¶
func (d *Driver) UpdateDevice(deviceName string, protocols protocolMap, adminState contract.AdminState) (err error)
UpdateDevice updates a device managed by this Driver.
The Device Service SDK calls it when a Device is updated, so this assumes the device is already registered with EdgeX.
If the Driver has a device with this name, but the device's address changes, this will shutdown any current connection associated with the named device, update the address, and attempt to reconnect at the new address and port. If the address is the same, nothing happens.
type ImpinjModelType ¶
type ImpinjModelType uint32
func (ImpinjModelType) HostnamePrefix ¶
func (imt ImpinjModelType) HostnamePrefix() string
HostnamePrefix will return the default hostname prefix of known Impinj readers
func (ImpinjModelType) String ¶
func (i ImpinjModelType) String() string
type LLRPDevice ¶
type LLRPDevice struct {
// contains filtered or unexported fields
}
LLRPDevice manages a connection to a device that speaks LLRP, and notifies EdgeX of relevant device events.
LLRPDevice attempts to maintain a connection to the Reader, provides methods to retry message sends that fail due to closed connections, and notifies EdgeX if a Reader connection appears lost. It forwards ROAccessReports & ReaderEventNotifications to EdgeX.
It is safe to use an LLRPDevice's methods concurrently and when disconnected. If TrySend fails due to connection issues, it reattempts the send a few times, backing off between attempts.
Use Stop to stop actively managing the connection. After Stop, we no longer receive reports or event notifications, and all calls to TrySend will fail. At that point, to reconnect to the same Reader, you must create a new LLRPDevice instance.
func (*LLRPDevice) Stop ¶
func (l *LLRPDevice) Stop(ctx context.Context) error
Stop closes any open client connection and stops trying to reconnect.
If the context is not canceled or past its deadline, it'll attempt a graceful shutdown. Otherwise/if the context is canceled/times out before completion, it forcefully closes the connection.
func (*LLRPDevice) TrySend ¶
TrySend works like the llrp.Client's SendFor method, but reattempts a send a few times if it fails due to a closed reader. Additionally, it enforces our KeepAlive interval for timeout detection upon SetReaderConfig messages.
func (*LLRPDevice) UpdateAddr ¶
UpdateAddr updates the device address.
If the device were Stopped, this won't start it, and this has no practical effect. It may return an error if closing the current connection fails for some reason. Nevertheless, it updates the address and will attempt to use it the next time it connects.
type MultiErr ¶
type MultiErr []error
func (MultiErr) Error ¶
type ServiceWrapper ¶
type ServiceWrapper interface { // Inherit Devices() []contract.Device GetDeviceByName(name string) (contract.Device, error) UpdateDevice(device contract.Device) error UpdateDeviceOperatingState(deviceName string, state string) error GetProvisionWatcherByName(name string) (contract.ProvisionWatcher, error) AddProvisionWatcher(watcher contract.ProvisionWatcher) (id string, err error) AddDevice(device contract.Device) (id string, err error) // Pass-through DriverConfigs() map[string]string // Custom functionality or macros SetDeviceOpState(name string, state contract.OperatingState) error }
ServiceWrapper wraps an EdgeX SDK service so it can be easily mocked in tests.
type VendorIDType ¶
type VendorIDType uint32
func (VendorIDType) String ¶
func (i VendorIDType) String() string
Source Files ¶
config.go device.go discover.go driver.go logging.go service.go types.go types_string.go
- Version
- v1.0.0 (latest)
- Published
- Aug 17, 2021
- Platform
- linux/amd64
- Imports
- 28 packages
- Last checked
- 4 days ago –
Tools for package owners.