瀏覽代碼

在完成协议开发的同时,把对应协议的分析工具也做好。

1.增加协议分析工具接口
2.增加信息描述接口
tags/v2.2.4
SmallChi(Koike) 5 年之前
父節點
當前提交
76ea898d7b
共有 83 個文件被更改,包括 519 次插入22 次删除
  1. +52
    -0
      src/JT808.Protocol.Test/Extensions/JT808HexExtensionsTest.cs
  2. +1
    -0
      src/JT808.Protocol.Test/JT808.Protocol.Test.csproj
  3. +8
    -0
      src/JT808.Protocol.Test/MessageBody/JT808_0x0001Test.cs
  4. +2
    -0
      src/JT808.Protocol.Test/MessageBody/JT808_0x9999.cs
  5. +5
    -0
      src/JT808.Protocol.Test/Simples/Demo6.cs
  6. +12
    -0
      src/JT808.Protocol/Extensions/JT808ConfigExtensions.cs
  7. +48
    -6
      src/JT808.Protocol/Extensions/JT808HexExtensions.cs
  8. +11
    -0
      src/JT808.Protocol/Interfaces/IJT808Analyze.cs
  9. +11
    -0
      src/JT808.Protocol/Interfaces/IJT808Description.cs
  10. +3
    -2
      src/JT808.Protocol/JT808.Protocol.csproj
  11. +6
    -2
      src/JT808.Protocol/JT808Bodies.cs
  12. +163
    -4
      src/JT808.Protocol/JT808Package.cs
  13. +95
    -0
      src/JT808.Protocol/JT808Serializer.cs
  14. +2
    -0
      src/JT808.Protocol/JT808SplitPackageBodies.cs
  15. +16
    -2
      src/JT808.Protocol/MessageBody/JT808_0x0001.cs
  16. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0002.cs
  17. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0003.cs
  18. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0004.cs
  19. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0005.cs
  20. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0100.cs
  21. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0102.cs
  22. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0104.cs
  23. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0107.cs
  24. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0108.cs
  25. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0200.cs
  26. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0201.cs
  27. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0301.cs
  28. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0302.cs
  29. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0303.cs
  30. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0500.cs
  31. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0608.cs
  32. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0701.cs
  33. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0702.cs
  34. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0704.cs
  35. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0705.cs
  36. +2
    -2
      src/JT808.Protocol/MessageBody/JT808_0x0800.cs
  37. +2
    -2
      src/JT808.Protocol/MessageBody/JT808_0x0801.cs
  38. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0802.cs
  39. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0805.cs
  40. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0900.cs
  41. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0901.cs
  42. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x0A00.cs
  43. +2
    -2
      src/JT808.Protocol/MessageBody/JT808_0x8001.cs
  44. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8003.cs
  45. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8004.cs
  46. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8100.cs
  47. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8103.cs
  48. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8104.cs
  49. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8105.cs
  50. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8106.cs
  51. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8107.cs
  52. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8108.cs
  53. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8201.cs
  54. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8202.cs
  55. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8203.cs
  56. +2
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8204.cs
  57. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8300.cs
  58. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8301.cs
  59. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8302.cs
  60. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8303.cs
  61. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8304.cs
  62. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8400.cs
  63. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8401.cs
  64. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8500.cs
  65. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8600.cs
  66. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8601.cs
  67. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8602.cs
  68. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8603.cs
  69. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8604.cs
  70. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8605.cs
  71. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8606.cs
  72. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8607.cs
  73. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8608.cs
  74. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8702.cs
  75. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8800.cs
  76. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8801.cs
  77. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8802.cs
  78. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8803.cs
  79. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8804.cs
  80. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8805.cs
  81. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8900.cs
  82. +1
    -0
      src/JT808.Protocol/MessageBody/JT808_0x8A00.cs
  83. +5
    -0
      src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs

+ 52
- 0
src/JT808.Protocol.Test/Extensions/JT808HexExtensionsTest.cs 查看文件

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
using JT808.Protocol.Extensions;

namespace JT808.Protocol.Test.Extensions
{
public class JT808HexExtensionsTest
{
[Fact]
public void Test1()
{
ushort a1 = 512;
string hex1 = a1.ReadNumber();
Assert.Equal("0200", hex1);

byte a2 = 126;
string hex2 = a2.ReadNumber();
Assert.Equal("7E", hex2);

ushort a3 = 126;
string hex3 = a3.ReadNumber();
Assert.Equal("007E", hex3);

short a4 = 126;
string hex4 = a4.ReadNumber();
Assert.Equal("007E", hex4);

int a5 = 126;
string hex5 = a5.ReadNumber();
Assert.Equal("0000007E", hex5);

uint a6 = 126;
string hex6 = a6.ReadNumber();
Assert.Equal("0000007E", hex6);


long a7 = 126;
string hex7 = a7.ReadNumber();
Assert.Equal("000000000000007E", hex7);

ulong a8 = 126;
string hex8 = a8.ReadNumber();
Assert.Equal("000000000000007E", hex8);

ulong a9 = 191204091818;
string hex9 = a9.ReadNumber("D12");
Assert.Equal("191204091818", hex9);
}
}
}

