var payload = new SparkplugNet.VersionB.Data.Payload
{
Metrics = new Metric[] { new SparkplugNet.VersionB.Data.Metric()
{
BytesValue = new byte[]{1,2,3,4}
}
}.ToList(),
Seq = (ulong)1,
Timestamp = (ulong)DateTimeOffset.Now.ToUnixTimeMilliseconds()
};
var payloadConverter = typeof(SparkplugNet.VersionB.SparkplugNode).Assembly.GetType("SparkplugNet.Core.PayloadConverter");
var convertMetric = payloadConverter.GetMethod("ConvertVersionBPayload", new Type[] { typeof(SparkplugNet.VersionB.Data.Payload) });
var result = convertMetric.Invoke(null, new object[] { payload });
var metrics = result.GetType().GetProperty("Metrics").GetValue(result);
var metric = ((IList)metrics)[0];
var byteValues = metric.GetType().GetProperty("BytesValue").GetValue(metric);
var dataType = metric.GetType().GetProperty("Datatype").GetValue(metric);
Console.WriteLine($"{dataType} : Items={string.Join(",", ((byte[])byteValues))} Length={((byte[])byteValues).Length}" );
Hi,
The SparkplugNet.Core.PayloadConverter.ConvertVersionBPayload seems to remove data if the data type is Bytes.
Here is a snippet to reproduce the issue: