コード例 #1
0
def wtgr800_anemometer(part, message, p):
    dirno = hi_nibble(p[4])
    speed = lo_nibble(p[7]) * 10 + hi_nibble(p[6]) + lo_nibble(p[6]) / 10.0
    avgspeed = hi_nibble(p[8]) * 10 + lo_nibble(p[8]) + hi_nibble(p[7]) / 10.0
    message['source'] = message['sensor'] = part
    message['dir'] = dirno
    message['speed'] = speed
    message['avgspeed'] = avgspeed
コード例 #2
0
def wtgr800_anemometer(part, message, p):
    dirno = hi_nibble(p[4]) * 22.5
    speed = lo_nibble(p[7]) * 10 + hi_nibble(p[6]) + lo_nibble(p[6]) / 10.0
    avgspeed = hi_nibble(p[8]) * 10 + lo_nibble(p[8]) + hi_nibble(p[7]) / 10.0
    message['source'] = message['sensor'] = '%s.%02x' % (part, p[3])
    message['dir'] = dirno
    message['speed'] = speed
    message['avgspeed'] = avgspeed
    percentage_battery(p, message)
コード例 #3
0
def pcr800_rain(part, message, p):
    message['source'] = message['sensor'] = '%s.%02x' % (part, p[3])
    rain = (lo_nibble(p[6]) * 10 + hi_nibble(p[5]) + lo_nibble(p[5]) / 10.0 +
            hi_nibble(p[4]) / 100.0)
    rain *= 25.4  # convert from inch/hr to mm/hr

    train = (lo_nibble(p[9]) * 100 + dec_byte(p, 8) + dec_byte(p, 7) / 100.0 +
             hi_nibble(p[6]) / 1000.0)
    train *= 25.4  # convert from inch/hr to mm/hr

    message['speed'] = rain
    message['total'] = train
    simple_battery(p, message)
コード例 #4
0
def humidity(p, message):
    hum = lo_nibble(p[7]) * 10 + hi_nibble(p[6])
    message['humidity'] = hum
コード例 #5
0
def temperature(p, message):
    temp = (
        ((p[6] & 0x8) and -1 or 1) *
        (hi_nibble(p[5]) * 10.0 + lo_nibble(p[5]) + hi_nibble(p[4]) / 10.0))
    message['temp'] = temp
コード例 #6
0
def checksum1(p):
    c = hi_nibble(p[6]) + (lo_nibble(p[7]) << 4)
    s = ((nibble_sum(6, p) + lo_nibble(p[6]) - 0xa) & 0xff)
    return s == c
コード例 #7
0
def checksum8(p):
    c = hi_nibble(p[9]) + (lo_nibble(p[10]) << 4)
    s = ((nibble_sum(9, p) - 0xa) & 0xff)
    return s == c
コード例 #8
0
def checksum6(p):
    return (hi_nibble(p[8]) +
            (lo_nibble(p[9]) << 4) == ((nibble_sum(8, p) - 0xa) & 0xff))