Browse Source

修复了校验码中包含0x7e和0x7d导致消息错误的问题

master
xuliang 5 years ago
parent
commit
817bb9f225
3 changed files with 11 additions and 8 deletions
  1. +3
    -1
      Program.cs
  2. +2
    -1
      TcpPack.cs
  3. +6
    -6
      app.config

+ 3
- 1
Program.cs View File

@@ -298,9 +298,11 @@ namespace GT808ClientTest
byte checkByte = PackHelper.CalcCheckByte(fullBytes, 0, fullBytes.Length);

bytesSend = (new byte[] { 0x7e }
.Concat(PackHelper.EncodeBytes(fullBytes).Concat(new byte[] { checkByte }))
.Concat(PackHelper.EncodeBytes(fullBytes.Concat(new byte[] { checkByte })))
.Concat(new byte[] { 0x7e })).ToArray();

//Console.WriteLine("{0} {1}",head.SeqNO, bytesSend.ToHexString());

//发送消息
SendBytes(tcp, bytesSend);
//控制台打印日志cpu占用太高


+ 2
- 1
TcpPack.cs View File

@@ -167,7 +167,8 @@ namespace Gps.Plugin.Tcp.GT808

public string GetDeviceId()
{
return string.Concat("460", DeviceId);
//return string.Concat("460", DeviceId);
return DeviceId;
}

public void SetDeviceId(string value)


+ 6
- 6
app.config View File

@@ -5,20 +5,20 @@

</configSections>
<appSettings>
<!--服务器IP和端口(113.31.92.200:8201)-->
<add key="remoteServerPort" value="10.1.97.12:32195"/>
<!--服务器IP和端口(10.1.97.12:32195)-->
<add key="remoteServerPort" value="58.217.99.135:17613"/>
<!--模拟终端id区间(设置200000-200100,将自动生成010000200000-010000200100这样101个设备)-->
<add key="deviceIdRange" value="200000-200010"/>
<add key="deviceIdRange" value="200000-200000"/>
<!--每个消息间隔(秒)-->
<add key="interval" value="1"/>
<!--每个设备发送共多少个包(默认0x0200)后断开连接-->
<add key="sendCountByOneDevice" value="10"/>
<!--控制台是否打印发送日志(消耗大量cpu)true or false-->
<add key="sendLogPrint" value="false"/>
<add key="sendLogPrint" value="true"/>
<!--消息是否等待服务端同步应答(如果开启,服务器来不及回复应答的时候,控制台看上去就像假死了)true or false-->
<add key="waitReceive" value="false"/>
<add key="waitReceive" value="true"/>
<!--控制台是否打印接收日志(消耗大量cpu),该开关只有开启了服务端应答之后才有效 true or false-->
<add key="receiveLogPrint" value="false"/>
<add key="receiveLogPrint" value="true"/>
</appSettings>
<log4net debug="false">
<root>


Loading…
Cancel
Save