Skip to content

Commit

Permalink
修复根据2019协议 MarkId 字节和22013版本一样都是5个字节
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallChi committed Dec 11, 2024
1 parent b7de21a commit 381ecce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/JT808.Protocol/JT808.Protocol.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9443,8 +9443,7 @@
<member name="P:JT808.Protocol.MessageBody.JT808_0x0107.MakerId">
<summary>
制造商 ID
2013版本 5 个字节,终端制造商编码
2019版本 11 个字节,终端制造商编码
2013版本 5 个字节,终端制造商编码
</summary>
</member>
<member name="P:JT808.Protocol.MessageBody.JT808_0x0107.TerminalModel">
Expand Down
33 changes: 7 additions & 26 deletions src/JT808.Protocol/MessageBody/JT808_0x0107.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public class JT808_0x0107 : JT808MessagePackFormatter<JT808_0x0107>, JT808Bodies
public ushort TerminalType { get; set; }
/// <summary>
/// 制造商 ID
/// 2013版本 5 个字节,终端制造商编码
/// 2019版本 11 个字节,终端制造商编码
/// 2013版本 5 个字节,终端制造商编码
/// </summary>
public string MakerId { get; set; }
/// <summary>
Expand Down Expand Up @@ -107,18 +106,9 @@ public override JT808_0x0107 Deserialize(ref JT808MessagePackReader reader, IJT8
{
JT808_0x0107 jT808_0X0107 = new JT808_0x0107();
jT808_0X0107.TerminalType = reader.ReadUInt16();
if(reader.Version== JT808Version.JTT2019)
{
jT808_0X0107.MakerId = reader.ReadString(11);
jT808_0X0107.TerminalModel = reader.ReadString(30);
jT808_0X0107.TerminalId = reader.ReadString(30);
}
else
{
jT808_0X0107.MakerId = reader.ReadString(5);
jT808_0X0107.TerminalModel = reader.ReadString(20);
jT808_0X0107.TerminalId = reader.ReadString(7);
}
jT808_0X0107.MakerId = reader.ReadString(5);
jT808_0X0107.TerminalModel = reader.ReadString(20);
jT808_0X0107.TerminalId = reader.ReadString(7);
jT808_0X0107.Terminal_SIM_ICCID = reader.ReadBCD(20, config.Trim);
jT808_0X0107.Terminal_Hardware_Version_Length = reader.ReadByte();
jT808_0X0107.Terminal_Hardware_Version_Num = reader.ReadString(jT808_0X0107.Terminal_Hardware_Version_Length);
Expand All @@ -137,18 +127,9 @@ public override JT808_0x0107 Deserialize(ref JT808MessagePackReader reader, IJT8
public override void Serialize(ref JT808MessagePackWriter writer, JT808_0x0107 value, IJT808Config config)
{
writer.WriteUInt16(value.TerminalType);
if (writer.Version == JT808Version.JTT2019)
{
writer.WriteString(value.MakerId.PadRight(11, '\0').ValiString(nameof(value.MakerId),11));
writer.WriteString(value.TerminalModel.PadRight(30, '\0').ValiString(nameof(value.TerminalModel), 30));
writer.WriteString(value.TerminalId.PadRight(30, '\0').ValiString(nameof(value.TerminalId), 30));
}
else
{
writer.WriteString(value.MakerId.PadRight(5, '\0').ValiString(nameof(value.MakerId), 5));
writer.WriteString(value.TerminalModel.PadRight(20, '\0').ValiString(nameof(value.TerminalModel), 20));
writer.WriteString(value.TerminalId.PadRight(7, '\0').ValiString(nameof(value.TerminalId), 7));
}
writer.WriteString(value.MakerId.PadRight(5, '\0').ValiString(nameof(value.MakerId), 5));
writer.WriteString(value.TerminalModel.PadRight(20, '\0').ValiString(nameof(value.TerminalModel), 20));
writer.WriteString(value.TerminalId.PadRight(7, '\0').ValiString(nameof(value.TerminalId), 7));
writer.WriteBCD(value.Terminal_SIM_ICCID.ValiString(nameof(value.Terminal_SIM_ICCID), 20), 20);
writer.WriteByte((byte)value.Terminal_Hardware_Version_Num.Length);
writer.WriteString(value.Terminal_Hardware_Version_Num);
Expand Down

0 comments on commit 381ecce

Please sign in to comment.