Mercurial > ~darius > hgwebdir.cgi > epro
comparison epro.py @ 3:6d0fe22566ab
Fix cut & paste error for variable name, report disconnected sensor specially.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Sun, 19 Nov 2017 18:07:55 +1030 |
parents | 1de08e57774f |
children | 787d9c8fdec6 |
comparison
equal
deleted
inserted
replaced
2:ffd0dcce19ed | 3:6d0fe22566ab |
---|---|
129 MSGNAME = "Battery Temperature" | 129 MSGNAME = "Battery Temperature" |
130 LEN = 3 | 130 LEN = 3 |
131 | 131 |
132 def __init__(self, dstadr, srcadr, devid, msgtype, data): | 132 def __init__(self, dstadr, srcadr, devid, msgtype, data): |
133 super(BatteryTemperature, self).__init__(dstadr, srcadr, devid, msgtype, data) | 133 super(BatteryTemperature, self).__init__(dstadr, srcadr, devid, msgtype, data) |
134 self.time = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 10.0 | 134 self.temp = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 10.0 |
135 if data[2] & 0x40: | 135 if data[2] & 0x40: |
136 self.time *= -1 | 136 self.temp *= -1 |
137 if self.temp == -20: | |
138 self.temp = None | |
137 | 139 |
138 def __repr__(self): | 140 def __repr__(self): |
139 s = super(BatteryTemperature, self).__repr__() | 141 s = super(BatteryTemperature, self).__repr__() |
140 s += ": %.2f degC" % (self.time) | 142 if self.temp == None: |
143 s += ": n/a" | |
144 else: | |
145 s += ": %.2f degC" % (self.temp) | |
141 return s | 146 return s |
142 | 147 |
143 class MonitorStatus(Packet): | 148 class MonitorStatus(Packet): |
144 """Monitor status""" | 149 """Monitor status""" |
145 MSGTYPE = 0x67 | 150 MSGTYPE = 0x67 |