示例#1
0
 def parseData(self, primaryData):
     data = SerialData(primaryData)
     st = b2i.bytes2Int32(data.payLoad)
     tt = (1 / (2.048 * st / 3.3 / pow(2, 23) + 1) - 1) * pow(10, 6)
     if tt < -50000.0 or tt > 50000.0:
         tt = 0
     self.telemetry.strain = tt
     self.attributes = b2i.bytes2UInt16(data.mcuId)
示例#2
0
    def parseData(self, primaryData):
        data = SerialData(primaryData)
        n = b2i.bytes2Int32(data.payLoad)
        k = n / pow(2, 25) * 2.048 / 2.7
        tt = (240 / (1 - 2 * k) - 220) * 50 / 19.4 - 7
        if tt < -20 or tt > 60:
            tt = 0

        self.telemetry.temperature = tt
        self.attributes = b2i.bytes2UInt16(data.mcuId)
示例#3
0
 def parseData(self, primaryData):
     '''
     再次调用初步解析串口数据的方法
     (这里应该直接指定primaryData就是解析好的对象,暂时没找到解决办法,优化时对其修改)
     '''
     data = SerialData(primaryData)
     self.telemetry.x = b2i.bytes2Int16(data.payLoad[0:2]) / 16834.0
     self.telemetry.y = b2i.bytes2Int16(data.payLoad[2:4]) / 16834.0
     self.telemetry.z = b2i.bytes2Int16(data.payLoad[4:6]) / 16834.0
     self.attributes = b2i.bytes2UInt16(data.mcuId)
示例#4
0
#@Time    :2018/10/29 19:46
import tool.bytes2int as bi

#在Python3以后,字符串和bytes类型彻底分开了。字符串是以字符为单位进行处理的,bytes类型是以字节为单位处理的
#https://www.cnblogs.com/R-bear/p/7744454.html
b = b'abcd'
res = bi.bytes2Int32(b)
print(res)

res = bi.bytes2Int16(b)
print(res)

res = bi.bytes2UInt16(b)
print(res)