Scale
7 min
the scale driver connects to scale devices over tcp, udp, or serial by sending configurable request payloads and reading responses the driver supports polling (request/response), streaming (unsolicited data), and write operations litmus edge compatible series compatibility parameter compatible items driver type ethernet (tcp, udp), serial validated devices/series generic tcp servers, scales how to configure the scale device to set up and configure this device in litmus edge, you will need to do the following step 1 set up and configure the scale device step 2 set up the scale device in litmus edge devicehub step 3 configure the list of registers step 1 set up and configure the scale device determine the transport type your device uses tcp , udp , or serial for tcp or udp note the device's ip address and port number ensure the device is reachable from your litmus edge instance over the network if tls is required, confirm that the device supports tls and that your certificates are in place for serial identify the serial port file (for example, /dev/ttyusb0 ) confirm the correct baud rate , data bits , stop bits , and parity settings for your device these are typically found in the device's hardware manual if the device requires a specific command to initiate a connection, note the exact command string — you will enter it in the connection request field step 2 set up the scale device in litmus edge devicehub configure the following parameters when you connect a device with this driver update default values to the specific setup of your device parameter value type generic driver scale transport select tcp , udp , or serial depending on your device network address (tcp or udp only) the device's ip address network port (tcp or udp only) the device's port number device file (serial only) the serial port file (for example, /dev/ttyusb0 ) baud rate (serial only) select from 1200 , 2400 , 4800 , 9600 , 19200 , 38400 , 57600 , 115200 , 230400 , 460800 , 921600 data bits (serial only) select from 5 , 6 , 7 , 8 stop bits (serial only) select from 1 , 1 5 , 2 parity (serial only) select from even , mark , none , odd , space connection request if the device requires a command to initiate the connection, enter it here protocol byte order select the byte order used by the device's protocol bigendian (bytes little) badc , bigendian abcd , littleendian (bytes big) cdab , or littleendian dcba data byte order select the byte order used for data values bigendian (bytes little) badc , bigendian abcd , littleendian (bytes big) cdab , or littleendian dcba multiple connections (tcp or udp only) enable to allow multiple simultaneous data streams tls (tcp only) enable to use tls encryption for the tcp connection step 3 configure the list of registers when you add a tag to the connected device, see the following register table and tag parameters sections organize device and tag data by using metadata docid\ mu 6j6zhi0cvchdad0w8n tag formula variables docid\ io7xgyrdvv vmpnfxoaci register table name value types access type description poll poll request uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, string, \[]byte r/o sends a request payload to the device and reads the response at regular polling intervals or on demand write write request uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, string, \[]byte r/w sends a write command to the device when triggered stream stream request uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, string, \[]byte r/o listens passively for unsolicited data sent by the device response linked response value uint8, uint16, uint32, uint64, int8, int16, int32, int64, float32, float64, string, \[]byte r/o parses an additional value from an existing poll or stream request use this register type when a single response contains multiple values and you want to extract each one separately using a regex pattern tag parameters configure the following parameters when you add a tag to a connected scale device parameter description name select a register name from the drop down list available options depend on the register table above value type select a data type from the drop down list available options depend on the register name selected supported types uint8 , uint16 , uint32 , uint64 , int8 , int16 , int32 , int64 , float32 , float64 , string , \[]byte polling interval enter a value in seconds this determines how often the tag polls the device for data tag name enter a name for the tag payload enter the command or request to send to the device in hex string or ascii format for example, to send the command test followed by a carriage return, enter test\r , test 0d , or 544553540d ensure the value type is set to string request params enter request parameters as a json object use this field to pass an address or area code included in the request leave empty if no parameters are needed and you only need to send a fixed command example {"addr" "0007"} response index enter the start index of the value within the device response value length enter the length of a single value in bytes enter 0 to use the entire response response terminator specify the character or byte sequence that marks the end of the device response (for example, \r\n ) include terminator enable to include the response terminator in the tag value response max length enter the maximum number of bytes the driver is allowed to read from the socket before parsing stops enter 0 for unlimited override transport enable to define an alternate endpoint for a single request note that the override transport connection is not persistent request tag for response registers only enter the tag name of an existing poll or stream register to link this response tag to that request response regex for response registers only enter a regular expression to extract a specific value or data pattern from the device response before updating the tag value for example, if the stream value is "\u0002\u0013\u0014\u0002 11 17 lb 4\r" and you only want 11 17 lb , use the regex (\[ +]?\d \\ ?\d+)\s lb with regex match num 0 and regex group num 0 status regex for response registers only use this field to parse a decimal value from the response using the same regex approach as response regex for example, with payload ab1 107 , where 1 is the decimal position and 107 is the raw data, decimal parsing produces 1 07 tag formula enter a formula for the tag to process the generated data two variables are permitted value (current tag value) and timestamp (current tag unix time in milliseconds) the following math functions are available sin cos sqrt tan power power ( x ) performs the operation 10^x log log(x) is the natural logarithm (the logarithm is in base e ) exp exp ( x ) performs the operation e^x only publish on change of value select the checkbox to customize nats messages to be published only when the value parameter changes to a new one change of value only applies to boolean, numeric (such as int or float), and simple string data types it does not apply to complex types, such as json or array poll once topics will not be affected by change of value settings these topics will still only see a single message meta data metadata summarizes basic information about data this feature allows you to define key value pair data for the device output payload later on it can then be used to find, use, and reuse particular instances of data note if you use special characters in meta data key names, the special characters are replaced with underscore characters in the payload this can cause two key names to be combined into one for example, configuring the key names a b and a&\&b will cause only one key name to be created (a b)