+ 1
- 0
src/JT808.Protocol.Test/JT808.Protocol.Test.csproj 查看文件

@@ -26,6 +26,7 @@

<ItemGroup>
<Compile Include="Extensions\JT808EnumExtensionsTest.cs" />
<Compile Include="Extensions\JT808HexExtensionsTest.cs" />
<Compile Include="Extensions\JT808PackageExtensionsTest.cs" />
<Compile Include="MessageBody\JT808LocationAttachExtensions\JT808LocationAttachImpl0x06.cs" />
<Compile Include="MessageBody\JT808_0x0001Test.cs" />


+ 8
- 0
src/JT808.Protocol.Test/MessageBody/JT808_0x0001Test.cs 查看文件

@@ -44,5 +44,13 @@ namespace JT808.Protocol.Test.MessageBody
Assert.Equal(1000, JT808Bodies.ReplyMsgNum);
Assert.Equal(Enums.JT808TerminalResult.Success, JT808Bodies.JT808TerminalResult);
}

[Fact]
public void Test3()
{
var bytes = "7E 00 01 00 05 01 23 45 67 89 00 04 B3 03 E8 00 02 00 D3 7E".ToHexBytes();
string json = JT808Serializer.Analyze(bytes);
//{"[7E]\u5F00\u59CB":126,"[0001]\u6D88\u606FId":1,"\u6D88\u606F\u4F53\u5C5E\u6027\u5BF9\u8C61":{"[0000000000000101]\u6D88\u606F\u4F53\u5C5E\u6027":5,"[0]\u4FDD\u7559":0,"[0]\u4FDD\u7559":0,"[0]\u662F\u5426\u5206\u5305":false,"[000]\u6570\u636E\u52A0\u5BC6":"None","[000000101]\u6D88\u606F\u4F53\u957F\u5EA6":5},"[12345678900]\u7EC8\u7AEF\u624B\u673A\u53F7":"12345678900","[04B3]\u6D88\u606F\u6D41\u6C34\u53F7":1203,"\u6570\u636E\u4F53\u5BF9\u8C61":{"\u7EC8\u7AEF\u901A\u7528\u5E94\u7B54":"03E8000200","[03E8]\u5E94\u7B54\u6D41\u6C34\u53F7":1000,"[0002]\u5E94\u7B54\u6D88\u606FId":2,"[0]\u7ED3\u679C":"Success"},"[D3]\u6821\u9A8C\u7801":211,"[D3]\u7ED3\u675F":211}
}
}
}

+ 2
- 0
src/JT808.Protocol.Test/MessageBody/JT808_0x9999.cs 查看文件

@@ -12,6 +12,8 @@ namespace JT808.Protocol.Test.MessageBody

public override ushort MsgId => 0x9999;

public override string Description => "自定义消息";

