Skip to content

Commit 317bb93

Browse files
committed
Minor improvements to Logging Malformed Packages by Netron Obsidian RDM10 Devices.
Make ArtDmx deserializer resilient against to short Package Wrote Test for RDM10 shorter ArtDMX Packages Improve Loopback detection. Bump v0.0.31
1 parent 6012691 commit 317bb93

6 files changed

Lines changed: 14 additions & 5 deletions

File tree

ArtNetSharp/ArtNet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ private void ProcessReceivedData(UdpReceiveResult result)
408408
}
409409
return;
410410
}
411-
Logger.LogWarning($"Can't deserialize Data to ArtNet-Packet");
411+
Logger.LogWarning($"Can't deserialize Data to ArtNet-Packet from {sourceIp}");
412412
}
413413
catch (ObjectDisposedException ed) { Logger.LogTrace(ed); }
414414
catch (SocketException se) { Logger.LogTrace(se); }

ArtNetSharp/ArtNetSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
44
<PackageLicenseFile>LICENSE</PackageLicenseFile>
5-
<Version>0.0.30</Version>
5+
<Version>0.0.31</Version>
66
<RepositoryUrl>https://github.com/DMXControl/ArtNetSharp</RepositoryUrl>
77
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
88
<PackageTags>RDM; ArtNet; E1.20; E1.33; E1.37-1; E1.37-2; E1.37-7</PackageTags>

ArtNetSharp/Communication/AbstractInstance.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ private void processArtPollReply(ArtPollReply artPollReply, IPv4Address localIp,
789789
&& MinorVersion == artPollReply.MinorVersion
790790
&& OEMProductCode == artPollReply.OemCode
791791
&& ESTAManufacturerCode == artPollReply.ManufacturerCode
792-
&& IPv4Address.Equals(sourceIp, localIp)
793792
&& IPv4Address.Equals(artPollReply.OwnIp, localIp)
794793
&& string.Equals(artPollReply.ShortName, ShortName)
795794
&& string.Equals(artPollReply.LongName, Name))
@@ -1276,7 +1275,7 @@ private async void TimerSendPoll_Elapsed(object sender, EventArgs e)
12761275
if (remoteClients.TryRemove(rc.Key, out RemoteClient removed))
12771276
remoteClientsTimeouted.TryAdd(removed.ID, removed);
12781277
else
1279-
Logger.LogWarning($"Can't remove RemoteClient from ConcurrentDictionary");
1278+
Logger.LogWarning($"Can't remove RemoteClient({removed.ID}) from ConcurrentDictionary");
12801279

12811280
if (removed != null)
12821281
{

ArtNetSharp/Communication/RemoteClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private async void OnSendArtPoll(object sender, EventArgs e)
278278
foreach (var port in timoutedPorts)
279279
{
280280
if (!ports.TryRemove(port.Key, out _))
281-
Logger.LogWarning($"Can't remove RemoteClientPort from ConcurrentDictionary");
281+
Logger.LogWarning($"Can't remove RemoteClientPort ({port.Key}) from ConcurrentDictionary");
282282
_ = Task.Run(() => PortTimedOut?.InvokeFailSafe(this, port));
283283
}
284284
}

ArtNetSharp/Messages/ArtDMX.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public ArtDMX(in byte[] packet) : base(packet)
5353
ushort length = (ushort)((packet[16] << 8) | packet[17]);
5454
if (length <= 512)
5555
{
56+
length = (ushort)(Math.Max(0, Math.Min(length, packet.Length - 18)));
5657
Data = new byte[length];
5758
Array.Copy(packet, 18, Data, 0, length);
5859
return;

ArtNetTests/PackagesSerializeDeserialize.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ public void Tools_TryDeserializePacket()
3838
data = data.Take(22).ToArray();
3939
Assert.That(ArtNetSharp.Tools.TryDeserializePacket(data, out _), Is.False);
4040
}
41+
[Test]
42+
public void Tools_TryDeserializePacketFromRaw()
43+
{
44+
byte[]? data = new byte[] { 0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x1a, 0x01, 0x01, 0x00, 0x02, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x4d, 0x14, 0xff, 0xff, 0xff, 0x33, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x4d, 0x14, 0xff, 0xff, 0xff, 0x33, 0x80, 0x00, 0x00, 0x59, 0x14, 0xff, 0xff, 0xff, 0x33, 0x80, 0x00, 0x00, 0x1c, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x1c, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x59, 0x14, 0xff, 0xff, 0xff };
45+
Assert.That(ArtNetSharp.Tools.TryDeserializePacket(data, out AbstractArtPacketCore packet), Is.True);
46+
47+
data = new byte[] { 0x41, 0x72, 0x74, 0x2d, 0x4e, 0x65, 0x74, 0x00, 0x00, 0x50, 0x00, 0x0e, 0x1a, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x50, 0x6f, 0x72, 0x74, 0x20, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x4d, 0x14, 0xff, 0xff, 0xff, 0x33, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x02, 0x00, 0x01, 0x40, 0xff, 0xaa, 0x80, 0x80, 0x00, 0x02, 0x14, 0x00, 0xff, 0xff, 0xaa, 0x01, 0x00, 0x00, 0x02, 0x01, 0xff, 0xff, 0xff, 0x64, 0x80, 0x00, 0x00, 0x4d, 0x14, 0xff, 0xff, 0xff, 0x33, 0x80, 0x00, 0x00, 0x59, 0x14, 0xff, 0xff, 0x02, 0x33, 0xc0, 0x00, 0x00, 0x1c, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x1c, 0x14, 0xff, 0xff, 0xff, 0xaa, 0x80, 0x00, 0x00, 0x59, 0x14, 0xff, 0xff, 0xff };
48+
Assert.That(ArtNetSharp.Tools.TryDeserializePacket(data, out packet), Is.True);
49+
}
4150

4251
[Test]
4352
public void ArtSync()

0 commit comments

Comments
 (0)