Ver código fonte

2.5.0-preview4

1.使用微软自带的hex库
2.readme增加两个使用例子
tags/v2.5.0
SmallChi(Koike) 2 anos atrás
pai
commit
e184229cfe
11 arquivos alterados com 39 adições e 124 exclusões
  1. +12
    -0
      README.en.md
  2. +12
    -2
      README.md
  3. +1
    -1
      src/Info.props
  4. +2
    -2
      src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj
  5. +2
    -4
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj
  6. +2
    -4
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.csproj
  7. +2
    -4
      src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.csproj
  8. +3
    -75
      src/JT808.Protocol/Extensions/JT808HexExtensions.cs
  9. +2
    -8
      src/JT808.Protocol/JT808.Protocol.csproj
  10. +0
    -23
      src/JT808.Protocol/JT808.Protocol.xml
  11. +1
    -1
      src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs

+ 12
- 0
README.en.md Ver arquivo

@@ -360,6 +360,18 @@ We can refer to the subcontracting data structure of the equipment in [Example 5

[See Demo16 for Simples](https://github.com/SmallChi/JT808/blob/master/src/JT808.Protocol.Test/Simples/Demo16.cs)

### 举个栗子17

***scene:***
The additional data of the JT/T808 0x0200 standard protocol is explicitly reserved for some additional information ids. Therefore, according to the standard, some device manufacturers use the additional information ids of the standard. Therefore, to resolve the problem, you can refer to the external custom additional information registration method.

[see Demo10 for Simples](https://github.com/SmallChi/JT808/blob/master/src/JT808.Protocol.Test/Simples/Demo10.cs).

### 举个栗子18

***scene:***
Due to access many different equipment vendor's agreement, but each protocol docking and less, think at the same time in a class library under the unified management, then in each manufacturer not conflict using the assembly way of registration is no problem, once has the conflict, then use the assembly way registered will quote Id conflict, The library does not support this way of isolation, so I use [SetMap] to manage this situation.

## NuGet Install

| Package Name| Version| Preview Version |Downloads|Remark|


+ 12
- 2
README.md Ver arquivo

@@ -358,9 +358,19 @@ JT808Serializer DT2JT808Serializer = new JT808Serializer(DT2JT808Config);
场景:
平台下发分包数据到设备

可以参考【栗子5】中,设备上来的分包数据结构,然后举一反三的去实现。
可以参考【举个栗子5】中,设备上来的分包数据结构,然后举一反三的去实现。

[可以参考Simples的Demo16](https://github.com/SmallChi/JT808/blob/master/src/JT808.Protocol.Test/Simples/Demo16.cs)
### 举个栗子17

场景:
由于808的0x0200标准协议的附加数据是有明确的表示对部分附加信息Id进行保留的,所以按照标准,有些设备厂商把标准的附加信息Id占用,所以需要解析这部分的数据,可以参考外部自定义附加信息注册的方式来解决解析问题。

可以参考[举个栗子10](https://github.com/SmallChi/JT808/blob/master/src/JT808.Protocol.Test/Simples/Demo10.cs)中的程序。

### 举个栗子18

场景:
由于接入很多不同设备厂商的协议,但是每个协议对接又比较少,想同时放在一个类库下面进行统一管理,那么在各个厂家不冲突的情况下使用程序集方式的注册是没有问题的,一旦有冲突,那么使用程序集的方式进行注册会报Id冲突,本身库不支持这种方式进行隔离的,所以遇到这种情况自己使用SetMap的方式进行管理。

## NuGet安装



+ 1
- 1
src/Info.props Ver arquivo

@@ -8,7 +8,7 @@
<PackageProjectUrl>https://github.com/SmallChi/JT808</PackageProjectUrl>
<licenseUrl>https://github.com/SmallChi/JT808/blob/master/LICENSE</licenseUrl>
<license>https://github.com/SmallChi/JT808/blob/master/LICENSE</license>
<Version>2.5.0-preview3</Version>
<Version>2.5.0-preview4</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<AnalysisLevel>latest</AnalysisLevel>


+ 2
- 2
src/JT808.Protocol.Benchmark/JT808.Protocol.Benchmark.csproj Ver arquivo

@@ -14,8 +14,8 @@
<None Remove="ReportTest\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.2" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />


+ 2
- 4
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JT1078/JT808.Protocol.Extensions.JT1078.csproj Ver arquivo

@@ -4,12 +4,10 @@
<PackageId>JT808.Protocol.Extensions.JT1078</PackageId>
<Product>JT808.Protocol.Extensions.JT1078</Product>
<Description>
JT/T1078 video message protocol based on JT/JT808 protocol and GB808 protocol extension.
基于JT808协议、GB808协议扩展的JT1078视频消息协议。
JT/T1078 video message protocol based on JT/JT808 protocol and GB808 protocol extension.基于JT808协议、GB808协议扩展的JT1078视频消息协议。
</Description>
<PackageReleaseNotes>
JT/T1078 video message protocol based on JT/JT808 protocol and GB808 protocol extension.
基于JT/T808协议、GB808协议扩展的JT/T1078视频消息协议。
JT/T1078 video message protocol based on JT/JT808 protocol and GB808 protocol extension.基于JT/T808协议、GB808协议扩展的JT/T1078视频消息协议。
</PackageReleaseNotes>
<DocumentationFile>JT808.Protocol.Extensions.JT1078.xml</DocumentationFile>
</PropertyGroup>


+ 2
- 4
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.SuBiao/JT808.Protocol.Extensions.SuBiao.csproj Ver arquivo

@@ -4,12 +4,10 @@
<PackageId>JT808.Protocol.Extensions.SuBiao</PackageId>
<Product>JT808.Protocol.Extensions.SuBiao</Product>
<Description>
Active secure message protocol (Su Biao) based on JT/T808 protocol and GB808 protocol extension.
基于JT/T808协议、GB808协议扩展的主动安全消息协议(苏标)。
Active secure message protocol (Su Biao) based on JT/T808 protocol and GB808 protocol extension.基于JT/T808协议、GB808协议扩展的主动安全消息协议(苏标)。
</Description>
<PackageReleaseNotes>
Active secure message protocol (Su Biao) based on JT/T808 protocol and GB808 protocol extension.
基于JT/T808协议、GB808协议扩展的主动安全消息协议(苏标)。
Active secure message protocol (Su Biao) based on JT/T808 protocol and GB808 protocol extension.基于JT/T808协议、GB808协议扩展的主动安全消息协议(苏标)。
</PackageReleaseNotes>
<DocumentationFile>JT808.Protocol.Extensions.SuBiao.xml</DocumentationFile>
</PropertyGroup>


+ 2
- 4
src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.csproj Ver arquivo

@@ -4,12 +4,10 @@
<PackageId>JT808.Protocol.Extensions.YueBiao</PackageId>
<Product>JT808.Protocol.Extensions.YueBiao</Product>
<Description>
Active Secure Message Protocol Based on JT/T808 protocol and GB808 Protocol Extension (Yue Biao).
基于JT/T808协议、GB808协议扩展的主动安全消息协议(粤标)。
Active Secure Message Protocol Based on JT/T808 protocol and GB808 Protocol Extension (Yue Biao).基于JT/T808协议、GB808协议扩展的主动安全消息协议(粤标)。
</Description>
<PackageReleaseNotes>
Active Secure Message Protocol Based on JT/T808 protocol and GB808 Protocol Extension (Yue Biao).
基于JT/T808协议、GB808协议扩展的主动安全消息协议(粤标)。
Active Secure Message Protocol Based on JT/T808 protocol and GB808 Protocol Extension (Yue Biao).基于JT/T808协议、GB808协议扩展的主动安全消息协议(粤标)。
</PackageReleaseNotes>
<DocumentationFile>JT808.Protocol.Extensions.YueBiao.xml</DocumentationFile>
</PropertyGroup>


+ 3
- 75
src/JT808.Protocol/Extensions/JT808HexExtensions.cs Ver arquivo

@@ -15,7 +15,7 @@ namespace JT808.Protocol.Extensions
/// <returns></returns>
public static string ToHexString(this byte[] source)
{
return HexUtil.DoHexDump(source, 0, source.Length).ToUpper();
return Convert.ToHexString(source, 0, source.Length);
}

/// <summary>
@@ -26,16 +26,7 @@ namespace JT808.Protocol.Extensions
public static byte[] ToHexBytes(this string hexString)
{
hexString = hexString.Replace(" ", "");
byte[] buf = new byte[hexString.Length / 2];
ReadOnlySpan<char> readOnlySpan = hexString.AsSpan();
for (int i = 0; i < hexString.Length; i++)
{
if (i % 2 == 0)
{
buf[i / 2] = Convert.ToByte(readOnlySpan.Slice(i, 2).ToString(), 16);
}
}
return buf;
return Convert.FromHexString(hexString);
}

/// <summary>
@@ -47,8 +38,7 @@ namespace JT808.Protocol.Extensions
/// <returns></returns>
public static string ReadHexStringLittle(ReadOnlySpan<byte> read, ref int offset, int len)
{
//ReadOnlySpan<byte> source = read.Slice(offset, len);
string hex = HexUtil.DoHexDump(read, offset, len);
string hex = Convert.ToHexString(read.Slice(offset, len));
offset += len;
return hex;
}
@@ -200,66 +190,4 @@ namespace JT808.Protocol.Extensions
return System.Convert.ToString(value, 2).PadLeft(8, '0').AsSpan();
}
}
/// <summary>
///
/// </summary>
public static class HexUtil
{
static readonly char[] HexdumpTable = new char[256 * 4];
static HexUtil()
{
char[] digits = "0123456789ABCDEF".ToCharArray();
for (int i = 0; i < 256; i++)
{
HexdumpTable[i << 1] = digits[(int)((uint)i >> 4 & 0x0F)];
HexdumpTable[(i << 1) + 1] = digits[i & 0x0F];
}
}
/// <summary>
///
/// </summary>
/// <param name="buffer"></param>
/// <param name="fromIndex"></param>
/// <param name="length"></param>
/// <returns></returns>
public static string DoHexDump(ReadOnlySpan<byte> buffer, int fromIndex, int length)
{
if (length == 0)
{
return "";
}
int endIndex = fromIndex + length;
var buf = new char[length << 1];
int srcIdx = fromIndex;
int dstIdx = 0;
for (; srcIdx < endIndex; srcIdx++, dstIdx += 2)
{
Array.Copy(HexdumpTable, buffer[srcIdx] << 1, buf, dstIdx, 2);
}
return new string(buf);
}
/// <summary>
///
/// </summary>
/// <param name="array"></param>
/// <param name="fromIndex"></param>
/// <param name="length"></param>
/// <returns></returns>
public static string DoHexDump(byte[] array, int fromIndex, int length)
{
if (length == 0)
{
return "";
}
int endIndex = fromIndex + length;
var buf = new char[length << 1];
int srcIdx = fromIndex;
int dstIdx = 0;
for (; srcIdx < endIndex; srcIdx++, dstIdx += 2)
{
Array.Copy(HexdumpTable, (array[srcIdx] & 0xFF) << 1, buf, dstIdx, 2);
}
return new string(buf);
}
}
}

+ 2
- 8
src/JT808.Protocol/JT808.Protocol.csproj Ver arquivo

@@ -4,12 +4,10 @@
<PackageId>JT808</PackageId>
<Product>JT808</Product>
<Description>
JT/T808 protocol,JT808 protocol, GB808 protocol(support 2011, 2013, 2019 version).
JT/T808协议、JT808协议、GB808协议(支持2011、2013、2019版本)。
JT/T808 protocol,JT808 protocol, GB808 protocol(support 2011, 2013, 2019 version).JT/T808协议、JT808协议、GB808协议(支持2011、2013、2019版本)。
</Description>
<PackageReleaseNotes>
JT/T808 protocol,JT808 protocol, GB808 protocol(support 2011, 2013, 2019 version).
JT/T808协议、JT808协议、GB808协议(支持2011、2013、2019版本)。
JT/T808 protocol,JT808 protocol, GB808 protocol(support 2011, 2013, 2019 version).JT/T808协议、JT808协议、GB808协议(支持2011、2013、2019版本)。
</PackageReleaseNotes>
<DocumentationFile>JT808.Protocol.xml</DocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
@@ -61,8 +59,4 @@
<DependentUpon>JT808PackageExtensionsTemplate.tt</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
</Project>

+ 0
- 23
src/JT808.Protocol/JT808.Protocol.xml Ver arquivo

@@ -2239,29 +2239,6 @@
<param name="value"></param>
<returns></returns>
</member>
<member name="T:JT808.Protocol.Extensions.HexUtil">
<summary>
</summary>
</member>
<member name="M:JT808.Protocol.Extensions.HexUtil.DoHexDump(System.ReadOnlySpan{System.Byte},System.Int32,System.Int32)">
<summary>
</summary>
<param name="buffer"></param>
<param name="fromIndex"></param>
<param name="length"></param>
<returns></returns>
</member>
<member name="M:JT808.Protocol.Extensions.HexUtil.DoHexDump(System.Byte[],System.Int32,System.Int32)">
<summary>
</summary>
<param name="array"></param>
<param name="fromIndex"></param>
<param name="length"></param>
<returns></returns>
</member>
<member name="T:JT808.Protocol.Extensions.JT808MessagePackFormatterResolverExtensions">
<summary>


+ 1
- 1
src/JT808.Protocol/MessagePack/JT808MessagePackReader.cs Ver arquivo

@@ -364,7 +364,7 @@ namespace JT808.Protocol.MessagePack
public string ReadHex(int len)
{
var readOnlySpan = GetReadOnlySpan(len);
string hex = HexUtil.DoHexDump(readOnlySpan, 0, len);
string hex = Convert.ToHexString(readOnlySpan.Slice(0, len));
return hex;
}
/// <summary>


Carregando…
Cancelar
Salvar