diff --git a/SensorHub.Well/Well.cs b/SensorHub.Well/Well.cs index c5b86c4..ba50d85 100644 --- a/SensorHub.Well/Well.cs +++ b/SensorHub.Well/Well.cs @@ -143,11 +143,13 @@ IsBackground = true//将线程设置为后台线程 }; savethread.Start(devCode); //开启存盘线程 - + /* byte[] responseFrame = BuildAccelerationDataReceived(devCode, new byte[2] { 0x05, 0x86 }); string responseBase64 = Convert.ToBase64String(responseFrame); // 转成base64下发 Common.SendAEPCommand(session, responseBase64, source); return; + */ + break; default: session.Logger.Info("未知业务类型!"); @@ -183,10 +185,15 @@ if (hexString.Length != 4) return 0; - Int16 originInt = Convert.ToInt16(hexString); - originInt -= 2048; + string convertStr = "0" + hexString.Substring(3, 1) + hexString.Substring(0, 2); // 将字节顺序反一下 最高4位置0 + + Int16 originInt = Convert.ToInt16(convertStr, 16); + if (originInt >= 2048) + { + originInt = (short)(originInt - 4095); + } - return (double)originInt / 2048.0; + return (double)originInt / 1.024; // 换算成mg } private byte[] BuildAccelerationDataReceived(string devCode, byte[] btPdu)