public JT808_0x9999 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
{
JT808_0x9999 jT808_0X9999 = new JT808_0x9999();


+ 5
- 0
src/JT808.Protocol.Test/Simples/Demo6.cs 查看文件

@@ -148,6 +148,8 @@ namespace JT808.Protocol.Test.Simples

public override ushort MsgId => 0x91;

public override string Description =>"DT1Demo6";

public DT1Demo6 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
{
DT1Demo6 dT1Demo6 = new DT1Demo6();
@@ -169,6 +171,9 @@ namespace JT808.Protocol.Test.Simples
public byte Sex2 { get; set; }

public ushort Age2 { get; set; }

public override string Description => "DT2Demo6";

public DT2Demo6 Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
{
DT2Demo6 dT2Demo6 = new DT2Demo6();


+ 12
- 0
src/JT808.Protocol/Extensions/JT808ConfigExtensions.cs 查看文件

@@ -18,10 +18,22 @@ namespace JT808.Protocol
}
return formatter;
}
public static object GetAnalyzeByType(this IJT808Config jT808Config, Type type)
{
if (!jT808Config.FormatterFactory.FormatterDict.TryGetValue(type.GUID, out var analyze))
{
throw new JT808Exception(JT808ErrorCode.NotGlobalRegisterFormatterAssembly, type.FullName);
}
return analyze;
}
public static IJT808MessagePackFormatter<T> GetMessagePackFormatter<T>(this IJT808Config jT808Config)
{
return (IJT808MessagePackFormatter<T>)GetMessagePackFormatterByType(jT808Config,typeof(T));
}
public static IJT808Analyze GetAnalyze<T>(this IJT808Config jT808Config)
{
return (IJT808Analyze)GetAnalyzeByType(jT808Config, typeof(T));
}
public static JT808Serializer GetSerializer(this IJT808Config jT808Config)
{
if(!jT808SerializerDict.TryGetValue(jT808Config.ConfigId,out var serializer))


+ 48
- 6
src/JT808.Protocol/Extensions/JT808HexExtensions.cs 查看文件

@@ -71,12 +71,54 @@ namespace JT808.Protocol.Extensions
return hex;
}

/// <summary>
/// Copyright (c) Microsoft. All rights reserved.
/// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/// <see cref="DotNetty.Buffers.ByteBufferUtil"/>
/// </summary>

public static string ReadNumber(this byte value, string format = "X1")
{
return value.ToString(format);
}
public static string ReadNumber(this int value, string format = "X8")
{
return value.ToString(format);
}
public static string ReadNumber(this uint value, string format = "X8")
{
return value.ToString(format);
}
public static string ReadNumber(this long value, string format = "X16")
{
return value.ToString(format);
}
public static string ReadNumber(this ulong value, string format="X16")
{
return value.ToString(format);
}
public static string ReadNumber(this short value, string format = "X4")
{
return value.ToString(format);
}
public static string ReadNumber(this ushort value, string format = "X4")
{
return value.ToString(format);
}
public static ReadOnlySpan<char> ReadBinary(this ushort value)
{
return System.Convert.ToString(value, 2).PadLeft(16, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this short value)
{
return System.Convert.ToString(value, 2).PadLeft(16, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this uint value)
{
return System.Convert.ToString(value, 2).PadLeft(32, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this int value)
{
return System.Convert.ToString(value, 2).PadLeft(32, '0').AsSpan();
}
public static ReadOnlySpan<char> ReadBinary(this byte value)
{
return System.Convert.ToString(value, 2).PadLeft(8, '0').AsSpan();
}
}

public static class HexUtil


+ 11
- 0
src/JT808.Protocol/Interfaces/IJT808Analyze.cs 查看文件

@@ -0,0 +1,11 @@
using JT808.Protocol.MessagePack;
using System;
using System.Text.Json;

namespace JT808.Protocol.Interfaces
{
public interface IJT808Analyze
{
void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config);
}
}

+ 11
- 0
src/JT808.Protocol/Interfaces/IJT808Description.cs 查看文件

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace JT808.Protocol.Interfaces
{
public interface IJT808Description
{
string Description { get;}
}
}

+ 3
- 2
src/JT808.Protocol/JT808.Protocol.csproj 查看文件

@@ -14,7 +14,7 @@
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl>
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>2.2.3</Version>
<Version>2.3.0-preview1</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@@ -57,7 +57,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.6.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
@@ -72,6 +72,7 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" />
<PackageReference Include="System.Text.Json" Version="4.7.0" />
</ItemGroup>
<ItemGroup>


+ 6
- 2
src/JT808.Protocol/JT808Bodies.cs 查看文件

@@ -1,6 +1,8 @@
namespace JT808.Protocol
using JT808.Protocol.Interfaces;

namespace JT808.Protocol
{
public abstract class JT808Bodies
public abstract class JT808Bodies: IJT808Description
{
/// <summary>
/// 跳过数据体序列化
@@ -10,5 +12,7 @@
public virtual bool SkipSerialization { get; set; } = false;

public abstract ushort MsgId { get;}

public abstract string Description { get; }
}
}

+ 163
- 4
src/JT808.Protocol/JT808Package.cs 查看文件

@@ -1,17 +1,18 @@
using JT808.Protocol.Attributes;
using JT808.Protocol.Enums;
using JT808.Protocol.Enums;
using JT808.Protocol.Exceptions;
using JT808.Protocol.Extensions;
using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces;
using JT808.Protocol.MessagePack;
using System;
using System.Text.Json;

namespace JT808.Protocol
{
/// <summary>
/// JT808数据包
/// </summary>
public class JT808Package:IJT808MessagePackFormatter<JT808Package>
public class JT808Package:IJT808MessagePackFormatter<JT808Package>, IJT808Analyze
{
/// <summary>
/// 起始符
@@ -170,7 +171,6 @@ namespace JT808.Protocol
}
}
}
// 5.读取校验码
jT808Package.CheckCode = reader.ReadByte();
// 6.读取终止位置
@@ -246,5 +246,164 @@ namespace JT808.Protocol
writer.WriteEncode();
// ---------------组包结束--------------
}

