Skip to content

Connect IoT - Keyboard Wedge Driver#

This driver is intended to handle data read by a device other than a keyboard, such as a magnetic strip or bar code reader or other such scanning device, into keyboard data. With this driver, using cheap readers (barcode, rfid, etc) becomes a reality.

Warning

Very Important: To be able to receive the data sent by the keyboard wedge device, it is necessary to listen to specific event in the operating system. This is also known as keylogger and it is not possible to be used within Microsoft Windows operating systems. For this reason, this driver is only supposed to be executed in Linux operating system, running as administrator privileges (sudo) and with libusb module installed.

Data Types#

These are the supported specific data types:

Name Description
String String Value
Boolean Boolean Value
Integer Integer value
Decimal Decimal value
Object Structured value

Protocol Parameters#

The protocol supports the following parameters:

Name Type Possible Values Default Value Description
deviceIdentifierType Enum VendorAndProductId
Path
DeviceIndex
VendorAndProductId Type of identification to use to determine which device the driver will connect to
path String Path of the device as known by the operating system. Used when deviceIdentifierType is Path
vendorId Integer 0 Id of the vendor of the device to use. Used when deviceIdentifierType is VendorAndProductId. Use "-1" value to use any vendor id. Expected value to be in decimal format (not hexadecimal).
productId Integer 0 Id of the product of the device to use. Used when deviceIdentifierType is VendorAndProductId. Use "-1" value to use any productId id. Expected value to be in decimal format (not hexadecimal).
deviceIndex Integer 0 Index of the device to use. When deviceIdentifierType is DeviceIndex, the selected device will be the one that matches the index on all devices. When deviceIdentifierType is VendorAndProductId, will select the index of the devices among the ones that match the vendor and product id.
parserType Enum Raw
Readline
ByteLength
Delimiter
InterByteTimeout
Ready
Regex
ReadLine Select the parser used to determine when the received data from the device is to be recognized and ready to be processed (check specific section about each of the parsers for more information).
delimiter string "\r\n" Used in parsers Readline , Delimiter, Ready, RegularExpression: String delimiter to split incoming text. Simple string substitutions can be used like \r\n\t. If parser is RegularExpression you can use regular expressions such as: [\r\n]+
encoding Enum ascii
utf8
utf16le
ucs2
base64
binary
hex
ascii Used in parsers Readline, Regex: Text encoding for the received data
byteLengthSize Integer 8 Used in parsers ByteLength: Number of bytes to receive before triggering the event
timeoutValue Integer 1000 Used in parsers InterByteTimeout: Period of silence in milliseconds after which data is emitted
maxBufferSize Integer 65536 Used in parsers: InterByteTimeout: Maximum number of bytes after which data will be emitted

Parsers#

Parsers are collection of transform streams to process incoming data. The following parsers are available:

Name Parameters Description
Raw Any data received will be immediately processed.
Readline delimiter Data is emitted after the configured newline delimiter is received.
ByteLength byteLengthSize Data is emitted right after a specific number of bytes are received.
Delimiter delimiter Data is emitted each time a specific sequence is received.
InterByte Timeout timeoutValue
maxBufferSize
Data is emitted after not receiving any bytes for the specified amount of time or if the buffer becomes full.
Ready delimiter Data is not emitted until a sequence of ready bytes (that match the delimiter parameter) before emitting a ready event and emitting data events
Regex delimiter
encoding
A regular expression (delimiter parameter) is used to split the incoming text. The matches are emitted as data to be processed.

Extended Parameters#

As with other protocol drivers, some extra parameters are necessary to provide more context to the behavior expected.

Property#

Name Type Possible Values Default Value Description
identifierType Enum None
RegularExpression
Token
None Method used to identify a property. If None is used, identifierValue will be ignored and all messages will update that property. Token type will match identifierValue text only on the beginning of the message and RegularExpression will match on configured Regular Expression identifierValue field.
identifierValue String Value of the Property Identifier. Valid on RegularExpression (enter a valid regular expression) or Token (enter the expected text) identifierType.

Event#

Name Type Possible Values Default Value Description
triggerMode Enum AllValues
DifferentValues
Periodic
AllValues Determines how and when the data can be emitted as an event.
AllValues: every time the trigger property value is received
DifferentValues: every time a different trigger property value is received
Periodic: On a periodic basis (every periodicDataInterval, in milliseconds), disregarding property update cycles or values.
periodicDataInterval Integer 1000 Number of milliseconds to publish data. Only valid on triggerMode Periodic

Event Property#

Name Type Possible Values Default Value Description
isTrigger Boolean true Trigger the event when the property is received (on event triggerMode AllValues), or when the value is changed (on event triggerMode AllValues or DifferentValues)

Remarks/Behavior#

  • When an event has more than one property with the isTrigger flag:
    • It will be triggered every time any of the properties value changes.
    • The value of the other properties will be the one available at the time of the event.
    • It is possible to have multiple triggers with the same set values (because they have not changed). If this behavior is not intended, separate into multiple events each one with its own trigger set.
  • When an event has no property with the isTrigger flag, it will never be triggered (unless event is defined as Periodic)
  • If you are not sure if libusb is installed, enter the command

    sudo apt install libusb-1.0-0 libusb-1.0-0-dev
    
  • According to linux documentation, it is possible to access the device without sudo/root permissions. For more information, check for udev device permissions documentation for your operating system.