diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index abbca6e..497ee89 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@master with: - dotnet-version: 3.1.101 + dotnet-version: 3.1.302 - name: dotnet info run: dotnet --info - name: dotnet restore diff --git a/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj b/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj index cead57d..be4c399 100644 --- a/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj +++ b/src/JT809.Protocol.Test/JT809.Protocol.Test.csproj @@ -12,10 +12,10 @@ - + - + all runtime; build; native; contentfiles; analyzers diff --git a/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9200_0x9201Test.cs b/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9200_0x9201Test.cs new file mode 100644 index 0000000..38c13dd --- /dev/null +++ b/src/JT809.Protocol.Test/JT809SubMessageBody/JT809_0x9200_0x9201Test.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JT809.Protocol; +using JT809.Protocol.Extensions; +using JT809.Protocol.MessageBody; +using JT809.Protocol.Exceptions; +using JT809.Protocol.SubMessageBody; +using JT809.Protocol.Enums; +using JT809.Protocol.Internal; + +namespace JT809.Protocol.Test.JT809SubMessageBody +{ + public class JT809_0x9200_0x9201Test + { + private JT809Serializer JT809_2019_Serializer = new JT809Serializer(new DefaultGlobalConfig() { Version = JT809Version.JTT2019 }); + + /// + /// 1078qq群808432702:大兄弟提供的 + /// 由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过 + /// + [Fact] + public void Test1() + { + var bytes = "5B0000002F000004579200000004570101010000000000000000004EBC924F9201000000070400000004000189DA5D".ToHexBytes(); + JT809Package jT809_0X9200_0X9201 = JT809_2019_Serializer.Deserialize(bytes); + } + + /// + /// 1078qq群808432702:大兄弟提供的 + /// 由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过 + /// + [Fact] + public void Test2() + { + var bytes = "5B0000002F000004579200000004570101010000000000000000004EBC924F9201000000070400000004000189DA5D".ToHexBytes(); + string json = JT809_2019_Serializer.Analyze(bytes); + } + } +} diff --git a/src/JT809.Protocol/JT809.Protocol.csproj b/src/JT809.Protocol/JT809.Protocol.csproj index 3d0aab5..6d786e1 100644 --- a/src/JT809.Protocol/JT809.Protocol.csproj +++ b/src/JT809.Protocol/JT809.Protocol.csproj @@ -112,7 +112,7 @@ - + diff --git a/src/JT809.Protocol/MessageBody/JT809_0x9200.cs b/src/JT809.Protocol/MessageBody/JT809_0x9200.cs index 1e3ba4f..3163447 100644 --- a/src/JT809.Protocol/MessageBody/JT809_0x9200.cs +++ b/src/JT809.Protocol/MessageBody/JT809_0x9200.cs @@ -24,11 +24,17 @@ namespace JT809.Protocol.MessageBody public void Analyze(ref JT809MessagePackReader reader, Utf8JsonWriter writer, IJT809Config config) { JT809_0x9200 value = new JT809_0x9200(); - var virtualHex = reader.ReadVirtualArray(21); - value.VehicleNo = reader.ReadString(21); - writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); - value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); - writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString()); + //1078qq群808432702:大兄弟提供的 + //由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过 + var subBusinessType = reader.ReadVirtualUInt16(); + if (subBusinessType != JT809SubBusinessType.车辆注册信息应答消息.ToUInt16Value()) + { + var virtualHex = reader.ReadVirtualArray(21); + value.VehicleNo = reader.ReadString(21); + writer.WriteString($"[{virtualHex.ToArray().ToHexString()}]车牌号", value.VehicleNo); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + writer.WriteString($"[{value.VehicleColor.ToByteValue()}]车牌颜色", value.VehicleColor.ToString()); + } value.SubBusinessType = reader.ReadUInt16(); writer.WriteString($"[{value.SubBusinessType.ReadNumber()}]子业务类型标识", ((JT809SubBusinessType)value.SubBusinessType).ToString()); value.DataLength = reader.ReadUInt32(); @@ -57,8 +63,14 @@ namespace JT809.Protocol.MessageBody public JT809_0x9200 Deserialize(ref JT809MessagePackReader reader, IJT809Config config) { JT809_0x9200 value = new JT809_0x9200(); - value.VehicleNo = reader.ReadString(21); - value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + var subBusinessType = reader.ReadVirtualUInt16(); + //1078qq群808432702:大兄弟提供的 + //由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过 + if (subBusinessType != JT809SubBusinessType.车辆注册信息应答消息.ToUInt16Value()) + { + value.VehicleNo = reader.ReadString(21); + value.VehicleColor = (JT809VehicleColorType)reader.ReadByte(); + } value.SubBusinessType = reader.ReadUInt16(); value.DataLength = reader.ReadUInt32(); try @@ -85,8 +97,13 @@ namespace JT809.Protocol.MessageBody public void Serialize(ref JT809MessagePackWriter writer, JT809_0x9200 value, IJT809Config config) { - writer.WriteStringPadRight(value.VehicleNo, 21); - writer.WriteByte((byte)value.VehicleColor); + //1078qq群808432702:大兄弟提供的 + //由于车辆注册信息应答消息0x9201子业务不存在车牌号和颜色需要跳过 + if (value.SubBusinessType != JT809SubBusinessType.车辆注册信息应答消息.ToUInt16Value()) + { + writer.WriteStringPadRight(value.VehicleNo, 21); + writer.WriteByte((byte)value.VehicleColor); + } writer.WriteUInt16(value.SubBusinessType); try {