public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
{
// ---------------开始解析对象--------------
writer.WriteStartObject();
// 1. 验证校验和
if (!reader.CheckXorCodeVali)
{
writer.WriteString("检验和错误", $"{reader.RealCheckXorCode}!={reader.CalculateCheckXorCode}");
}
// 2.读取起始位置
byte start = reader.ReadEnd();
writer.WriteNumber($"[{start.ReadNumber()}]开始", start);
var msgid = reader.ReadUInt16();
writer.WriteNumber($"[{msgid.ReadNumber()}]消息Id", msgid);
ushort messageBodyPropertyValue = reader.ReadUInt16();
var headerMessageBodyProperty=new JT808HeaderMessageBodyProperty(messageBodyPropertyValue);
//消息体属性对象 开始
writer.WriteStartObject("消息体属性对象");
ReadOnlySpan<char> messageBodyPropertyReadOnlySpan = messageBodyPropertyValue.ReadBinary();
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.WriteEndObject();
//2019版本
var protocolVersion = reader.ReadByte();
writer.WriteNumber($"[{protocolVersion.ReadNumber()}]协议版本号(2019)", protocolVersion);
// 3.4.读取终端手机号
var terminalPhoneNo = reader.ReadBCD(20, config.Trim);
writer.WriteString($"[{terminalPhoneNo}]终端手机号", terminalPhoneNo);
}
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.WriteEndObject();
//2013版本
// 3.3.读取终端手机号
var terminalPhoneNo = reader.ReadBCD(config.TerminalPhoneNoLength, config.Trim);
//消息体属性对象 结束
writer.WriteString($"[{terminalPhoneNo}]终端手机号", terminalPhoneNo);
}
// 3.4.读取消息流水号
var msgNum = reader.ReadUInt16();
writer.WriteNumber($"[{msgNum.ReadNumber()}]消息流水号", msgNum);
// 3.5.判断有无分包
uint packgeCount=0, packageIndex=0;
if (headerMessageBodyProperty.IsPackage)
{
//3.5.1.读取消息包总数
packgeCount = reader.ReadUInt16();
writer.WriteNumber($"[{packgeCount.ReadNumber()}]消息包总数", packgeCount);
//3.5.2.读取消息包序号
packageIndex = reader.ReadUInt16();
writer.WriteNumber($"[{packageIndex.ReadNumber()}]消息包序号", packageIndex);
}
// 4.处理数据体
// 4.1.判断有无数据体
if (headerMessageBodyProperty.DataLength > 0)
{
if (config.MsgIdFactory.TryGetValue(msgid, out object instance))
{
//数据体属性对象 开始
writer.WriteStartObject("数据体对象");
string description = "数据体";
if (instance is IJT808Description jT808Description)
{
//4.2.处理消息体
description = jT808Description.Description;
}
if (headerMessageBodyProperty.IsPackage)
{
if (packageIndex > 1)
{
try
{
//4.2处理第二包之后的分包数据消息体
writer.WriteString($"[分包]数据体", reader.ReadContent().ToArray().ToHexString());
}
catch (Exception ex)
{
writer.WriteString($"[分包]数据体异常", ex.StackTrace);
}
}
else
{
try
{
writer.WriteString($"[分包]{description}", reader.ReadVirtualArray(headerMessageBodyProperty.DataLength).ToArray().ToHexString());
if (instance is IJT808Analyze analyze)
{
//4.2.处理消息体
analyze.Analyze(ref reader, writer, config);
}
}
catch (Exception ex)
{
writer.WriteString($"[分包]数据体异常", ex.StackTrace);
}
}
}
else
{
try
{
writer.WriteString($"{description}", reader.ReadVirtualArray(headerMessageBodyProperty.DataLength).ToArray().ToHexString());
if (instance is IJT808Analyze analyze)
{
//4.2.处理消息体
analyze.Analyze(ref reader, writer, config);
}
}
catch (Exception ex)
{
writer.WriteString($"数据体异常", ex.StackTrace);
}
}
//数据体属性对象 结束
writer.WriteEndObject();
}
}
else
{
if (config.MsgIdFactory.TryGetValue(msgid, out object instance))
{
//数据体属性对象 开始
writer.WriteStartObject("数据体对象");
string description = "[Null]数据体";
if (instance is IJT808Description jT808Description)
{
//4.2.处理消息体
description = jT808Description.Description;
}
writer.WriteNull(description);
//数据体属性对象 结束
writer.WriteEndObject();
}
else
{
writer.WriteNull($"[Null]数据体");
}
}
// 5.读取校验码
reader.ReadByte();
writer.WriteNumber($"[{reader.RealCheckXorCode.ReadNumber()}]校验码", reader.RealCheckXorCode);
// 6.读取终止位置
byte end = reader.ReadEnd();
writer.WriteNumber($"[{end.ReadNumber()}]结束", end);
writer.WriteEndObject();
}
}
}

+ 95
- 0
src/JT808.Protocol/JT808Serializer.cs 查看文件

@@ -5,6 +5,9 @@ using JT808.Protocol.Interfaces;
using JT808.Protocol.Internal;
using JT808.Protocol.MessagePack;
using System;
using System.IO;
using System.Text;
using System.Text.Json;

namespace JT808.Protocol
{
@@ -161,5 +164,97 @@ namespace JT808.Protocol
JT808ArrayPool.Return(buffer);
}
}

public string Analyze(ReadOnlySpan<byte> bytes, JT808Version version = JT808Version.JTT2013, JsonWriterOptions options = default, int minBufferSize = 8096)
{
byte[] buffer = JT808ArrayPool.Rent(minBufferSize);
try
{
JT808MessagePackReader jT808MessagePackReader = new JT808MessagePackReader(bytes, version);
jT808MessagePackReader.Decode(buffer);
using(MemoryStream memoryStream = new MemoryStream())
using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options))
{
jT808Package.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config);
utf8JsonWriter.Flush();
string value = Encoding.UTF8.GetString(memoryStream.ToArray());
return value;
}
}
finally
{
JT808ArrayPool.Return(buffer);
}
}

public string Analyze<T>(ReadOnlySpan<byte> 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<T>();
using (MemoryStream memoryStream = new MemoryStream(buffer1))
using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options))
{
analyze.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config);
utf8JsonWriter.Flush();
return utf8JsonWriter.ToString();
}
}
finally
{
JT808ArrayPool.Return(buffer);
JT808ArrayPool.Return(buffer1);
}
}

