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
221 stars 129 forks source link

Javascript: sparkplug-payload -> Possible to specify converion options when decoding payload? #384

Open bj00rn opened 4 months ago

bj00rn commented 4 months ago

Hi, Is it possible to specify conversion options for longs etc, when decoding payload?

We coming from using protobufjs with sparkplug protocol and using toObject by specified conversion options:

import * as protobuf from 'protobufjs'
import protocol from './sparkplugb.proto'
const root = protobuf.parse(protocol).root
let SparkplugPayload = root.lookupType('com.cirruslink.sparkplug.protobuf.Payload')
let decodedObj = SparkplugPayload.toObject(SparkplugPayload.decode(new Uint8Array(input)), {longs: Number})

I would like to use sparkplug-payload instead for decoding, but now my long timestamps are no longer converted.

import { get } from 'sparkplug-payload'
let sparkplug = get("spBv1.0")
let decodedObj = sparkplug.decodePayload(new Uint8Array(input)))

image

Cheers!