配置区超大,超出了数据流范围,只同步前16字节

This commit is contained in:
nnhy 2015-11-18 12:13:39 +00:00
parent 5c808657b0
commit 995f12cf89
2 changed files with 14 additions and 7 deletions

View File

@ -336,6 +336,8 @@ void TinyClient::Report(Message& msg)
// 0x01子功能主数据区
void TinyClient::ReportPing0x01(Stream& ms)
{
TS("TinyClient::ReportPing0x01");
byte len = Store.Data.Length() - 1;
if(ms.Position() + 3 + len > Control->Port->MaxSize) return;
@ -349,8 +351,11 @@ void TinyClient::ReportPing0x01(Stream& ms)
// 0x02子功能配置区
void TinyClient::ReportPing0x02(Stream& ms)
{
TS("TinyClient::ReportPing0x02");
byte len2 = sizeof(Cfg->Length);
byte len = Cfg->Length - len2;
if(len > 0x10) len = 0x10;
if(ms.Position() + 1 + len2 + 1 + len > Control->Port->MaxSize) return;
ms.Write((byte)0x02); // 子功能码
@ -363,6 +368,8 @@ void TinyClient::ReportPing0x02(Stream& ms)
// 0x03子功能硬件校验码
void TinyClient::ReportPing0x03(Stream& ms)
{
TS("TinyClient::ReportPing0x03");
if(ms.Position() + 3 > Control->Port->MaxSize) return;
ms.Write((byte)0x03); // 子功能码

View File

@ -14,29 +14,29 @@
struct TinyConfig
{
byte Length; // 数据长度
byte OfflineTime;// 离线阀值时间。秒
byte SleepTime; // 睡眠时间。秒
byte PingTime; // 心跳时间。秒
char Name[8]; //设备名称
ushort Kind; // 类型
byte Address; // 分配得到的设备地址
byte Server; // 网关ID
byte Channel; // 通道
ushort Speed; // 传输速度
ushort Speed; // 传输速度
byte HardVer; // 硬件版本
byte SoftVer; // 软件版本
byte Password[16]; // 通信密码
byte Password[16]; // 通信密码
byte ServerKey[16]; // 服务端组网密码退网时使用。一般6字节
//初始化各字段为0
//TinyConfig();
//const TinyConfig& Default();
byte StartSet;
void LoadDefault();
void Load();