public byte[] AnalyzeJsonBuffer(ReadOnlySpan<byte> bytes, JT808Version version = JT808Version.JTT2013, JsonWriterOptions options = default, int minBufferSize = 8096)
{
byte[] buffer = JT808ArrayPool.Rent(minBufferSize);
try
{
JT808MessagePackReader jT808MessagePackReader = new JT808MessagePackReader(bytes, version);
jT808MessagePackReader.Decode(buffer);
using (MemoryStream memoryStream = new MemoryStream())
using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options))
{
jT808Package.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config);
utf8JsonWriter.Flush();
return memoryStream.ToArray();
}
}
finally
{
JT808ArrayPool.Return(buffer);
}
}

public byte[] AnalyzeJsonBuffer<T>(ReadOnlySpan<byte> bytes, JT808Version version = JT808Version.JTT2013, JsonWriterOptions options = default, int minBufferSize = 8096)
{
byte[] buffer = JT808ArrayPool.Rent(minBufferSize);
try
{
JT808MessagePackReader jT808MessagePackReader = new JT808MessagePackReader(bytes, version);
if (CheckPackageType(typeof(T)))
jT808MessagePackReader.Decode(buffer);
var analyze = jT808Config.GetAnalyze<T>();
using (MemoryStream memoryStream = new MemoryStream())
using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(memoryStream, options))
{
analyze.Analyze(ref jT808MessagePackReader, utf8JsonWriter, jT808Config);
utf8JsonWriter.Flush();
return memoryStream.ToArray();
}
}
finally
{
JT808ArrayPool.Return(buffer);
}
}
}
}

+ 2
- 0
src/JT808.Protocol/JT808SplitPackageBodies.cs 查看文件

@@ -14,6 +14,8 @@ namespace JT808.Protocol

public override ushort MsgId => 0xFFFF;

public override string Description => "统一分包数据体";

public JT808SplitPackageBodies Deserialize(ref JT808MessagePackReader reader, IJT808Config config)
{
JT808SplitPackageBodies jT808SplitPackageBodies = new JT808SplitPackageBodies


+ 16
- 2
src/JT808.Protocol/MessageBody/JT808_0x0001.cs 查看文件

@@ -1,15 +1,19 @@
using JT808.Protocol.Enums;
using JT808.Protocol.MessagePack;
using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces;
using System.Text.Json;
using JT808.Protocol.Extensions;

namespace JT808.Protocol.MessageBody
{
/// <summary>
/// 终端通用应答
/// </summary>
public class JT808_0x0001 : JT808Bodies,IJT808MessagePackFormatter<JT808_0x0001>
public class JT808_0x0001 : JT808Bodies,IJT808MessagePackFormatter<JT808_0x0001>, IJT808Analyze
{
public override ushort MsgId { get; } = 0x0001;
public override ushort MsgId => 0x0001;
public override string Description => "终端通用应答";
/// <summary>
/// 应答流水号
/// 对应的平台消息的流水号
@@ -43,5 +47,15 @@ namespace JT808.Protocol.MessageBody
writer.WriteUInt16(value.ReplyMsgId);
writer.WriteByte((byte)value.JT808TerminalResult);
}

public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config)
{
var replyMsgNum = reader.ReadUInt16();
var replyMsgId = reader.ReadUInt16();
var terminalResult = reader.ReadByte();
writer.WriteNumber($"[{replyMsgNum.ReadNumber()}]应答流水号", replyMsgNum);
writer.WriteNumber($"[{replyMsgId.ReadNumber()}]应答消息Id", replyMsgId);
writer.WriteString($"[{terminalResult.ReadNumber()}]结果", ((JT808TerminalResult)terminalResult).ToString());
}
}
}

+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x0002.cs 查看文件

@@ -7,5 +7,7 @@
{
public override bool SkipSerialization { get; set; } = true;
public override ushort MsgId { get; } = 0x0002;

public override string Description => "终端心跳";
}
}

+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x0003.cs 查看文件

@@ -11,5 +11,7 @@
public override bool SkipSerialization { get; set; } = true;

public override ushort MsgId { get; } = 0x0003;

public override string Description => "终端注销请求";
}
}

+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x0004.cs 查看文件

@@ -14,5 +14,7 @@ namespace JT808.Protocol.MessageBody
public override bool SkipSerialization { get; set; } = true;

public override ushort MsgId { get; } = 0x0004;

public override string Description => "查询服务器时间请求";
}
}

