Scale
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.
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).