eclipse / tahu

Eclipse Tahu addresses the existence of legacy SCADA/DCS/ICS protocols and infrastructures and provides a much-needed definition of how best to apply MQTT into these existing industrial operational environments.
https://eclipse.org/tahu
Eclipse Public License 2.0
216 stars 123 forks source link

How to encode bytes values and array data types? #353

Closed SeppPenner closed 4 months ago

SeppPenner commented 4 months ago

I have checked https://github.com/eclipse/tahu/blob/5736e404889d4b95910613040a99ba79589ffb13/java/lib/core/src/main/java/org/eclipse/tahu/message/SparkplugBPayloadEncoder.java#L377 where the encoder does metricBuilder.setBytesValue(ByteString.copyFrom((byte[]) metric.getValue())); --> I have checked the Protobuf class and seen the following:

public Builder setBytesValue(com.google.protobuf.ByteString value) {
    if (value == null) {
        throw new NullPointerException();
    }

    valueCase_ = 16;
    value_ = value;
    onChanged();
    return this;
}

but I don't understand how the data is stored in the value. Is this a Hex-String of the byte stored as string value in Protobuf? The same question for the array data types like In8Array or DateTimeArray. It would be nice if someone could give me an example on what to do here as I'm currently really struggeling with these conversions in my project https://github.com/SeppPenner/SparkplugNet...

SeppPenner commented 4 months ago

I found it, seems like I was missing the bytes value in the Protobuf equivalenbt (Or the bytes value wasn't present for some other types).