Skip to content

DigGenSDI12GenericDataStrMsg

Dig Gen SDI12 Generic Data Str Msg

Message containing the data read from a SDI-12 sensor connected to the DIG Gen. The message contains information about the port, sensor and channels errors, as well as the read values for each channel, if no errors are present.

Integration ID: 0 | Message Version: 0

Source Code


Field Bits Type Unit Condition Mutator Validator Description
numSensors 6 UInt count Always RangeValidator[0, 62] Number of sensors read from the SDI-12 port. Limit 62 by protocol.
numChannels 6 UInt count Always RangeValidator[0, 31] Number of channels read from each sensor. It is assumed that all sensors have the same number of channels. If numSensors is 0, numChannels is also 0. In current implementation the limit should be 9. If we add a list of reading commands, it can be 9 per command. Limit 31 to be aligned with the 5bits of errorParameter.
portError 1 Bool boolean Always Whether there was an error reading the SDI-12 port. If true, no sensor or channel data is included in the message.
portData Switch Always
├── errorCode 3 Enum portError == 1 Type of error encountered on the SDI-12 port GENERIC (0), HW_FAILURE (1), NUM_CH_MISMATCH (2)
├── errorParameter 5 UInt count portError == 1 Number of channels read if errorCode is NUM_CH_MISMATCH, otherwise 0. It is useful to the user to understand how many channels is really reading.
└── Sensor Data [numSensors] Seq portError == 0 Data for each sensor read from the SDI-12 port
    ├── sensorError 1 Bool boolean Whether there was an error reading the sensor. If true, no channel data is included for this sensor.
    ├── errorCode 3 Enum sensorError == 1 Type of error encountered on the sensor GENERIC (0), NO_RESPONSE (1), PROTOCOL_ERR (2)
    └── Channel Data [numChannels] Seq sensorError == 0 Data for each channel read from the sensor
        ├── channelError 1 Bool boolean Whether there was an error reading the channel. If true, no channel data is included for this channel.
        ├── errorCode 3 Enum channelError == 1 Type of error encountered on the channel GENERIC (0), NAN (1), NEG_INF (2), POS_INF (3)
        ├── decimalPlace 3 UInt count channelError == 0 Number of decimal places for the channel value
        └── scaledInteger 25 Int channelError == 0 DynamicScalingMutator(decimalPlace) Scaled integer value for the channel. The actual value is obtained by applying the scaling factor based on the decimalPlace field.

Example

SDI12 generic single message with error

Source: DigGenSDI12GenericDataStrMessages.py

JSON Message

{
  "ls_header": {
    "uplink_version": {
      "value": "4",
      "raw": 4
    },
    "product_code": {
      "value": "89",
      "raw": 89
    },
    "node_id": {
      "value": "5",
      "raw": 5
    },
    "sequence_number": {
      "value": "5",
      "raw": 5
    },
    "am_type": {
      "value": "92",
      "raw": 92
    }
  },
  "readTimestamp": {
    "value": "1970-01-01T00:00:00Z",
    "raw": 0
  },
  "msgVersion": {
    "value": "0",
    "raw": 0
  },
  "portNumber": {
    "value": "0",
    "raw": 0
  },
  "totalFragments": {
    "value": "1",
    "raw": 0
  },
  "numFragment": {
    "value": "0",
    "raw": 0
  },
  "numRedundancyFragments": {
    "value": "0",
    "raw": 0
  },
  "integrationIdLength": {
    "value": "SHORT_ID",
    "raw": 0
  },
  "error": {
    "value": "NO_ERROR",
    "raw": 0
  },
  "rfu": {
    "value": "0",
    "raw": 0
  },
  "integrationId": {
    "value": "0",
    "raw": 0
  },
  "integrationIdMsgVersion": {
    "value": "0",
    "raw": 0
  },
  "readings": {
    "numSensors": {
      "value": "1",
      "raw": 1,
      "unit": "count"
    },
    "numChannels": {
      "value": "2",
      "raw": 2,
      "unit": "count"
    },
    "portError": {
      "value": true,
      "raw": true,
      "unit": "boolean"
    },
    "portData": {
      "errorCode": {
        "raw": 2,
        "value": "NUM_CH_MISMATCH"
      },
      "errorParameter": {
        "raw": 6,
        "value": "6",
        "unit": "count"
      }
    }
  }
}

Encoded Bytes

Source:

BitArray(
            "hex = 40 59 00 05 05 5c 00 00 00 00,"  # Header + readTimestamp
            # Start DigGen header
            "uint:3 = 0,"  # MsgVersion
            "uint:3 = 0,"  # portNumber
            "uint:5 = 0,"  # totalFragments (+1)
            "uint:5 = 0,"  # numFragment
            "uint:2 = 0,"  # numRedundancyFragments
            "uint:2 = 0,"  # integrationIdLength
            "uint:3 = 0,"  # error
            "uint:1 = 0,"  # rfu
            # End DigGen header
            "uint:8 = 0,"  # Payload 1st part (Integration Id, no padding)
            "uint:3 = 0,"  # IntegrationMsgVersion
            "uint:6 = 1,"  # numSensors
            "uint:6 = 2,"  # numChannels
            "bool = True,"  # portError
            "uint:3 = 2,"  # errorCode
            "uint:5 = 6,"  # errorParameter
        ).hex

Result:

40 59 00 05 05 5c 00 00 00 00 00 00 00 00 00 85 46