修正数据消息计算Code时的Bug,测试确认已修正

This commit is contained in:
nnhy 2015-12-19 09:49:53 +00:00
parent 6acd69864c
commit 31877080f6
3 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,7 @@ DataMessage::DataMessage(const Message& msg, Stream& dest) : _Src(msg.ToStream()
Length = 0;
// 读取请求、写入响应、错误响应 等包含偏移和长度
byte code = msg.Code && 0x0F;
byte code = msg.Code & 0x0F;
if(code == 0x05 && !msg.Reply || code == 0x06 && msg.Reply || msg.Error)
Length = _Src.ReadEncodeInt();
}

View File

@ -194,7 +194,7 @@ bool TinyServer::Dispatch(TinyMessage& msg)
break;
}
debug_printf("fw=%d \r\n", fw);
//debug_printf("fw=%d \r\n", fw);
if(fw && !rs.Error)
{
// 非休眠设备直接发送
@ -484,6 +484,7 @@ bool TinyServer::OnRead(const Message& msg, Message& rs, Device& dv)
auto ms = rs.ToStream();
DataMessage dm(msg, ms);
//debug_printf("TinyServer::OnRead Addr=%d Offset=%d len=%d \r\n", dv.Address, dm.Offset, dm.Length);
bool rt = true;
if(dm.Offset < 64)
@ -497,6 +498,7 @@ bool TinyServer::OnRead(const Message& msg, Message& rs, Device& dv)
rs.Error = !rt;
rs.Length = ms.Position();
//rs.Show();
return true;
}

View File

@ -289,9 +289,9 @@ bool Gateway::OnRemote(const TokenMessage& msg)
// TinyToToken(tmsg, msg2);
}
else
TinyToToken(tmsg, msg2);
TinyToToken(tmsg, msg2);
msg2.Show();
msg2.Show();
return Client->Reply(msg2);
}