diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x0005Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x0005Test.cs index daa4ff1..442c7c9 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x0005Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x0005Test.cs @@ -29,5 +29,12 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(new byte[] { 0x01, 0x02, 0x02, 0x03 }, jT808_0X8005.AgainPackageData); Assert.Equal(2, jT808_0X8005.AgainPackageCount); } + + [Fact] + public void Test3() + { + var bytes = "04D20201020203".ToHexBytes(); + string json = JT808Serializer.Analyze(bytes); + } } } diff --git a/src/JT808.Protocol.Test/MessageBody/JT808_0x8606Test.cs b/src/JT808.Protocol.Test/MessageBody/JT808_0x8606Test.cs index fdf53eb..786a6b6 100644 --- a/src/JT808.Protocol.Test/MessageBody/JT808_0x8606Test.cs +++ b/src/JT808.Protocol.Test/MessageBody/JT808_0x8606Test.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using Xunit; using JT808.Protocol.Metadata; +using JT808.Protocol.Enums; namespace JT808.Protocol.Test.MessageBody { @@ -209,5 +210,90 @@ namespace JT808.Protocol.Test.MessageBody Assert.Equal(3, jT808_0X8606.InflectionPointItems[1].SectionProperty); Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth); } + + [Fact] + public void Test5_2019() + { + JT808_0x8606 jT808_0X8606 = new JT808_0x8606 + { + RouteId = 9999, + RouteProperty = 51, + StartTime = DateTime.Parse("2020-01-04 00:00:12"), + EndTime = DateTime.Parse("2020-01-04 00:00:12"), + InflectionPointItems = new List() + }; + jT808_0X8606.InflectionPointItems.Add(new JT808InflectionPointProperty() + { + InflectionPointId = 1000, + InflectionPointLat = 123456789, + InflectionPointLng = 123456788, + SectionDrivingUnderThreshold = 123, + SectionHighestSpeed = 69, + SectionId = 1287, + SectionLongDrivingThreshold = 50, + SectionOverspeedDuration = 23, + SectionProperty = 3, + SectionWidth = 56, + NightMaximumSpeed=80 + }); + jT808_0X8606.InflectionPointItems.Add(new JT808InflectionPointProperty() + { + InflectionPointId = 1001, + InflectionPointLat = 123456780, + InflectionPointLng = 123456781, + SectionDrivingUnderThreshold = 124, + SectionHighestSpeed = 42, + SectionId = 12007, + SectionLongDrivingThreshold = 58, + SectionOverspeedDuration = 26, + SectionProperty = 3, + SectionWidth = 75, + NightMaximumSpeed = 66 + }); + jT808_0X8606.RouteName = "koike518"; + var hex = JT808Serializer.Serialize(jT808_0X8606,JT808Version.JTT2019).ToHexString(); + Assert.Equal("0000270F00332001040000122001040000120002000003E800000507075BCD15075BCD1438030032007B0045170050000003E900002EE7075BCD0C075BCD0D4B03003A007C002A1A004200086B6F696B65353138", hex); + } + + [Fact] + public void Test6_2019() + { + byte[] bytes = "0000270F00332001040000122001040000120002000003E800000507075BCD15075BCD1438030032007B0045170050000003E900002EE7075BCD0C075BCD0D4B03003A007C002A1A004200086B6F696B65353138".ToHexBytes(); + JT808_0x8606 jT808_0X8606 = JT808Serializer.Deserialize(bytes, JT808Version.JTT2019); + + Assert.Equal((uint)9999, jT808_0X8606.RouteId); + Assert.Equal((uint)51, jT808_0X8606.RouteProperty); + Assert.Equal(DateTime.Parse("2020-01-04 00:00:12"), jT808_0X8606.StartTime); + Assert.Equal(DateTime.Parse("2020-01-04 00:00:12"), jT808_0X8606.EndTime); + + Assert.Equal(2, jT808_0X8606.InflectionPointItems.Count); + + Assert.Equal((uint)1000, jT808_0X8606.InflectionPointItems[0].InflectionPointId); + Assert.Equal((uint)123456789, jT808_0X8606.InflectionPointItems[0].InflectionPointLat); + Assert.Equal((uint)123456788, jT808_0X8606.InflectionPointItems[0].InflectionPointLng); + + Assert.Equal((ushort)123, jT808_0X8606.InflectionPointItems[0].SectionDrivingUnderThreshold); + Assert.Equal((ushort)69, jT808_0X8606.InflectionPointItems[0].SectionHighestSpeed); + Assert.Equal((uint)1287, jT808_0X8606.InflectionPointItems[0].SectionId); + Assert.Equal((ushort)50, jT808_0X8606.InflectionPointItems[0].SectionLongDrivingThreshold); + Assert.Equal((byte)23, jT808_0X8606.InflectionPointItems[0].SectionOverspeedDuration); + Assert.Equal(3, jT808_0X8606.InflectionPointItems[0].SectionProperty); + Assert.Equal(56, jT808_0X8606.InflectionPointItems[0].SectionWidth); + Assert.Equal(80, jT808_0X8606.InflectionPointItems[0].NightMaximumSpeed.Value); + + Assert.Equal((uint)1001, jT808_0X8606.InflectionPointItems[1].InflectionPointId); + Assert.Equal((uint)123456780, jT808_0X8606.InflectionPointItems[1].InflectionPointLat); + Assert.Equal((uint)123456781, jT808_0X8606.InflectionPointItems[1].InflectionPointLng); + Assert.Equal((ushort)124, jT808_0X8606.InflectionPointItems[1].SectionDrivingUnderThreshold); + Assert.Equal((ushort)42, jT808_0X8606.InflectionPointItems[1].SectionHighestSpeed); + Assert.Equal((uint)12007, jT808_0X8606.InflectionPointItems[1].SectionId); + Assert.Equal((ushort)58, jT808_0X8606.InflectionPointItems[1].SectionLongDrivingThreshold); + Assert.Equal((byte)26, jT808_0X8606.InflectionPointItems[1].SectionOverspeedDuration); + Assert.Equal(3, jT808_0X8606.InflectionPointItems[1].SectionProperty); + Assert.Equal(75, jT808_0X8606.InflectionPointItems[1].SectionWidth); + Assert.Equal(66, jT808_0X8606.InflectionPointItems[1].NightMaximumSpeed.Value); + + Assert.Equal("koike518", jT808_0X8606.RouteName); + } } } diff --git a/src/JT808.Protocol/JT808.Protocol.csproj b/src/JT808.Protocol/JT808.Protocol.csproj index 6e195aa..f461e52 100644 --- a/src/JT808.Protocol/JT808.Protocol.csproj +++ b/src/JT808.Protocol/JT808.Protocol.csproj @@ -14,7 +14,7 @@ https://github.com/SmallChi/JT808/blob/master/LICENSE https://github.com/SmallChi/JT808/blob/master/LICENSE false - 2.3.0-preview1 + 2.2.4 LICENSE diff --git a/src/JT808.Protocol/JT808.Protocol.xml b/src/JT808.Protocol/JT808.Protocol.xml index 1b4e3da..45bd743 100644 --- a/src/JT808.Protocol/JT808.Protocol.xml +++ b/src/JT808.Protocol/JT808.Protocol.xml @@ -6918,6 +6918,11 @@ 单位为秒(s),若路段属性 1 位为 0 则没有该字段 + + + 单位为千米每小时(km/h),若路段属性 1 位为 0 则没有该字段 + + 信息点播属性 diff --git a/src/JT808.Protocol/JT808Constants.cs b/src/JT808.Protocol/JT808Constants.cs index 879bbf3..8cc4c5f 100644 --- a/src/JT808.Protocol/JT808Constants.cs +++ b/src/JT808.Protocol/JT808Constants.cs @@ -22,6 +22,8 @@ namespace JT808.Protocol public const byte JT808_0x0200_0x02 = 0x02; public const byte JT808_0x0200_0x03 = 0x03; public const byte JT808_0x0200_0x04 = 0x04; + public const byte JT808_0x0200_0x05 = 0x05; + public const byte JT808_0x0200_0x06 = 0x06; public const byte JT808_0x0200_0x11 = 0x11; public const byte JT808_0x0200_0x12 = 0x12; public const byte JT808_0x0200_0x13 = 0x13; diff --git a/src/JT808.Protocol/JT808Package.cs b/src/JT808.Protocol/JT808Package.cs index be065c0..55d3414 100644 --- a/src/JT808.Protocol/JT808Package.cs +++ b/src/JT808.Protocol/JT808Package.cs @@ -269,11 +269,11 @@ namespace JT808.Protocol writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan.ToString()}]消息体属性", messageBodyPropertyValue); if (headerMessageBodyProperty.VersionFlag) { - writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan[0]}]保留", 0); - writer.WriteBoolean($"[{messageBodyPropertyReadOnlySpan[1]}]协议版本标识", headerMessageBodyProperty.VersionFlag); - writer.WriteBoolean($"[{messageBodyPropertyReadOnlySpan.Slice(2,1).ToString()}]是否分包", headerMessageBodyProperty.IsPackage); - writer.WriteString($"[{messageBodyPropertyReadOnlySpan.Slice(3,3).ToString()}]数据加密", headerMessageBodyProperty.Encrypt.ToString()); - writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan.Slice(7).ToString()}]消息体长度", headerMessageBodyProperty.DataLength); + writer.WriteNumber( "[bit15]保留", 0); + writer.WriteBoolean("[bit14]协议版本标识", headerMessageBodyProperty.VersionFlag); + writer.WriteBoolean("[bit13]是否分包", headerMessageBodyProperty.IsPackage); + writer.WriteString("[bit10~bit12]数据加密", headerMessageBodyProperty.Encrypt.ToString()); + writer.WriteNumber("[bit0~bit9]消息体长度", headerMessageBodyProperty.DataLength); //消息体属性对象 结束 writer.WriteEndObject(); //2019版本 @@ -285,11 +285,11 @@ namespace JT808.Protocol } else { - writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan[0]}]保留", 0); - writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan[1]}]保留", 0); - writer.WriteBoolean($"[{messageBodyPropertyReadOnlySpan.Slice(2, 1).ToString()}]是否分包", headerMessageBodyProperty.IsPackage); - writer.WriteString($"[{messageBodyPropertyReadOnlySpan.Slice(3, 3).ToString()}]数据加密", headerMessageBodyProperty.Encrypt.ToString()); - writer.WriteNumber($"[{messageBodyPropertyReadOnlySpan.Slice(7).ToString()}]消息体长度", headerMessageBodyProperty.DataLength); + writer.WriteNumber("[bit15]保留", 0); + writer.WriteNumber("[bit14]保留", 0); + writer.WriteBoolean("[bit13]是否分包", headerMessageBodyProperty.IsPackage); + writer.WriteString("[bit10~bit12]数据加密", headerMessageBodyProperty.Encrypt.ToString()); + writer.WriteNumber("[bit0~bit9]消息体长度", headerMessageBodyProperty.DataLength); writer.WriteEndObject(); //2013版本 // 3.3.读取终端手机号 @@ -375,6 +375,10 @@ namespace JT808.Protocol //数据体属性对象 结束 writer.WriteEndObject(); } + else + { + writer.WriteNull($"[Null]数据体"); + } } else { diff --git a/src/JT808.Protocol/JT808Serializer.cs b/src/JT808.Protocol/JT808Serializer.cs index 77d66e1..4367199 100644 --- a/src/JT808.Protocol/JT808Serializer.cs +++ b/src/JT808.Protocol/JT808Serializer.cs @@ -190,26 +190,26 @@ namespace JT808.Protocol public string Analyze(ReadOnlySpan bytes, JT808Version version = JT808Version.JTT2013, JsonWriterOptions options = default, int minBufferSize = 8096) { byte[] buffer = JT808ArrayPool.Rent(minBufferSize); - byte[] buffer1 = JT808ArrayPool.Rent(minBufferSize); try { - JT808MessagePackReader jT808MessagePackReader = new JT808MessagePackReader(bytes, version); if (CheckPackageType(typeof(T))) jT808MessagePackReader.Decode(buffer); var analyze = jT808Config.GetAnalyze(); - using (MemoryStream memoryStream = new MemoryStream(buffer1)) + using (MemoryStream memoryStream = new MemoryStream()) using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options)) { + if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteStartObject(); analyze.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config); + if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteEndObject(); utf8JsonWriter.Flush(); - return utf8JsonWriter.ToString(); + string value = Encoding.UTF8.GetString(memoryStream.ToArray()); + return value; } } finally { JT808ArrayPool.Return(buffer); - JT808ArrayPool.Return(buffer1); } } @@ -246,7 +246,9 @@ namespace JT808.Protocol using (MemoryStream memoryStream = new MemoryStream()) using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options)) { + if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteStartObject(); analyze.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config); + if (!CheckPackageType(typeof(T))) utf8JsonWriter.WriteEndObject(); utf8JsonWriter.Flush(); return memoryStream.ToArray(); } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0005.cs b/src/JT808.Protocol/MessageBody/JT808_0x0005.cs index 93d8642..71086a8 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0005.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0005.cs @@ -1,6 +1,8 @@ using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; +using JT808.Protocol.Extensions; +using System.Text.Json; namespace JT808.Protocol.MessageBody { @@ -8,7 +10,7 @@ namespace JT808.Protocol.MessageBody /// 终端补传分包请求 /// 2019版本 /// - public class JT808_0x0005 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version + public class JT808_0x0005 : JT808Bodies, IJT808MessagePackFormatter, IJT808_2019_Version, IJT808Analyze { public override ushort MsgId { get; } = 0x0005; public override string Description => "终端补传分包请求"; @@ -28,6 +30,7 @@ namespace JT808.Protocol.MessageBody /// 重传包序号顺序排列,如“包 ID1 包 ID2......包 IDn”。 /// public byte[] AgainPackageData { get; set; } + public JT808_0x0005 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { JT808_0x0005 value = new JT808_0x0005(); @@ -42,5 +45,21 @@ namespace JT808.Protocol.MessageBody writer.WriteByte((byte)(value.AgainPackageData.Length / 2)); writer.WriteArray(value.AgainPackageData); } + + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + var originalMsgNum = reader.ReadUInt16(); + var againPackageCount = reader.ReadByte(); + var againPackageData = reader.ReadArray(againPackageCount * 2); + writer.WriteNumber($"[{originalMsgNum.ReadNumber()}]原始消息流水号", originalMsgNum); + writer.WriteNumber($"[{againPackageCount.ReadNumber()}]重传包总数", againPackageCount); + writer.WriteString("重传包ID", string.Join(",", againPackageData.ToArray())); + writer.WriteStartArray("重传包ID列表"); + for (var i=0;i< againPackageCount; i++) + { + writer.WriteStringValue(string.Join(",",againPackageData.Slice(i*2,2).ToArray())); + } + writer.WriteEndArray(); + } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x01.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x01.cs index d38e25f..615efa4 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x01.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x01.cs @@ -6,7 +6,7 @@ namespace JT808.Protocol.MessageBody { public class JT808_0x0200_0x01 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter { - public override byte AttachInfoId { get; set; } = 0x01; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x01; public override byte AttachInfoLength { get; set; } = 4; /// /// 里程 diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x02.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x02.cs index ff0b914..68c7f4f 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x02.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x02.cs @@ -15,7 +15,7 @@ namespace JT808.Protocol.MessageBody /// [IgnoreDataMember] public double ConvertOil => Oil / 10.0; - public override byte AttachInfoId { get; set; } = 0x02; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x02; public override byte AttachInfoLength { get; set; } = 2; public JT808_0x0200_0x02 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x03.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x03.cs index 46a886c..52ba1af 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x03.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x03.cs @@ -16,7 +16,7 @@ namespace JT808.Protocol.MessageBody /// [IgnoreDataMember] public double ConvertSpeed => Speed / 10.0; - public override byte AttachInfoId { get; set; } = 0x03; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x03; public override byte AttachInfoLength { get; set; } = 2; public JT808_0x0200_0x03 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x04.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x04.cs index 2382d37..5ed9a19 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x04.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x04.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.MessageBody /// 需要人工确认报警事件的 ID,从 1 开始计数 /// public ushort EventId { get; set; } - public override byte AttachInfoId { get; set; } = 0x04; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x04; public override byte AttachInfoLength { get; set; } = 2; public JT808_0x0200_0x04 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x05.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x05.cs index 9794fb5..cb59e46 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x05.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x05.cs @@ -14,8 +14,8 @@ namespace JT808.Protocol.MessageBody /// /// 胎压 /// - public string TirePressure { get; set; } - public override byte AttachInfoId { get; set; } = 0x05; + public byte[] TirePressure { get; set; } + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x05; public override byte AttachInfoLength { get; set; } = 30; public JT808_0x0200_0x05 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) @@ -23,7 +23,7 @@ namespace JT808.Protocol.MessageBody JT808_0x0200_0x05 value = new JT808_0x0200_0x05(); value.AttachInfoId = reader.ReadByte(); value.AttachInfoLength = reader.ReadByte(); - value.TirePressure = reader.ReadString(value.AttachInfoLength); + value.TirePressure = reader.ReadArray(value.AttachInfoLength).ToArray(); return value; } @@ -31,7 +31,7 @@ namespace JT808.Protocol.MessageBody { writer.WriteByte(value.AttachInfoId); writer.WriteByte(value.AttachInfoLength); - writer.WriteString(value.TirePressure); + writer.WriteArray(value.TirePressure); } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x06.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x06.cs index 2e21478..b737ecd 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x06.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x06.cs @@ -15,7 +15,7 @@ namespace JT808.Protocol.MessageBody /// 车厢温度 /// public short CarTemperature { get; set; } - public override byte AttachInfoId { get; set; } = 0x05; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x06; public override byte AttachInfoLength { get; set; } = 2; public JT808_0x0200_0x06 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x11.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x11.cs index e43c8a3..79001ce 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x11.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x11.cs @@ -21,7 +21,7 @@ namespace JT808.Protocol.MessageBody /// 若位置类型为 0,无该字段 /// public uint AreaId { get; set; } - public override byte AttachInfoId { get; set; } = 0x11; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x11; public override byte AttachInfoLength { get diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x12.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x12.cs index c2c147c..f05fc5d 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x12.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x12.cs @@ -26,7 +26,7 @@ namespace JT808.Protocol.MessageBody /// 1:出 /// public JT808DirectionType Direction { get; set; } - public override byte AttachInfoId { get; set; } = 0x12; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x12; public override byte AttachInfoLength { get; set; } = 6; public JT808_0x0200_0x12 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x13.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x13.cs index 8a8c4d6..7b6cf04 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x13.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x13.cs @@ -6,7 +6,7 @@ namespace JT808.Protocol.MessageBody { public class JT808_0x0200_0x13 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter { - public override byte AttachInfoId { get; set; } = 0x13; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x13; public override byte AttachInfoLength { get; set; } = 7; /// diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x25.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x25.cs index 9462f38..aa66726 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x25.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x25.cs @@ -9,7 +9,7 @@ namespace JT808.Protocol.MessageBody /// 扩展车辆信号状态位 /// public int CarSignalStatus { get; set; } - public override byte AttachInfoId { get; set; } = 0x25; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x25; public override byte AttachInfoLength { get; set; } = 4; public JT808_0x0200_0x25 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2A.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2A.cs index 1113c38..115970e 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2A.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2A.cs @@ -9,7 +9,7 @@ namespace JT808.Protocol.MessageBody /// IO状态位 /// public ushort IOStatus { get; set; } - public override byte AttachInfoId { get; set; } = 0x2A; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x2A; public override byte AttachInfoLength { get; set; } = 2; public JT808_0x0200_0x2A Deserialize(ref JT808MessagePackReader reader, IJT808Config config) diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2B.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2B.cs index 5cfd8c9..d0e43eb 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2B.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x2B.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.MessageBody /// 模拟量 bit0-15,AD0;bit16-31,AD1 /// public int Analog { get; set; } - public override byte AttachInfoId { get; set; } = 0x2B; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x2B; public override byte AttachInfoLength { get; set; } = 4; public JT808_0x0200_0x2B Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x30.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x30.cs index a385648..db8101a 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x30.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x30.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.MessageBody /// 无线通信网络信号强度 /// public byte WiFiSignalStrength { get; set; } - public override byte AttachInfoId { get; set; } = 0x30; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x30; public override byte AttachInfoLength { get; set; } = 1; public JT808_0x0200_0x30 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x31.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x31.cs index 048dc80..faa3f89 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_0x31.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_0x31.cs @@ -9,7 +9,7 @@ namespace JT808.Protocol.MessageBody /// GNSS 定位卫星数 /// public byte GNSSCount { get; set; } - public override byte AttachInfoId { get; set; } = 0x31; + public override byte AttachInfoId { get; set; } = JT808Constants.JT808_0x0200_0x31; public override byte AttachInfoLength { get; set; } = 1; public JT808_0x0200_0x31 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) { diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8606.cs b/src/JT808.Protocol/MessageBody/JT808_0x8606.cs index f759853..eb3fe9e 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8606.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8606.cs @@ -87,13 +87,15 @@ namespace JT808.Protocol.MessageBody { jT808InflectionPointProperty.SectionHighestSpeed = reader.ReadUInt16(); jT808InflectionPointProperty.SectionOverspeedDuration = reader.ReadByte(); + if (reader.Version == JT808Version.JTT2019) + jT808InflectionPointProperty.NightMaximumSpeed = reader.ReadUInt16(); } jT808_0X8606.InflectionPointItems.Add(jT808InflectionPointProperty); - if (reader.Version == JT808Version.JTT2019) - { - jT808_0X8606.RouteNameLength = reader.ReadUInt16(); - jT808_0X8606.RouteName = reader.ReadString(jT808_0X8606.RouteNameLength); - } + } + if (reader.Version == JT808Version.JTT2019) + { + jT808_0X8606.RouteNameLength = reader.ReadUInt16(); + jT808_0X8606.RouteName = reader.ReadString(jT808_0X8606.RouteNameLength); } return jT808_0X8606; } @@ -141,6 +143,11 @@ namespace JT808.Protocol.MessageBody writer.WriteUInt16(item.SectionHighestSpeed.Value); if (item.SectionOverspeedDuration.HasValue) writer.WriteByte(item.SectionOverspeedDuration.Value); + if (writer.Version == JT808Version.JTT2019) + { + if (item.NightMaximumSpeed.HasValue) + writer.WriteUInt16(item.NightMaximumSpeed.Value); + } } } } diff --git a/src/JT808.Protocol/Metadata/JT808InflectionPointProperty.cs b/src/JT808.Protocol/Metadata/JT808InflectionPointProperty.cs index 0747ad3..2d8d1d2 100644 --- a/src/JT808.Protocol/Metadata/JT808InflectionPointProperty.cs +++ b/src/JT808.Protocol/Metadata/JT808InflectionPointProperty.cs @@ -52,5 +52,9 @@ /// 单位为秒(s),若路段属性 1 位为 0 则没有该字段 /// public byte? SectionOverspeedDuration { get; set; } + /// + /// 单位为千米每小时(km/h),若路段属性 1 位为 0 则没有该字段 + /// + public ushort? NightMaximumSpeed { get; set; } } }