+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0005.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0005 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0005>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0005;
public override string Description => "终端补传分包请求";
/// <summary>
/// 原始消息流水号
/// 对应要求补传的原始消息第一包的消息流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0100.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0100 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0100>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0100;
public override string Description => "终端注册";
/// <summary>
/// 省域 ID
/// 标示终端安装车辆所在的省域,0 保留,由平台取默


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0102.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0102 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0102>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0102;
public override string Description => "终端鉴权";
/// <summary>
/// 鉴权码
/// 鉴权码内容 2019版本


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0104.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0104 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0104>
{
public override ushort MsgId { get; } = 0x0104;
public override string Description => "查询终端参数应答";
/// <summary>
/// 应答流水号
/// 查询指定终端参数的流水号


+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x0107.cs 查看文件

@@ -11,6 +11,8 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0107 : JT808Bodies,IJT808MessagePackFormatter<JT808_0x0107>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0107;

public override string Description => "查询终端属性应答";
/// <summary>
/// 终端类型
/// bit0,0:不适用客运车辆,1:适用客运车辆;


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0108.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0108 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0108>
{
public override ushort MsgId { get; } = 0x0108;
public override string Description => "终端升级结果通知";
/// <summary>
/// 升级类型
/// 0:终端,12:道路运输证 IC 卡读卡器,52:北斗卫星定位模块


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0200.cs 查看文件

@@ -14,6 +14,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0200 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0200>
{
public override ushort MsgId { get; } = 0x0200;
public override string Description => "位置信息汇报";
/// <summary>
/// 报警标志
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0201.cs 查看文件

@@ -9,6 +9,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0201 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0201>
{
public override ushort MsgId { get; } = 0x0201;
public override string Description => "位置信息查询应答";
/// <summary>
/// 应答流水号
/// 对应的终端注册消息的流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0301.cs 查看文件

@@ -13,6 +13,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0301>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0301;
public override string Description => "事件报告";
/// <summary>
/// 事件 ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0302.cs 查看文件

@@ -14,6 +14,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0302>,IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0302;
public override string Description => "提问应答";
/// <summary>
/// 应答流水号
/// 对应的提问下发消息的流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0303.cs 查看文件

@@ -13,6 +13,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0303>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0303;
public override string Description => "信息点播_取消";
/// <summary>
/// 信息类型
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0500.cs 查看文件

@@ -9,6 +9,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0500 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0500>
{
public override ushort MsgId { get; } = 0x0500;
public override string Description => "车辆控制应答";
/// <summary>
/// 应答流水号
/// 对应的终端注册消息的流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0608.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0608 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0608>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0608;
public override string Description => "查询区域或线路数据应答";
/// <summary>
/// 查询类型
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0701.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0701 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0701>
{
public override ushort MsgId { get; } = 0x0701;
public override string Description => "电子运单上报";
/// <summary>
/// 电子运单长度
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0702.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0702 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0702>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0702;
public override string Description => "驾驶员身份信息采集上报";
/// <summary>
/// 状态
/// 0x01:从业资格证 IC 卡插入(驾驶员上班);


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0704.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0704 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0704>
{
public override ushort MsgId { get; } = 0x0704;
public override string Description => "定位数据批量上传";
/// <summary>
/// 数据项个数
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0705.cs 查看文件

@@ -15,6 +15,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0705 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0705>,IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0705;
public override string Description => "CAN总线数据上传";
/// <summary>
/// 数据项个数
/// 包含的 CAN 总线数据项个数,>0


+ 2
- 2
src/JT808.Protocol/MessageBody/JT808_0x0800.cs 查看文件

@@ -1,5 +1,4 @@
using JT808.Protocol.Attributes;
using JT808.Protocol.Formatters;
using JT808.Protocol.Formatters;
using JT808.Protocol.MessagePack;

namespace JT808.Protocol.MessageBody
@@ -11,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0800 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0800>
{
public override ushort MsgId { get; } = 0x0800;
public override string Description => "多媒体事件信息上传";
/// <summary>
/// 多媒体数据 ID
/// </summary>


+ 2
- 2
src/JT808.Protocol/MessageBody/JT808_0x0801.cs 查看文件

@@ -1,5 +1,4 @@
using JT808.Protocol.Attributes;
using JT808.Protocol.Formatters;
using JT808.Protocol.Formatters;
using JT808.Protocol.Interfaces;
using JT808.Protocol.MessagePack;

@@ -12,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0801 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0801>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0801;
public override string Description => "多媒体数据上传";
/// <summary>
/// 多媒体 ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0802.cs 查看文件

@@ -13,6 +13,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0802 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0802>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0802;
public override string Description => "存储多媒体数据检索应答";
/// <summary>
/// 应答流水号
/// 对应的多媒体数据检索消息的流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0805.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0805 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0805>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0805;
public override string Description => "摄像头立即拍摄命令应答";
/// <summary>
/// 应答流水号
/// 对应平台摄像头立即拍摄命令的消息流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0900.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0900 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0900>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x0900;
public override string Description => "数据上行透传";
/// <summary>
/// 透传消息类型
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0901.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0901 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0901>
{
public override ushort MsgId { get; } = 0x0901;
public override string Description => "数据压缩上报";
/// <summary>
/// 未压缩消息长度
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x0A00.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x0A00 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x0A00>
{
public override ushort MsgId { get; } = 0x0A00;
public override string Description => "终端RSA公钥";
/// <summary>
/// e
/// 终端 RSA 公钥{e,n}中的 e


+ 2
- 2
src/JT808.Protocol/MessageBody/JT808_0x8001.cs 查看文件

@@ -1,5 +1,4 @@
using JT808.Protocol.Attributes;
using JT808.Protocol.Enums;
using JT808.Protocol.Enums;
using JT808.Protocol.Formatters;
using JT808.Protocol.MessagePack;

@@ -11,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8001 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8001>
{
public override ushort MsgId { get; } = 0x8001;
public override string Description => "平台通用应答";
public ushort MsgNum { get; set; }
/// <summary>
/// <see cref="JT808.Protocol.Enums.JT808MsgId"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8003.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8003 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8003>
{
public override ushort MsgId { get; } = 0x8003;
public override string Description => "补传分包请求";
/// <summary>
/// 原始消息流水号
/// 对应要求补传的原始消息第一包的消息流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8004.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8004 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8004>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8004;
public override string Description => "查询服务器时间应答";

public DateTime Time { get; set; } = DateTime.Now;



+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8100.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8100 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8100>
{
public override ushort MsgId { get; } = 0x8100;
public override string Description => "终端注册应答";
/// <summary>
/// 应答流水号
/// 对应的终端注册消息的流水号


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8103.cs 查看文件

@@ -14,6 +14,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8103 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8103>
{
public override ushort MsgId { get; } = 0x8103;
public override string Description => "设置终端参数";
/// <summary>
/// 参数总数
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8104.cs 查看文件

@@ -6,6 +6,7 @@
public class JT808_0x8104 : JT808Bodies
{
public override ushort MsgId { get; } = 0x8104;
public override string Description => "查询终端参数";
/// <summary>
/// 跳过数据体序列化
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8105.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8105 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8105>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8105;
public override string Description => "终端控制";
/// <summary>
/// 命令字
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8106.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8106 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8106>
{
public override ushort MsgId { get; } = 0x8106;
public override string Description => "查询指定终端参数";
/// <summary>
/// 参数总数
/// 参数总数为 n


+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x8107.cs 查看文件

@@ -10,5 +10,7 @@
/// 跳过数据体序列化
/// </summary>
public override bool SkipSerialization { get; set; } = true;

public override string Description => "查询终端属性";
}
}

+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x8108.cs 查看文件

@@ -11,6 +11,8 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8108 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8108>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8108;

public override string Description => "下发终端升级包";
/// <summary>
/// 升级类型
/// </summary>


+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x8201.cs 查看文件

@@ -10,5 +10,7 @@
/// 跳过数据体序列化
/// </summary>
public override bool SkipSerialization { get; set; } = true;

public override string Description => "位置信息查询";
}
}

+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x8202.cs 查看文件

@@ -9,6 +9,8 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8202 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8202>
{
public override ushort MsgId { get; } = 0x8202;

public override string Description => "临时位置跟踪控制";
/// <summary>
/// 时间间隔
/// 单位为秒(s),0 则停止跟踪。停止跟踪无需带后继字段


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8203.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8203 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8203>
{
public override ushort MsgId { get; } = 0x8203;
public override string Description => "人工确认报警消息";
/// <summary>
/// 报警消息流水号
/// 需人工确认的报警消息流水号,0 表示该报警类型所有消息


+ 2
- 0
src/JT808.Protocol/MessageBody/JT808_0x8204.cs 查看文件

@@ -13,5 +13,7 @@ namespace JT808.Protocol.MessageBody
public override ushort MsgId { get; } = 0x8204;

public override bool SkipSerialization { get; set; } = true;

public override string Description => "链路检测";
}
}

+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8300.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8300 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8300>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8300;
public override string Description => "文本信息下发";
/// <summary>
/// 文本信息标志位含义见 表 38
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8301.cs 查看文件

@@ -15,6 +15,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8301 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8301>,IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8301;
public override string Description => "事件设置";
/// <summary>
/// 设置类型
/// <see cref="JT808.Protocol.Enums.JT808EventSettingType"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8302.cs 查看文件

@@ -14,6 +14,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8302 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8302>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8302;
public override string Description => "提问下发";
/// <summary>
/// 标志
/// 提问下发标志位定义


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8303.cs 查看文件

@@ -15,6 +15,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8303 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8303>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8303;
public override string Description => "信息点播菜单设置";
/// <summary>
/// 设置类型
/// <see cref="JT808.Protocol.Enums.JT808InformationSettingType"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8304.cs 查看文件

@@ -13,6 +13,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8304 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8304>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8304;
public override string Description => "信息服务";
/// <summary>
/// 信息类型
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8400.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8400 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8400>
{
public override ushort MsgId { get; } = 0x8400;
public override string Description => "电话回拨";
/// <summary>
/// 0:普通通话;1:监听
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8401.cs 查看文件

@@ -12,6 +12,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8401 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8401>
{
public override ushort MsgId { get; } = 0x8401;
public override string Description => "设置电话本";
/// <summary>
/// 设置类型
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8500.cs 查看文件

@@ -13,6 +13,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8500 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8500>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8500;
public override string Description => "车辆控制";
/// <summary>
/// 控制标志
/// 控制指令标志位数据格式


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8600.cs 查看文件

@@ -16,6 +16,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8600 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8600>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8600;
public override string Description => "设置圆形区域";
/// <summary>
/// 设置属性
/// <see cref="JT808.Protocol.Enums.JT808SettingProperty"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8601.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8601 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8601>
{
public override ushort MsgId { get; } = 0x8601;
public override string Description => "删除圆形区域";
/// <summary>
/// 区域数
/// 本条消息中包含的区域数,不超过 125 个,多于 125个建议用多条消息,0 为删除所有圆形区域


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8602.cs 查看文件

@@ -15,6 +15,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8602 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8602>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8602;
public override string Description => "设置矩形区域";
/// <summary>
/// 设置属性
/// <see cref="JT808.Protocol.Enums.JT808SettingProperty"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8603.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8603 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8603>
{
public override ushort MsgId { get; } = 0x8603;
public override string Description => "删除矩形区域";
/// <summary>
/// 区域数
/// 本条消息中包含的区域数,不超过 125 个,多于 125个建议用多条消息,0 为删除所有圆形区域


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8604.cs 查看文件

@@ -15,6 +15,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8604 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8604>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8604;
public override string Description => "设置多边形区域";
/// <summary>
/// 区域 ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8605.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8605 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8605>
{
public override ushort MsgId { get; } = 0x8605;
public override string Description => "删除多边形区域";
/// <summary>
/// 区域数
/// 本条消息中包含的区域数,不超过 125 个,多于 125个建议用多条消息,0 为删除所有圆形区域


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8606.cs 查看文件

@@ -15,6 +15,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8606 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8606>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8606;
public override string Description => "设置路线";
/// <summary>
/// 路线 ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8607.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8607 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8607>
{
public override ushort MsgId { get; } = 0x8607;
public override string Description => "删除路线";
/// <summary>
/// 区域数
/// 本条消息中包含的区域数,不超过 125 个,多于 125个建议用多条消息,0 为删除所有圆形区域


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8608.cs 查看文件

@@ -13,6 +13,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8608 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8608>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8608;
public override string Description => "查询区域或线路数据";
/// <summary>
/// 查询类型
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8702.cs 查看文件

@@ -6,6 +6,7 @@
public class JT808_0x8702 : JT808Bodies
{
public override ushort MsgId { get; } = 0x8702;
public override string Description => "上报驾驶员身份信息请求";
/// <summary>
/// 跳过数据体序列化
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8800.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8800 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8800>
{
public override ushort MsgId { get; } = 0x8800;
public override string Description => "多媒体数据上传应答";
/// <summary>
/// 多媒体ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8801.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8801 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8801>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8801;
public override string Description => "摄像头立即拍摄命令";
/// <summary>
/// 通道 ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8802.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8802 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8802>
{
public override ushort MsgId { get; } = 0x8802;
public override string Description => "存储多媒体数据检索";
/// <summary>
/// 多媒体类型
/// <see cref="JT808.Protocol.Enums.JT808MultimediaType"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8803.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8803 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8803>
{
public override ushort MsgId { get; } = 0x8803;
public override string Description => "存储多媒体数据上传命令";
/// <summary>
/// 多媒体类型
/// <see cref="JT808.Protocol.Enums.JT808MultimediaType"/>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8804.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8804 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8804>
{
public override ushort MsgId { get; } = 0x8804;
public override string Description => "录音开始命令";
/// <summary>
/// 录音命令
/// 0:停止录音;0x01:开始录音;


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8805.cs 查看文件

@@ -10,6 +10,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8805 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8805>,IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8805;
public override string Description => "单条存储多媒体数据检索上传命令";
/// <summary>
/// 多媒体ID
/// </summary>


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8900.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8900 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8900>, IJT808_2019_Version
{
public override ushort MsgId { get; } = 0x8900;
public override string Description => "数据下行透传";
/// <summary>
/// 透传消息类型
/// 透传消息类型定义见 表 93


+ 1
- 0
src/JT808.Protocol/MessageBody/JT808_0x8A00.cs 查看文件

@@ -11,6 +11,7 @@ namespace JT808.Protocol.MessageBody
public class JT808_0x8A00 : JT808Bodies, IJT808MessagePackFormatter<JT808_0x8A00>
{
public override ushort MsgId { get; } = 0x8A00;
public override string Description => "平台RSA公钥";
/// <summary>
/// e
/// 平台 RSA 公钥{e,n}中的 e


+ 5
- 0
src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs 查看文件

@@ -160,6 +160,10 @@ namespace JT808.Protocol.MessagePack
{
return GetVirtualReadOnlySpan(1)[0];
}
public ReadOnlySpan<byte> ReadVirtualArray(int count)
{
return GetVirtualReadOnlySpan(count);
}
public ushort ReadVirtualUInt16()
{
return BinaryPrimitives.ReadUInt16BigEndian(GetVirtualReadOnlySpan(2));
@@ -229,6 +233,7 @@ namespace JT808.Protocol.MessagePack
string hex = HexUtil.DoHexDump(readOnlySpan, 0, len);
return hex;
}

/// <summary>
/// yyMMddHHmmss
/// </summary>


Loading…
取消
儲存