mirror of
https://github.com/weewx/weewx.git
synced 2026-06-09 17:45:24 -04:00
eliminate some PEP warnings
This commit is contained in:
@@ -309,11 +309,11 @@ class TE923Configurator(weewx.drivers.AbstractConfigurator):
|
||||
def show_history(self, ts=0, count=0, fmt='raw'):
|
||||
"""Show the indicated number of records or records since timestamp"""
|
||||
print "Querying the station for historical records..."
|
||||
for i,r in enumerate(self.station.genArchiveRecords(ts)):
|
||||
for i, r in enumerate(self.station.genArchiveRecords(ts)):
|
||||
if fmt.lower() == 'raw':
|
||||
self.print_raw(r['datetime'], r['ptr'], r['raw_data'])
|
||||
elif fmt.lower() == 'table':
|
||||
self.print_table(r['datetime'], r['data'], i==0)
|
||||
self.print_table(r['datetime'], r['data'], i == 0)
|
||||
else:
|
||||
print r['datetime'], r['data']
|
||||
if count and i > count:
|
||||
@@ -343,7 +343,7 @@ class TE923Configurator(weewx.drivers.AbstractConfigurator):
|
||||
class TE923Driver(weewx.drivers.AbstractDevice):
|
||||
"""Driver for Hideki TE923 stations."""
|
||||
|
||||
def __init__(self, **stn_dict) :
|
||||
def __init__(self, **stn_dict):
|
||||
"""Initialize the station object.
|
||||
|
||||
polling_interval: How often to poll the station, in seconds.
|
||||
@@ -353,7 +353,6 @@ class TE923Driver(weewx.drivers.AbstractDevice):
|
||||
[Optional. Default is 'TE923']
|
||||
"""
|
||||
self._last_rain = None
|
||||
self._last_rain_ts = None
|
||||
|
||||
global DEBUG_READ
|
||||
DEBUG_READ = int(stn_dict.get('debug_read', 0))
|
||||
@@ -400,11 +399,9 @@ class TE923Driver(weewx.drivers.AbstractDevice):
|
||||
status = self.station.get_status()
|
||||
packet = data_to_packet(data, status=status,
|
||||
last_rain=self._last_rain,
|
||||
last_rain_ts=self._last_rain_ts,
|
||||
sensor_map=self.sensor_map,
|
||||
battery_map=self.battery_map)
|
||||
self._last_rain = packet['rainTotal']
|
||||
self._last_rain_ts = packet['dateTime']
|
||||
ntries = 0
|
||||
yield packet
|
||||
time.sleep(self.polling_interval)
|
||||
@@ -428,8 +425,7 @@ class TE923Driver(weewx.drivers.AbstractDevice):
|
||||
data = self.station.get_status()
|
||||
return data
|
||||
|
||||
def data_to_packet(data, status=None,
|
||||
last_rain=None, last_rain_ts=None,
|
||||
def data_to_packet(data, status=None, last_rain=None,
|
||||
sensor_map=DEFAULT_SENSOR_MAP,
|
||||
battery_map=DEFAULT_BATTERY_MAP):
|
||||
"""convert raw data to format and units required by weewx
|
||||
@@ -548,7 +544,7 @@ def decode_th(buf, i):
|
||||
hlabel = 'h_%d' % i
|
||||
hstate = 'h_%d_state' % i
|
||||
|
||||
offset = i*3
|
||||
offset = i * 3
|
||||
data = {}
|
||||
data[tstate] = STATE_OK
|
||||
if DEBUG_DECODE:
|
||||
@@ -597,7 +593,7 @@ def decode_uv(buf):
|
||||
"""decode data from uv sensor"""
|
||||
data = {}
|
||||
if DEBUG_DECODE:
|
||||
logdbg("UVX BUF[18]=%02x BUF[19]=%02x" % (buf[18],buf[19]))
|
||||
logdbg("UVX BUF[18]=%02x BUF[19]=%02x" % (buf[18], buf[19]))
|
||||
if buf[18] == 0xaa and buf[19] == 0x0a:
|
||||
data['uv_state'] = STATE_MISSING_LINK
|
||||
data['uv'] = None
|
||||
@@ -743,6 +739,16 @@ def decode_status(buf):
|
||||
logdbg("STT %s %s" % (data['storm'], data['forecast']))
|
||||
return data
|
||||
|
||||
def _find_dev(vendor_id, product_id, device_id):
|
||||
"""Find the vendor and product ID on the USB."""
|
||||
for bus in usb.busses():
|
||||
for dev in bus.devices:
|
||||
if dev.idVendor == vendor_id and dev.idProduct == product_id:
|
||||
if device_id is None or dev.filename == device_id:
|
||||
loginf('Found device on USB bus=%s device=%s' % (bus.dirname, dev.filename))
|
||||
return dev
|
||||
return None
|
||||
|
||||
class BadRead(weewx.WeeWxIOError):
|
||||
"""Bogus data length, CRC, header block, or other read failure"""
|
||||
|
||||
@@ -769,18 +775,8 @@ class TE923(object):
|
||||
self.num_rec = 208
|
||||
self.num_blk = 256
|
||||
|
||||
def _find(self, vendor_id, product_id, device_id):
|
||||
"""Find the vendor and product ID on the USB."""
|
||||
for bus in usb.busses():
|
||||
for dev in bus.devices:
|
||||
if dev.idVendor == vendor_id and dev.idProduct == product_id:
|
||||
if device_id is None or dev.filename == device_id:
|
||||
loginf('Found device on USB bus=%s device=%s' % (bus.dirname, dev.filename))
|
||||
return dev
|
||||
return None
|
||||
|
||||
def open(self, interface=0):
|
||||
dev = self._find(self.vendor_id, self.product_id, self.device_id)
|
||||
dev = _find_dev(self.vendor_id, self.product_id, self.device_id)
|
||||
if not dev:
|
||||
logcrt("Cannot find USB device with VendorID=0x%04x ProductID=0x%04x DeviceID=%s" % (self.vendor_id, self.product_id, self.device_id))
|
||||
raise weewx.WeeWxIOError('Unable to find station on USB')
|
||||
@@ -919,11 +915,10 @@ class TE923(object):
|
||||
count = self.num_rec
|
||||
tt = time.localtime(time.time())
|
||||
addr = None
|
||||
records = []
|
||||
for i in range(count):
|
||||
logdbg("reading record %d of %d" % (i+1, count))
|
||||
addr,record = self.get_record(addr, tt.tm_year, tt.tm_mon)
|
||||
yield addr,record
|
||||
addr, record = self.get_record(addr, tt.tm_year, tt.tm_mon)
|
||||
yield addr, record
|
||||
|
||||
def get_record(self, addr=None, now_year=None, now_month=None):
|
||||
"""return a single record from station and address of the next
|
||||
@@ -973,7 +968,7 @@ class TE923(object):
|
||||
if addr > radr:
|
||||
addr = 0x000101
|
||||
|
||||
return addr,data
|
||||
return addr, data
|
||||
|
||||
|
||||
# define a main entry point for basic testing of the station without weewx
|
||||
@@ -1052,13 +1047,13 @@ if __name__ == '__main__':
|
||||
else:
|
||||
print_readings(data)
|
||||
if options.records is not None:
|
||||
for ptr,data in station.gen_records(count=options.records):
|
||||
for ptr, data in station.gen_records(count=options.records):
|
||||
if options.format.lower() == FMT_DICT:
|
||||
print_dict(data)
|
||||
else:
|
||||
print_readings(data)
|
||||
if options.blocks is not None:
|
||||
for ptr,block in station.gen_blocks(count=options.blocks):
|
||||
for ptr, block in station.gen_blocks(count=options.blocks):
|
||||
print_hex(ptr, block)
|
||||
finally:
|
||||
if station is not None:
|
||||
@@ -1086,7 +1081,7 @@ if __name__ == '__main__':
|
||||
output = [str(data['timestamp'])]
|
||||
output.append(getvalue(data, 't_in', '%0.2f'))
|
||||
output.append(getvalue(data, 'h_in', '%d'))
|
||||
for i in range(1,6):
|
||||
for i in range(1, 6):
|
||||
output.append(getvalue(data, 't_%d' % i, '%0.2f'))
|
||||
output.append(getvalue(data, 'h_%d' % i, '%d'))
|
||||
output.append(getvalue(data, 'slp', '%0.1f'))
|
||||
|
||||
@@ -97,7 +97,7 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
# Detach any old claimed interfaces
|
||||
try:
|
||||
self.devh.detachKernelDriver(self.interface)
|
||||
except:
|
||||
except usb.USBError:
|
||||
pass
|
||||
try:
|
||||
self.devh.claimInterface(self.interface)
|
||||
@@ -109,11 +109,11 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
def closePort(self):
|
||||
try:
|
||||
self.devh.releaseInterface()
|
||||
except:
|
||||
except usb.USBError:
|
||||
pass
|
||||
try:
|
||||
self.devh.detachKernelDriver(self.interface)
|
||||
except:
|
||||
except usb.USBError:
|
||||
pass
|
||||
|
||||
def genLoopPackets(self):
|
||||
@@ -127,7 +127,7 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
_packet_type = _packet[1]
|
||||
if _packet_type in WMR100._dispatch_dict:
|
||||
_record = WMR100._dispatch_dict[_packet_type](self, _packet)
|
||||
if _record is not None :
|
||||
if _record is not None:
|
||||
yield _record
|
||||
except IndexError:
|
||||
syslog.syslog(syslog.LOG_ERR, "wmr100: Malformed packet. %s" % _packet)
|
||||
@@ -164,7 +164,7 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
syslog.syslog(syslog.LOG_DEBUG, "wmr100: Exception while calculating checksum.")
|
||||
syslog.syslog(syslog.LOG_DEBUG, "**** %s" % e)
|
||||
else:
|
||||
actual_checksum = (buff[-1] << 8) + buff[-2]
|
||||
actual_checksum = (buff[-1] << 8) + buff[-2]
|
||||
if computed_checksum == actual_checksum:
|
||||
# Looks good. Yield the packet
|
||||
yield buff
|
||||
@@ -184,8 +184,7 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
#===============================================================================
|
||||
# USB functions
|
||||
#===============================================================================
|
||||
|
||||
|
||||
|
||||
def _findDevice(self):
|
||||
"""Find the given vendor and product IDs on the USB bus"""
|
||||
for bus in usb.busses():
|
||||
@@ -307,10 +306,10 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
channel = packet[2] & 0x0f
|
||||
|
||||
if channel == 0:
|
||||
_record['inTemp'] = T
|
||||
_record['inTemp'] = T
|
||||
_record['inTempBatteryStatus'] = (packet[0] & 0x40) >> 6
|
||||
elif channel == 1:
|
||||
_record['outTemp'] = T
|
||||
_record['outTemp'] = T
|
||||
# The WMR does not provide wind information in a temperature
|
||||
# packet, so we have to use old wind data to calculate wind chill,
|
||||
# provided it isn't too old and has gone stale. If no wind data has
|
||||
@@ -327,12 +326,12 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
elif channel >= 2:
|
||||
# If additional temperature sensors exist (channel>=2), then
|
||||
# use observation types 'extraTemp1', 'extraTemp2', etc.
|
||||
_record['extraTemp%d' % (channel-1)] = T
|
||||
_record['extraTemp%d' % (channel-1)] = T
|
||||
|
||||
return _record
|
||||
|
||||
def _barometer_packet(self, packet):
|
||||
SP = float(((packet[3] & 0x0f) << 8) + packet[2])
|
||||
SP = float(((packet[3] & 0x0f) << 8) + packet[2])
|
||||
# Although the WMR100 emits SLP, not all consoles in the series
|
||||
# (notably, the WMRS200) allow the user to set altitude. So, we must
|
||||
# calculate in software.
|
||||
@@ -353,8 +352,7 @@ class WMR100(weewx.drivers.AbstractDevice):
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC}
|
||||
return _record
|
||||
|
||||
|
||||
|
||||
def _wind_packet(self, packet):
|
||||
"""Decode a wind packet. Wind speed will be in kph"""
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ def confeditor_loader():
|
||||
|
||||
|
||||
# General decoding sensor maps.
|
||||
WIND_DIR_MAP = { 0:'N', 1:'NNE', 2:'NE', 3:'ENE',
|
||||
4:'E', 5:'ESE', 6:'SE', 7:'SSE',
|
||||
8:'S', 9:'SSW', 10:'SW', 11:'WSW',
|
||||
12:'W', 13:'WNW', 14:'NW', 15:'NNW' }
|
||||
FORECAST_MAP = { 0:'Partly Cloudy', 1:'Rainy', 2:'Cloudy', 3:'Sunny',
|
||||
4:'Clear Night', 5:'Snowy',
|
||||
6:'Partly Cloudy Night', 7:'Unknown7' }
|
||||
TRENDS = { 0:'Stable', 1:'Rising', 2:'Falling', 3:'Undefined' }
|
||||
WIND_DIR_MAP = {0: 'N', 1: 'NNE', 2: 'NE', 3: 'ENE',
|
||||
4: 'E', 5: 'ESE', 6: 'SE', 7: 'SSE',
|
||||
8: 'S', 9: 'SSW', 10: 'SW', 11: 'WSW',
|
||||
12: 'W', 13: 'WNW', 14: 'NW', 15: 'NNW'}
|
||||
FORECAST_MAP = {0: 'Partly Cloudy', 1: 'Rainy', 2: 'Cloudy',
|
||||
3: 'Sunny', 4: 'Clear Night', 5: 'Snowy',
|
||||
6: 'Partly Cloudy Night', 7: 'Unknown7'}
|
||||
TRENDS = {0: 'Stable', 1: 'Rising', 2: 'Falling', 3: 'Undefined'}
|
||||
|
||||
# Size of USB frame to read from weather console.
|
||||
_WMR200_USB_FRAME_SIZE = 8
|
||||
@@ -196,7 +196,7 @@ class UsbDevice(object):
|
||||
# Detach any old claimed interfaces
|
||||
try:
|
||||
self.handle.detachKernelDriver(self.interface)
|
||||
except usb.USBError, exception:
|
||||
except usb.USBError:
|
||||
pass
|
||||
|
||||
try:
|
||||
@@ -376,7 +376,7 @@ class Packet(object):
|
||||
def packet_process(self):
|
||||
"""Process the raw data and creates a record field."""
|
||||
# Convention is that this driver only works in metric units.
|
||||
self._record.update({'usUnits' : weewx.METRIC})
|
||||
self._record.update({'usUnits': weewx.METRIC})
|
||||
if DEBUG_PACKETS_RAW or DEBUG_PACKETS_COOKED:
|
||||
logdbg('Processing %s' % self.pkt_name)
|
||||
if self.pkt_len and self.pkt_len != self.size_actual():
|
||||
@@ -447,7 +447,7 @@ class Packet(object):
|
||||
if not self._bogus_packet \
|
||||
and self._checksum_calculate() != self._checksum_field():
|
||||
msg = ('Checksum error act:0x%04x exp:0x%04x'
|
||||
% (self._checksum_calculate(), self._checksum_field()))
|
||||
% (self._checksum_calculate(), self._checksum_field()))
|
||||
logerr(msg)
|
||||
logerr(self.to_string_raw(' packet:'))
|
||||
if self.wmr200.ignore_checksum:
|
||||
@@ -459,8 +459,7 @@ class Packet(object):
|
||||
|
||||
# Debug test to force checksum recovery testing.
|
||||
if DEBUG_CHECKSUM and (self.pkt_id % DEBUG_CHECKSUM) == 0:
|
||||
msg = ('Debug forced checksum error')
|
||||
raise weewx.CRCError(msg)
|
||||
raise weewx.CRCError('Debug forced checksum error')
|
||||
|
||||
@staticmethod
|
||||
def timestamp_host():
|
||||
@@ -526,8 +525,8 @@ class Packet(object):
|
||||
out = ' Packet cooked: '
|
||||
out += 'id:%d ' % self.pkt_id
|
||||
out += '%s ' % self.pkt_name
|
||||
out += '%s ' % weeutil.weeutil.timestamp_to_string\
|
||||
(self.timestamp_record())
|
||||
out += '%s ' % weeutil.weeutil.timestamp_to_string(
|
||||
self.timestamp_record())
|
||||
out += 'len:%d ' % self.size_actual()
|
||||
out += 'fields:%d ' % len(self._record)
|
||||
out += str(self._record)
|
||||
@@ -558,7 +557,7 @@ class PacketLive(Packet):
|
||||
def packet_process(self):
|
||||
"""Returns a records field to be processed by the weewx engine."""
|
||||
super(PacketLive, self).packet_process()
|
||||
self._record.update({'dateTime' : self.timestamp_live(), })
|
||||
self._record.update({'dateTime': self.timestamp_live(), })
|
||||
|
||||
def calc_time_drift(self):
|
||||
"""Returns the difference between PC time and the packet timestamp.
|
||||
@@ -567,7 +566,7 @@ class PacketLive(Packet):
|
||||
Only done once upon first live packet received."""
|
||||
if self.wmr200.time_drift is None:
|
||||
self.wmr200.time_drift = self.timestamp_host() \
|
||||
- self.timestamp_packet()
|
||||
- self.timestamp_packet()
|
||||
loginf('Time drift between host and console in seconds:%d' %
|
||||
self.wmr200.time_drift)
|
||||
|
||||
@@ -605,9 +604,9 @@ class PacketArchive(Packet):
|
||||
super(PacketArchive, self).packet_process()
|
||||
# If we need to adjust the timestamp if pc time is set we will do it
|
||||
# later
|
||||
self._record.update({'dateTime' : self.timestamp_packet(), })
|
||||
self._record.update({'dateTime': self.timestamp_packet(), })
|
||||
# Archive packets have extra field indicating interval time.
|
||||
self._record.update({'interval' : \
|
||||
self._record.update({'interval':
|
||||
int(self.wmr200.archive_interval / 60.0), })
|
||||
|
||||
def timestamp_adjust_drift(self):
|
||||
@@ -663,7 +662,7 @@ class PacketControl(Packet):
|
||||
|
||||
This packet isn't really passed up to weewx but is assigned a
|
||||
timestamp for completeness."""
|
||||
self._record.update({'dateTime' : self.timestamp_host(), })
|
||||
self._record.update({'dateTime': self.timestamp_host(), })
|
||||
|
||||
def print_cooked(self):
|
||||
"""Print the processed packet.
|
||||
@@ -777,7 +776,7 @@ def decode_wind(pkt, pkt_data):
|
||||
if DEBUG_PACKETS_WIND:
|
||||
logdbg(' Wind Dir: %s' % (WIND_DIR_MAP[pkt_data[0] & 0x0f]))
|
||||
logdbg(' Gust: %.1f m/s Wind:%.1f m/s' % (gust_speed, avg_speed))
|
||||
if windchill != None:
|
||||
if windchill is not None:
|
||||
logdbg(' Windchill: %.1f C' % (windchill))
|
||||
return record
|
||||
|
||||
@@ -895,7 +894,7 @@ class PacketRain(PacketLive):
|
||||
def decode_uvi(pkt, pkt_data):
|
||||
"""Decode the uvi portion of a wmr200 packet."""
|
||||
try:
|
||||
record = { 'UV' : pkt_data[0 & 0x0f] }
|
||||
record = {'UV': pkt_data[0 & 0x0f]}
|
||||
if DEBUG_PACKETS_UVI:
|
||||
logdbg(" UV index:%s\n" % record['UV'])
|
||||
return record
|
||||
@@ -943,11 +942,11 @@ def decode_pressure(pkt, pkt_data):
|
||||
|
||||
if DEBUG_PACKETS_PRESSURE:
|
||||
logdbg(' Forecast: %s' % FORECAST_MAP[forecast])
|
||||
logdbg(' Raw pressure: %.02f hPa' % (pressure))
|
||||
logdbg(' Raw pressure: %.02f hPa' % pressure)
|
||||
if unknown_nibble != 3:
|
||||
logdbg(' Pressure unknown nibble: 0x%x' % (unknown_nibble))
|
||||
logdbg(' Pressure unknown nibble: 0x%x' % unknown_nibble)
|
||||
logdbg(' Altitude corrected pressure: %.02f hPa console' %
|
||||
(alt_pressure_console))
|
||||
alt_pressure_console)
|
||||
return record
|
||||
|
||||
except IndexError:
|
||||
@@ -1018,26 +1017,25 @@ def decode_temp(pkt, pkt_data):
|
||||
|
||||
if sensor_id == 0:
|
||||
# Indoor temperature sensor.
|
||||
record['inTemp'] = temp
|
||||
record['inHumidity'] = humidity
|
||||
record['inTemp'] = temp
|
||||
record['inHumidity'] = humidity
|
||||
elif sensor_id == 1:
|
||||
# Outdoor temperature sensor.
|
||||
record['outTemp'] = temp
|
||||
record['outTemp'] = temp
|
||||
record['outHumidity'] = humidity
|
||||
record['heatindex'] = heat_index
|
||||
elif sensor_id >= 2:
|
||||
# Extra temperature sensors.
|
||||
# If additional temperature sensors exist (channel>=2), then
|
||||
# use observation types 'extraTemp1', 'extraTemp2', etc.
|
||||
record['extraTemp%d' % sensor_id] = temp
|
||||
record['extraTemp%d' % sensor_id] = temp
|
||||
record['extraHumid%d' % sensor_id] = humidity
|
||||
|
||||
if DEBUG_PACKETS_TEMP:
|
||||
logdbg((' Temperature id:%d %.1f C trend: %s'
|
||||
% (sensor_id, temp,
|
||||
TRENDS[temp_trend])))
|
||||
logdbg(' Humidity id:%d %d%% trend: %s' % (sensor_id, humidity,
|
||||
TRENDS[hum_trend]))
|
||||
logdbg(' Temperature id:%d %.1f C trend: %s'
|
||||
% (sensor_id, temp, TRENDS[temp_trend]))
|
||||
logdbg(' Humidity id:%d %d%% trend: %s'
|
||||
% (sensor_id, humidity, TRENDS[hum_trend]))
|
||||
logdbg((' Dew point id:%d: %.1f C' % (sensor_id, dew_point)))
|
||||
if heat_index:
|
||||
logdbg(' Heat id:%d index:%d' % (sensor_id, heat_index))
|
||||
@@ -1286,7 +1284,7 @@ class PollUsbDevice(threading.Thread):
|
||||
loginf('USB polling device thread signaled to start')
|
||||
|
||||
# Read and discard next data from weather console device.
|
||||
buf = self.usb_device.read_device()
|
||||
_ = self.usb_device.read_device()
|
||||
read_timeout_cnt = 0
|
||||
read_reset_cnt = 0
|
||||
|
||||
@@ -1378,7 +1376,7 @@ class PollUsbDevice(threading.Thread):
|
||||
class WMR200(weewx.drivers.AbstractDevice):
|
||||
"""Driver for the Oregon Scientific WMR200 station."""
|
||||
|
||||
def __init__(self, **stn_dict) :
|
||||
def __init__(self, **stn_dict):
|
||||
"""Initialize the wmr200 driver.
|
||||
|
||||
NAMED ARGUMENTS:
|
||||
@@ -1401,17 +1399,17 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
super(WMR200, self).__init__()
|
||||
|
||||
## User configurable options
|
||||
self._model = stn_dict.get('model', 'WMR200')
|
||||
self._model = stn_dict.get('model', 'WMR200')
|
||||
# Provide sensor faults in syslog.
|
||||
self._sensor_stat = weeutil.weeutil.tobool(stn_dict.get('sensor_status',
|
||||
True))
|
||||
# Use pc timestamps or weather console timestamps.
|
||||
self._use_pc_time = \
|
||||
weeutil.weeutil.tobool(stn_dict.get('use_pc_time', True))
|
||||
weeutil.weeutil.tobool(stn_dict.get('use_pc_time', True))
|
||||
|
||||
# Use archive data when possible.
|
||||
self._erase_archive = \
|
||||
weeutil.weeutil.tobool(stn_dict.get('erase_archive', False))
|
||||
weeutil.weeutil.tobool(stn_dict.get('erase_archive', False))
|
||||
|
||||
# Archive interval in seconds.
|
||||
self._archive_interval = int(stn_dict.get('archive_interval', 60))
|
||||
@@ -1455,7 +1453,7 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
|
||||
# Pass USB parameters to the USB device accessor.
|
||||
self.usb_device.in_endpoint = in_endpoint
|
||||
self.usb_device.interface = interface
|
||||
self.usb_device.interface = interface
|
||||
|
||||
# Locate the weather console device on the USB bus.
|
||||
if not self.usb_device.find_device(vendor_id, product_id):
|
||||
@@ -1482,8 +1480,7 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
'sock_rd' : self.sock_rd})
|
||||
|
||||
# Create the usb polling device thread.
|
||||
self._thread_usb_poll = PollUsbDevice(kwargs={'wmr200' :
|
||||
self})
|
||||
self._thread_usb_poll = PollUsbDevice(kwargs={'wmr200': self})
|
||||
|
||||
# Start the usb polling device thread.
|
||||
self._poll_device_enable = True
|
||||
@@ -1533,7 +1530,6 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
global DEBUG_CHECKSUM
|
||||
DEBUG_CHECKSUM = int(stn_dict.get('debug_checksum', 0))
|
||||
|
||||
|
||||
if DEBUG_CONFIG_DATA:
|
||||
logdbg('Configuration setup')
|
||||
logdbg(' Log sensor faults: %s' % self._sensor_stat)
|
||||
@@ -1749,7 +1745,7 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
% pkt.pkt_id)
|
||||
yield pkt.packet_record()
|
||||
|
||||
def XXXgenArchiveRecords(self, since_ts = 0):
|
||||
def XXXgenArchiveRecords(self, since_ts=0):
|
||||
"""A generator function to return archive packets from the wmr200.
|
||||
|
||||
weewx api to return archive records.
|
||||
@@ -1808,7 +1804,7 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
loginf(('genArchive() Ignoring received archive record'
|
||||
' before requested timestamp'))
|
||||
|
||||
def genStartupRecords(self, since_ts = 0):
|
||||
def genStartupRecords(self, since_ts=0):
|
||||
"""A generator function to present archive packets on start.
|
||||
|
||||
weewx api to return archive records."""
|
||||
@@ -1929,7 +1925,7 @@ class WMR200(weewx.drivers.AbstractDevice):
|
||||
% (self._archive_startup, cnt))
|
||||
if timestamp_packet_first is not None:
|
||||
startup_time = timestamp_packet_current \
|
||||
- timestamp_packet_first
|
||||
- timestamp_packet_first
|
||||
|
||||
loginf(('genStartup() Yielded %d packets in %d sec '
|
||||
' between these dates %s ==> %s' %
|
||||
|
||||
@@ -40,9 +40,9 @@ class WMR9x8ProtocolError(weewx.WeeWxIOError):
|
||||
"""Used to signal a protocol error condition"""
|
||||
|
||||
def channel_decoder(chan):
|
||||
if 1 <= chan <=2:
|
||||
if 1 <= chan <= 2:
|
||||
outchan = chan
|
||||
elif chan==4:
|
||||
elif chan == 4:
|
||||
outchan = 3
|
||||
else:
|
||||
raise WMR9x8ProtocolError("Bad channel number %d" % chan)
|
||||
@@ -80,14 +80,14 @@ class SerialWrapper(object):
|
||||
"""Wraps a serial connection returned from package serial"""
|
||||
|
||||
def __init__(self, port):
|
||||
self.port = port
|
||||
self.port = port
|
||||
# WMR9x8 specific settings
|
||||
self.serialconfig = {
|
||||
"bytesize":serial.EIGHTBITS,
|
||||
"parity":serial.PARITY_NONE,
|
||||
"stopbits":serial.STOPBITS_ONE,
|
||||
"timeout":None,
|
||||
"rtscts":1
|
||||
"bytesize": serial.EIGHTBITS,
|
||||
"parity": serial.PARITY_NONE,
|
||||
"stopbits": serial.STOPBITS_ONE,
|
||||
"timeout": None,
|
||||
"rtscts": 1
|
||||
}
|
||||
|
||||
def flush_input(self):
|
||||
@@ -106,7 +106,7 @@ class SerialWrapper(object):
|
||||
def openPort(self):
|
||||
# Open up the port and store it
|
||||
self.serial_port = serial.Serial(self.port, **self.serialconfig)
|
||||
syslog.syslog(syslog.LOG_DEBUG, "wmr9x8: Opened up serial port %s" % (self.port))
|
||||
syslog.syslog(syslog.LOG_DEBUG, "wmr9x8: Opened up serial port %s" % self.port)
|
||||
|
||||
def closePort(self):
|
||||
self.serial_port.close()
|
||||
@@ -120,7 +120,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
|
||||
The connection to the console will be open after initialization"""
|
||||
|
||||
def __init__(self, **stn_dict) :
|
||||
def __init__(self, **stn_dict):
|
||||
"""Initialize an object of type WMR9x8.
|
||||
|
||||
NAMED ARGUMENTS:
|
||||
@@ -137,7 +137,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
serial port. [Optional. Default is 5]
|
||||
"""
|
||||
|
||||
self.model = stn_dict.get('model', 'WMR968')
|
||||
self.model = stn_dict.get('model', 'WMR968')
|
||||
self.last_totalRain = None
|
||||
|
||||
# Create the specified port
|
||||
@@ -166,7 +166,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
wm918max = max(wm918_packet_type_size_map.items(), key=operator.itemgetter(1))[1]
|
||||
preBufferSize = max(wmr9x8max, wm918max)
|
||||
while True:
|
||||
buf.extend(map(ord, self.port.read(preBufferSize-len(buf))))
|
||||
buf.extend(map(ord, self.port.read(preBufferSize - len(buf))))
|
||||
# WMR-9x8/968 packets are framed by 0xFF characters
|
||||
if buf[0] == 0xFF and buf[1] == 0xFF and buf[2] in wmr9x8_packet_type_size_map:
|
||||
# Look up packet type, the expected size of this packet type
|
||||
@@ -243,27 +243,27 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
"""Decode a wind packet. Wind speed will be in kph"""
|
||||
null, status, dir1, dir10, dir100, gust10th, gust1, gust10, avg10th, avg1, avg10, chillstatus, chill1, chill10 = self._get_nibble_data(packet[1:]) # @UnusedVariable
|
||||
|
||||
battery = bool(status&0x04)
|
||||
battery = bool(status & 0x04)
|
||||
|
||||
# The console returns wind speeds in m/s. Our metric system requires kph,
|
||||
# so the result needs to be multiplied by 3.6
|
||||
_record = {
|
||||
'windBatteryStatus' : battery,
|
||||
'windSpeed' : ((avg10th/10.0) + avg1 + (avg10*10)) * 3.6,
|
||||
'windSpeed' : ((avg10th / 10.0) + avg1 + (avg10 * 10)) * 3.6,
|
||||
'windDir' : dir1 + (dir10 * 10) + (dir100 * 100),
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC
|
||||
}
|
||||
# Sometimes the station emits a wind gust that is less than the average wind.
|
||||
# Ignore it if this is the case.
|
||||
windGustSpeed = ((gust10th/10.0) + gust1 + (gust10*10)) * 3.6
|
||||
windGustSpeed = ((gust10th / 10.0) + gust1 + (gust10 * 10)) * 3.6
|
||||
if windGustSpeed >= _record['windSpeed']:
|
||||
_record['windGust'] = windGustSpeed
|
||||
|
||||
# Bit 1 of chillstatus is on if there is no wind chill data;
|
||||
# Bit 2 is on if it has overflowed. Check them both:
|
||||
if chillstatus & 0x6 == 0:
|
||||
chill = chill1 + (10*chill10)
|
||||
chill = chill1 + (10 * chill10)
|
||||
if chillstatus & 0x8:
|
||||
chill = -chill
|
||||
_record['windchill'] = chill
|
||||
@@ -275,22 +275,22 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
@wmr9x8_registerpackettype(typecode=0x01, size=16)
|
||||
def _wmr9x8_rain_packet(self, packet):
|
||||
null, status, cur1, cur10, cur100, tot10th, tot1, tot10, tot100, tot1000, yest1, yest10, yest100, yest1000, totstartmin1, totstartmin10, totstarthr1, totstarthr10, totstartday1, totstartday10, totstartmonth1, totstartmonth10, totstartyear1, totstartyear10 = self._get_nibble_data(packet[1:]) # @UnusedVariable
|
||||
battery = bool(status&0x04)
|
||||
battery = bool(status & 0x04)
|
||||
|
||||
# station units are mm and mm/hr while the internal metric units are cm and cm/hr
|
||||
# It is reported that total rainfall is biased by +0.5 mm
|
||||
_record = {
|
||||
'rainBatteryStatus' : battery,
|
||||
'rainRate' : (cur1 + (cur10 * 10) + (cur100 * 100))/10.0,
|
||||
'dayRain' : (yest1 + (yest10 * 10) + (yest100 * 100) + (yest1000 * 1000))/10.0,
|
||||
'totalRain' : (tot10th/10.0 + tot1 + 10.0*tot10 + 100.0*tot100 + 1000.0*tot1000)/10.0,
|
||||
'rainRate' : (cur1 + (cur10 * 10) + (cur100 * 100)) / 10.0,
|
||||
'dayRain' : (yest1 + (yest10 * 10) + (yest100 * 100) + (yest1000 * 1000)) / 10.0,
|
||||
'totalRain' : (tot10th / 10.0 + tot1 + 10.0 * tot10 + 100.0 * tot100 + 1000.0 * tot1000) / 10.0,
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC
|
||||
}
|
||||
# Because the WMR does not offer anything like bucket tips, we must
|
||||
# calculate it by looking for the change in total rain. Of course, this
|
||||
# won't work for the very first rain packet.
|
||||
_record['rain'] = (_record['totalRain']-self.last_totalRain) if self.last_totalRain is not None else None
|
||||
_record['rain'] = (_record['totalRain'] - self.last_totalRain) if self.last_totalRain is not None else None
|
||||
self.last_totalRain = _record['totalRain']
|
||||
return _record
|
||||
|
||||
@@ -300,7 +300,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
|
||||
chan = channel_decoder(chan)
|
||||
|
||||
battery = bool(status & 0x04)
|
||||
battery = bool(status & 0x04)
|
||||
_record = {
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC,
|
||||
@@ -329,7 +329,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
def _wmr9x8_mushroom_packet(self, packet):
|
||||
_, status, temp10th, temp1, temp10, temp100etc, hum1, hum10, dew1, dew10 = self._get_nibble_data(packet[1:])
|
||||
|
||||
battery = bool(status & 0x04)
|
||||
battery = bool(status & 0x04)
|
||||
_record = {
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC,
|
||||
@@ -358,7 +358,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
chan, status, temp10th, temp1, temp10, temp100etc = self._get_nibble_data(packet[1:])
|
||||
|
||||
chan = channel_decoder(chan)
|
||||
battery = bool(status & 0x04)
|
||||
battery = bool(status & 0x04)
|
||||
|
||||
_record = {'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC,
|
||||
@@ -367,7 +367,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
temp = temp10th / 10.0 + temp1 + 10.0 * temp10 + 100.0 * (temp100etc & 0x03)
|
||||
if temp100etc & 0x08:
|
||||
temp = -temp
|
||||
tempoverunder = temp100etc & 0x04
|
||||
tempoverunder = temp100etc & 0x04
|
||||
_record['extraTemp%d' % chan] = temp if not tempoverunder else None
|
||||
|
||||
return _record
|
||||
@@ -381,19 +381,19 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
|
||||
tempoverunder = bool(temp100etc & 0x04)
|
||||
if not tempoverunder:
|
||||
temp = (temp10th / 10.0) + temp1 + (temp10 * 10) + ((temp100etc&0x03) * 100)
|
||||
temp = (temp10th / 10.0) + temp1 + (temp10 * 10) + ((temp100etc & 0x03) * 100)
|
||||
if temp100etc & 0x08:
|
||||
temp = -temp
|
||||
else:
|
||||
temp = None
|
||||
|
||||
dewunder = bool(status&0x01)
|
||||
dewunder = bool(status & 0x01)
|
||||
if not dewunder:
|
||||
dew = dew1 + (dew10 * 10)
|
||||
else:
|
||||
dew = None
|
||||
|
||||
rawsp = ((baro10&0xF) << 4) | baro1
|
||||
rawsp = ((baro10 & 0xF) << 4) | baro1
|
||||
sp = rawsp + 795
|
||||
pre_slpoff = (slpoff10th / 10.0) + slpoff1 + (slpoff10 * 10) + (slpoff100 * 100)
|
||||
slpoff = (1000 + pre_slpoff) if pre_slpoff < 400.0 else pre_slpoff
|
||||
@@ -403,7 +403,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
'inHumidity' : hum,
|
||||
'inTemp' : temp,
|
||||
'dewpoint' : dew,
|
||||
'barometer' : rawsp+slpoff,
|
||||
'barometer' : rawsp + slpoff,
|
||||
'pressure' : sp,
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC
|
||||
@@ -415,24 +415,24 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
def _wmr9x8_in_ext_thermohygrobaro_packet(self, packet):
|
||||
null, status, temp10th, temp1, temp10, temp100etc, hum1, hum10, dew1, dew10, baro1, baro10, baro100, wstatus, null2, slpoff10th, slpoff1, slpoff10, slpoff100, slpoff1000 = self._get_nibble_data(packet[1:]) # @UnusedVariable
|
||||
|
||||
battery = bool(status&0x04)
|
||||
battery = bool(status & 0x04)
|
||||
hum = hum1 + (hum10 * 10)
|
||||
|
||||
tempoverunder = bool(temp100etc & 0x04)
|
||||
if not tempoverunder:
|
||||
temp = (temp10th / 10.0) + temp1 + (temp10 * 10) + ((temp100etc&0x03) * 100)
|
||||
temp = (temp10th / 10.0) + temp1 + (temp10 * 10) + ((temp100etc & 0x03) * 100)
|
||||
if temp100etc & 0x08:
|
||||
temp = -temp
|
||||
else:
|
||||
temp = None
|
||||
|
||||
dewunder = bool(status&0x01)
|
||||
dewunder = bool(status & 0x01)
|
||||
if not dewunder:
|
||||
dew = dew1 + (dew10 * 10)
|
||||
else:
|
||||
dew = None
|
||||
|
||||
rawsp = ((baro100&0x01) << 8) | ((baro10&0xF) << 4) | baro1
|
||||
rawsp = ((baro100 & 0x01) << 8) | ((baro10 & 0xF) << 4) | baro1
|
||||
sp = rawsp + 600
|
||||
slpoff = (slpoff10th / 10.0) + slpoff1 + (slpoff10 * 10) + (slpoff100 * 100) + (slpoff1000 * 1000)
|
||||
|
||||
@@ -454,7 +454,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
"""The (partial) time packet is not used by weewx.
|
||||
However, the last time is saved in case getTime() is called."""
|
||||
min1, min10 = self._get_nibble_data(packet[1:])
|
||||
minutes = min1 + ((min10&0x07) * 10)
|
||||
minutes = min1 + ((min10 & 0x07) * 10)
|
||||
|
||||
cur = time.gmtime()
|
||||
self.last_time = time.mktime(
|
||||
@@ -475,7 +475,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
month = month1 + (month10 * 10)
|
||||
day = day1 + (day10 * 10)
|
||||
hour = hour1 + (hour10 * 10)
|
||||
minutes = min1 + ((min10&0x07) * 10)
|
||||
minutes = min1 + ((min10 & 0x07) * 10)
|
||||
cur = time.gmtime()
|
||||
# TODO: not sure if using tm_isdst is correct here
|
||||
self.last_time = time.mktime(
|
||||
@@ -493,9 +493,9 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
# The console returns wind speeds in m/s. Our metric system requires kph,
|
||||
# so the result needs to be multiplied by 3.6
|
||||
_record = {
|
||||
'windSpeed' : ((avg10th/10.0) + avg1 + (avg10*10)) * 3.6,
|
||||
'windSpeed' : ((avg10th / 10.0) + avg1 + (avg10*10)) * 3.6,
|
||||
'windDir' : avgdir1 + (avgdir10 * 10) + (avgdir100 * 100),
|
||||
'windGust' : ((gust10th/10.0) + gust1 + (gust10*10)) * 3.6,
|
||||
'windGust' : ((gust10th / 10.0) + gust1 + (gust10 * 10)) * 3.6,
|
||||
'windGustDir' : dir1 + (dir10 * 10) + (dir100 * 100),
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC
|
||||
@@ -515,8 +515,8 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
# It is reported that total rainfall is biased by +0.5 mm
|
||||
_record = {
|
||||
'rainRate' : (cur1 + (cur10 * 10) + (cur100 * 100)) / 10.0,
|
||||
'yesterdayRain' : (yest1 + (yest10 * 10) + (yest100 * 100) + (yest1000 * 1000))/10.0,
|
||||
'totalRain' : (tot1 + (tot10 * 10) + (tot100 * 100) + (tot1000 * 1000))/10.0,
|
||||
'yesterdayRain' : (yest1 + (yest10 * 10) + (yest100 * 100) + (yest1000 * 1000)) / 10.0,
|
||||
'totalRain' : (tot1 + (tot10 * 10) + (tot100 * 100) + (tot1000 * 1000)) / 10.0,
|
||||
'dateTime' : int(time.time() + 0.5),
|
||||
'usUnits' : weewx.METRIC
|
||||
}
|
||||
@@ -550,10 +550,10 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
temp10th, temp1, temp10, null = self._get_nibble_data(packet[1:3]) # @UnusedVariable
|
||||
tempout10th, tempout1, tempout10, null = self._get_nibble_data(packet[16:18]) # @UnusedVariable
|
||||
|
||||
temp = (temp10th/10.0) + temp1 + ((temp10&0x7)*10)
|
||||
temp *= -1 if (temp10&0x08) else 1
|
||||
tempout = (tempout10th/10.0) + tempout1 + ((tempout10&0x7)*10)
|
||||
tempout *= -1 if (tempout10&0x08) else 1
|
||||
temp = (temp10th / 10.0) + temp1 + ((temp10 & 0x7) * 10)
|
||||
temp *= -1 if (temp10 & 0x08) else 1
|
||||
tempout = (tempout10th / 10.0) + tempout1 + ((tempout10 & 0x7) * 10)
|
||||
tempout *= -1 if (tempout10 & 0x08) else 1
|
||||
_record = {
|
||||
'inTemp' : temp,
|
||||
'outTemp' : tempout
|
||||
@@ -564,8 +564,8 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
except AttributeError:
|
||||
_record['apparentTemp'] = None
|
||||
|
||||
_record ['dateTime'] = int(time.time() + 0.5)
|
||||
_record ['usUnits'] = weewx.METRIC
|
||||
_record['dateTime'] = int(time.time() + 0.5)
|
||||
_record['usUnits'] = weewx.METRIC
|
||||
return _record
|
||||
|
||||
@wm918_registerpackettype(typecode=0xaf, size=31)
|
||||
@@ -575,8 +575,8 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
|
||||
#dew = dewin1 + (dewin10 * 10)
|
||||
#dewout = dewout1 + (dewout10 *10)
|
||||
sp = baro1 + (baro10 *10) + (baro100 *100) + (baro1000 * 1000)
|
||||
slp = (slp10th / 10.0) + slp1 + (slp10 * 10) + (slp100 * 100) +(slp1000 * 1000)
|
||||
sp = baro1 + (baro10 * 10) + (baro100 * 100) + (baro1000 * 1000)
|
||||
slp = (slp10th / 10.0) + slp1 + (slp10 * 10) + (slp100 * 100) + (slp1000 * 1000)
|
||||
_record = {
|
||||
'barometer' : slp,
|
||||
'pressure' : sp,
|
||||
@@ -590,7 +590,7 @@ class WMR9x8(weewx.drivers.AbstractDevice):
|
||||
return _record
|
||||
|
||||
|
||||
class WMR200ConfEditor(weewx.drivers.AbstractConfEditor):
|
||||
class WMR9x8ConfEditor(weewx.drivers.AbstractConfEditor):
|
||||
@property
|
||||
def version(self):
|
||||
return DRIVER_VERSION
|
||||
|
||||
@@ -180,7 +180,7 @@ class Station(object):
|
||||
else:
|
||||
try:
|
||||
int(c, 16)
|
||||
except ValueError, e:
|
||||
except ValueError:
|
||||
bad_byte = True
|
||||
b.append(c)
|
||||
if DEBUG_READ:
|
||||
|
||||
@@ -978,7 +978,7 @@ def log_traceback(dst=syslog.LOG_INFO, prefix='**** '):
|
||||
traceback.print_exc(file=sfd)
|
||||
sfd.seek(0)
|
||||
for line in sfd:
|
||||
logmsg(dst, prefix+line)
|
||||
logmsg(dst, prefix + line)
|
||||
del sfd
|
||||
|
||||
def log_frame(n, buf):
|
||||
@@ -986,7 +986,7 @@ def log_frame(n, buf):
|
||||
strbuf = ''
|
||||
for i in xrange(0,n):
|
||||
strbuf += str('%02x ' % buf[i])
|
||||
if (i+1) % 16 == 0:
|
||||
if (i + 1) % 16 == 0:
|
||||
logdbg(strbuf)
|
||||
strbuf = ''
|
||||
if strbuf:
|
||||
@@ -1011,7 +1011,7 @@ def calc_checksum(buf, start, end=None):
|
||||
return cs
|
||||
|
||||
def get_next_index(idx):
|
||||
return get_index(idx+1)
|
||||
return get_index(idx + 1)
|
||||
|
||||
def get_index(idx):
|
||||
if idx < 0:
|
||||
@@ -1025,7 +1025,7 @@ def tstr_to_ts(tstr):
|
||||
return None
|
||||
return int(time.mktime(time.strptime(tstr, "%Y-%m-%d %H:%M:%S")))
|
||||
|
||||
def bytes_to_addr(a,b,c):
|
||||
def bytes_to_addr(a, b, c):
|
||||
return ((((a & 0xF) << 8) | b) << 8) | c
|
||||
|
||||
def addr_to_index(addr):
|
||||
@@ -1119,7 +1119,7 @@ class WS28xxConfigurator(weewx.drivers.AbstractConfigurator):
|
||||
if self.station.transceiver_is_present():
|
||||
print 'Transceiver is present'
|
||||
sn = self.station.get_transceiver_serial()
|
||||
print 'serial: %s' % sn
|
||||
print 'serial: %s' % sn
|
||||
tid = self.station.get_transceiver_id()
|
||||
print 'id: %d (0x%04x)' % (tid, tid)
|
||||
break
|
||||
@@ -1275,15 +1275,15 @@ class WS28xxDriver(weewx.drivers.AbstractDevice):
|
||||
[Optional. Default is None]
|
||||
"""
|
||||
|
||||
self.model = stn_dict.get('model', 'LaCrosse WS28xx')
|
||||
self.polling_interval = int(stn_dict.get('polling_interval', 30))
|
||||
self.comm_interval = int(stn_dict.get('comm_interval', 3))
|
||||
self.frequency = stn_dict.get('transceiver_frequency', 'US')
|
||||
self.device_id = stn_dict.get('device_id', None)
|
||||
self.serial = stn_dict.get('serial', None)
|
||||
self.model = stn_dict.get('model', 'LaCrosse WS28xx')
|
||||
self.polling_interval = int(stn_dict.get('polling_interval', 30))
|
||||
self.comm_interval = int(stn_dict.get('comm_interval', 3))
|
||||
self.frequency = stn_dict.get('transceiver_frequency', 'US')
|
||||
self.device_id = stn_dict.get('device_id', None)
|
||||
self.serial = stn_dict.get('serial', None)
|
||||
|
||||
self.vendor_id = 0x6666
|
||||
self.product_id = 0x5555
|
||||
self.vendor_id = 0x6666
|
||||
self.product_id = 0x5555
|
||||
|
||||
now = int(time.time())
|
||||
self._service = None
|
||||
@@ -1335,7 +1335,7 @@ class WS28xxDriver(weewx.drivers.AbstractDevice):
|
||||
|
||||
# if no new weather data, return an empty packet
|
||||
if packet is None:
|
||||
packet = { 'usUnits': weewx.METRIC, 'dateTime': now }
|
||||
packet = {'usUnits': weewx.METRIC, 'dateTime': now}
|
||||
# if no new weather data for awhile, log it
|
||||
if self._last_obs_ts is None or \
|
||||
now - self._last_obs_ts > self._nodata_interval:
|
||||
@@ -1555,11 +1555,11 @@ class WS28xxDriver(weewx.drivers.AbstractDevice):
|
||||
# eddie de pieri, which is in turn based on the HeavyWeather implementation.
|
||||
|
||||
class BadResponse(Exception):
|
||||
'''raised when unexpected data found in frame buffer'''
|
||||
"""raised when unexpected data found in frame buffer"""
|
||||
pass
|
||||
|
||||
class DataWritten(Exception):
|
||||
'''raised when message 'data written' in frame buffer'''
|
||||
"""raised when message 'data written' in frame buffer"""
|
||||
pass
|
||||
|
||||
class BitHandling:
|
||||
@@ -1567,31 +1567,31 @@ class BitHandling:
|
||||
@staticmethod
|
||||
def testBit(int_type, offset):
|
||||
mask = 1 << offset
|
||||
return(int_type & mask)
|
||||
return int_type & mask
|
||||
|
||||
# return an integer with the bit at 'offset' set to 1.
|
||||
@staticmethod
|
||||
def setBit(int_type, offset):
|
||||
mask = 1 << offset
|
||||
return(int_type | mask)
|
||||
return int_type | mask
|
||||
|
||||
# return an integer with the bit at 'offset' set to 1.
|
||||
@staticmethod
|
||||
def setBitVal(int_type, offset, val):
|
||||
mask = val << offset
|
||||
return(int_type | mask)
|
||||
return int_type | mask
|
||||
|
||||
# return an integer with the bit at 'offset' cleared.
|
||||
@staticmethod
|
||||
def clearBit(int_type, offset):
|
||||
mask = ~(1 << offset)
|
||||
return(int_type & mask)
|
||||
return int_type & mask
|
||||
|
||||
# return an integer with the bit at 'offset' inverted, 0->1 and 1->0.
|
||||
@staticmethod
|
||||
def toggleBit(int_type, offset):
|
||||
mask = 1 << offset
|
||||
return(int_type ^ mask)
|
||||
return int_type ^ mask
|
||||
|
||||
class EHistoryInterval:
|
||||
hi01Min = 0
|
||||
@@ -1765,10 +1765,10 @@ def getFrequencyStandard(frequency):
|
||||
# 2 - thermo-hygro
|
||||
# 3 - console
|
||||
|
||||
batterybits = { 'wind':0, 'rain':1, 'th':2, 'console':3 }
|
||||
batterybits = {'wind':0, 'rain':1, 'th':2, 'console':3}
|
||||
|
||||
def getBatteryStatus(status, flag):
|
||||
'''Return 1 if bit is set, 0 otherwise'''
|
||||
"""Return 1 if bit is set, 0 otherwise"""
|
||||
bit = batterybits.get(flag)
|
||||
if bit is None:
|
||||
return None
|
||||
@@ -1798,13 +1798,13 @@ def getHistoryInterval(i):
|
||||
# OFL - outside factory limits
|
||||
class CWeatherTraits(object):
|
||||
windDirMap = {
|
||||
0:"N", 1:"NNE", 2:"NE", 3:"ENE", 4:"E", 5:"ESE", 6:"SE", 7:"SSE",
|
||||
8:"S", 9:"SSW", 10:"SW", 11:"WSW", 12:"W", 13:"WNW", 14:"NW",
|
||||
15:"NWN", 16:"err", 17:"inv", 18:"None" }
|
||||
0: "N", 1: "NNE", 2: "NE", 3: "ENE", 4: "E", 5: "ESE", 6: "SE",
|
||||
7: "SSE", 8: "S", 9: "SSW", 10: "SW", 11: "WSW", 12: "W",
|
||||
13: "WNW", 14: "NW", 15: "NWN", 16: "err", 17: "inv", 18: "None" }
|
||||
forecastMap = {
|
||||
0:"Rainy(Bad)", 1:"Cloudy(Neutral)", 2:"Sunny(Good)", 3:"Error" }
|
||||
0: "Rainy(Bad)", 1: "Cloudy(Neutral)", 2: "Sunny(Good)", 3: "Error" }
|
||||
trendMap = {
|
||||
0:"Stable(Neutral)", 1:"Rising(Up)", 2:"Falling(Down)", 3:"Error" }
|
||||
0: "Stable(Neutral)", 1: "Rising(Up)", 2: "Falling(Down)", 3: "Error" }
|
||||
|
||||
@staticmethod
|
||||
def TemperatureNP():
|
||||
@@ -1874,7 +1874,7 @@ _bad_labels = ['RainLastMonthMax','RainLastWeekMax','PressureRelativeMin']
|
||||
class USBHardware(object):
|
||||
@staticmethod
|
||||
def isOFL2(buf, start, StartOnHiNibble):
|
||||
if StartOnHiNibble :
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4) == 15 \
|
||||
or (buf[0][start+0] & 0xF) == 15
|
||||
else:
|
||||
@@ -1884,7 +1884,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def isOFL3(buf, start, StartOnHiNibble):
|
||||
if StartOnHiNibble :
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4) == 15 \
|
||||
or (buf[0][start+0] & 0xF) == 15 \
|
||||
or (buf[0][start+1] >> 4) == 15
|
||||
@@ -1896,7 +1896,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def isOFL5(buf, start, StartOnHiNibble):
|
||||
if StartOnHiNibble :
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4) == 15 \
|
||||
or (buf[0][start+0] & 0xF) == 15 \
|
||||
or (buf[0][start+1] >> 4) == 15 \
|
||||
@@ -1912,7 +1912,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def isErr2(buf, start, StartOnHiNibble):
|
||||
if StartOnHiNibble :
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4) >= 10 \
|
||||
and (buf[0][start+0] >> 4) != 15 \
|
||||
or (buf[0][start+0] & 0xF) >= 10 \
|
||||
@@ -1926,7 +1926,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def isErr3(buf, start, StartOnHiNibble):
|
||||
if StartOnHiNibble :
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4) >= 10 \
|
||||
and (buf[0][start+0] >> 4) != 15 \
|
||||
or (buf[0][start+0] & 0xF) >= 10 \
|
||||
@@ -1944,7 +1944,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def isErr5(buf, start, StartOnHiNibble):
|
||||
if StartOnHiNibble :
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4) >= 10 \
|
||||
and (buf[0][start+0] >> 4) != 15 \
|
||||
or (buf[0][start+0] & 0xF) >= 10 \
|
||||
@@ -1983,7 +1983,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toInt_2(buf, start, StartOnHiNibble):
|
||||
'''read 2 nibbles'''
|
||||
"""read 2 nibbles"""
|
||||
if StartOnHiNibble:
|
||||
rawpre = (buf[0][start+0] >> 4)* 10 \
|
||||
+ (buf[0][start+0] & 0xF)* 1
|
||||
@@ -1994,12 +1994,12 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toRain_7_3(buf, start, StartOnHiNibble):
|
||||
'''read 7 nibbles, presentation with 3 decimals; units of mm'''
|
||||
if ( USBHardware.isErr2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isErr5(buf, start+1, StartOnHiNibble)):
|
||||
"""read 7 nibbles, presentation with 3 decimals; units of mm"""
|
||||
if (USBHardware.isErr2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isErr5(buf, start+1, StartOnHiNibble)):
|
||||
result = CWeatherTraits.RainNP()
|
||||
elif ( USBHardware.isOFL2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isOFL5(buf, start+1, StartOnHiNibble) ):
|
||||
elif (USBHardware.isOFL2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isOFL5(buf, start+1, StartOnHiNibble)):
|
||||
result = CWeatherTraits.RainOFL()
|
||||
elif StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4)* 1000 \
|
||||
@@ -2022,13 +2022,13 @@ class USBHardware(object):
|
||||
@staticmethod
|
||||
def toRain_6_2(buf, start, StartOnHiNibble):
|
||||
'''read 6 nibbles, presentation with 2 decimals; units of mm'''
|
||||
if ( USBHardware.isErr2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isErr2(buf, start+1, StartOnHiNibble) or
|
||||
USBHardware.isErr2(buf, start+2, StartOnHiNibble) ):
|
||||
if (USBHardware.isErr2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isErr2(buf, start+1, StartOnHiNibble) or
|
||||
USBHardware.isErr2(buf, start+2, StartOnHiNibble) ):
|
||||
result = CWeatherTraits.RainNP()
|
||||
elif ( USBHardware.isOFL2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isOFL2(buf, start+1, StartOnHiNibble) or
|
||||
USBHardware.isOFL2(buf, start+2, StartOnHiNibble) ):
|
||||
elif (USBHardware.isOFL2(buf, start+0, StartOnHiNibble) or
|
||||
USBHardware.isOFL2(buf, start+1, StartOnHiNibble) or
|
||||
USBHardware.isOFL2(buf, start+2, StartOnHiNibble)):
|
||||
result = CWeatherTraits.RainOFL()
|
||||
elif StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4)* 1000 \
|
||||
@@ -2048,8 +2048,8 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toRain_3_1(buf, start, StartOnHiNibble):
|
||||
'''read 3 nibbles, presentation with 1 decimal; units of 0.1 inch'''
|
||||
if StartOnHiNibble :
|
||||
"""read 3 nibbles, presentation with 1 decimal; units of 0.1 inch"""
|
||||
if StartOnHiNibble:
|
||||
hibyte = buf[0][start+0]
|
||||
lobyte = (buf[0][start+1] >> 4) & 0xF
|
||||
else:
|
||||
@@ -2066,7 +2066,7 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toFloat_3_1(buf, start, StartOnHiNibble):
|
||||
'''read 3 nibbles, presentation with 1 decimal'''
|
||||
"""read 3 nibbles, presentation with 1 decimal"""
|
||||
if StartOnHiNibble:
|
||||
result = (buf[0][start+0] >> 4)*16**2 \
|
||||
+ (buf[0][start+0] & 0xF)* 16**1 \
|
||||
@@ -2080,13 +2080,13 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toDateTime(buf, start, StartOnHiNibble, label):
|
||||
'''read 10 nibbles, presentation as DateTime'''
|
||||
"""read 10 nibbles, presentation as DateTime"""
|
||||
result = None
|
||||
if ( USBHardware.isErr2(buf, start+0, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+1, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+2, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+3, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+4, StartOnHiNibble) ):
|
||||
if (USBHardware.isErr2(buf, start+0, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+1, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+2, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+3, StartOnHiNibble)
|
||||
or USBHardware.isErr2(buf, start+4, StartOnHiNibble)):
|
||||
logerr('ToDateTime: bogus date for %s: error status in buffer' %
|
||||
label)
|
||||
else:
|
||||
@@ -2110,10 +2110,10 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toHumidity_2_0(buf, start, StartOnHiNibble):
|
||||
'''read 2 nibbles, presentation with 0 decimal'''
|
||||
if USBHardware.isErr2(buf, start+0, StartOnHiNibble) :
|
||||
"""read 2 nibbles, presentation with 0 decimal"""
|
||||
if USBHardware.isErr2(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.HumidityNP()
|
||||
elif USBHardware.isOFL2(buf, start+0, StartOnHiNibble) :
|
||||
elif USBHardware.isOFL2(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.HumidityOFL()
|
||||
else:
|
||||
result = USBHardware.toInt_2(buf, start, StartOnHiNibble)
|
||||
@@ -2121,10 +2121,10 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toTemperature_5_3(buf, start, StartOnHiNibble):
|
||||
'''read 5 nibbles, presentation with 3 decimals; units of degree C'''
|
||||
if USBHardware.isErr5(buf, start+0, StartOnHiNibble) :
|
||||
"""read 5 nibbles, presentation with 3 decimals; units of degree C"""
|
||||
if USBHardware.isErr5(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.TemperatureNP()
|
||||
elif USBHardware.isOFL5(buf, start+0, StartOnHiNibble) :
|
||||
elif USBHardware.isOFL5(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.TemperatureOFL()
|
||||
else:
|
||||
if StartOnHiNibble:
|
||||
@@ -2144,10 +2144,10 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toTemperature_3_1(buf, start, StartOnHiNibble):
|
||||
'''read 3 nibbles, presentation with 1 decimal; units of degree C'''
|
||||
if USBHardware.isErr3(buf, start+0, StartOnHiNibble) :
|
||||
"""read 3 nibbles, presentation with 1 decimal; units of degree C"""
|
||||
if USBHardware.isErr3(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.TemperatureNP()
|
||||
elif USBHardware.isOFL3(buf, start+0, StartOnHiNibble) :
|
||||
elif USBHardware.isOFL3(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.TemperatureOFL()
|
||||
else:
|
||||
if StartOnHiNibble :
|
||||
@@ -2163,33 +2163,33 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toWindspeed_6_2(buf, start):
|
||||
'''read 6 nibbles, presentation with 2 decimals; units of km/h'''
|
||||
"""read 6 nibbles, presentation with 2 decimals; units of km/h"""
|
||||
result = (buf[0][start+0] >> 4)* 16**5 \
|
||||
+ (buf[0][start+0] & 0xF)* 16**4 \
|
||||
+ (buf[0][start+1] >> 4)* 16**3 \
|
||||
+ (buf[0][start+1] & 0xF)* 16**2 \
|
||||
+ (buf[0][start+2] >> 4)* 16**1 \
|
||||
+ (buf[0][start+2] & 0xF)
|
||||
result = result / 256.0
|
||||
result = result / 100.0 # km/h
|
||||
result /= 256.0
|
||||
result /= 100.0 # km/h
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def toWindspeed_3_1(buf, start, StartOnHiNibble):
|
||||
'''read 3 nibbles, presentation with 1 decimal; units of m/s'''
|
||||
"""read 3 nibbles, presentation with 1 decimal; units of m/s"""
|
||||
if StartOnHiNibble :
|
||||
hibyte = buf[0][start+0]
|
||||
lobyte = (buf[0][start+1] >> 4) & 0xF
|
||||
else:
|
||||
hibyte = 16*(buf[0][start+0] & 0xF) + ((buf[0][start+1] >> 4) & 0xF)
|
||||
lobyte = buf[0][start+1] & 0xF
|
||||
if hibyte == 0xFF and lobyte == 0xE :
|
||||
if hibyte == 0xFF and lobyte == 0xE:
|
||||
result = CWeatherTraits.WindNP()
|
||||
elif hibyte == 0xFF and lobyte == 0xF :
|
||||
elif hibyte == 0xFF and lobyte == 0xF:
|
||||
result = CWeatherTraits.WindOFL()
|
||||
else:
|
||||
result = USBHardware.toFloat_3_1(buf, start, StartOnHiNibble) # m/s
|
||||
result = result * 3.6 # km/h
|
||||
result *= 3.6 # km/h
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
@@ -2199,10 +2199,10 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toPressure_hPa_5_1(buf, start, StartOnHiNibble):
|
||||
'''read 5 nibbles, presentation with 1 decimal; units of hPa (mbar)'''
|
||||
if USBHardware.isErr5(buf, start+0, StartOnHiNibble) :
|
||||
"""read 5 nibbles, presentation with 1 decimal; units of hPa (mbar)"""
|
||||
if USBHardware.isErr5(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.PressureNP()
|
||||
elif USBHardware.isOFL5(buf, start+0, StartOnHiNibble) :
|
||||
elif USBHardware.isOFL5(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.PressureOFL()
|
||||
elif StartOnHiNibble :
|
||||
result = (buf[0][start+0] >> 4)* 1000 \
|
||||
@@ -2220,10 +2220,10 @@ class USBHardware(object):
|
||||
|
||||
@staticmethod
|
||||
def toPressure_inHg_5_2(buf, start, StartOnHiNibble):
|
||||
'''read 5 nibbles, presentation with 2 decimals; units of inHg'''
|
||||
if USBHardware.isErr5(buf, start+0, StartOnHiNibble) :
|
||||
"""read 5 nibbles, presentation with 2 decimals; units of inHg"""
|
||||
if USBHardware.isErr5(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.PressureNP()
|
||||
elif USBHardware.isOFL5(buf, start+0, StartOnHiNibble) :
|
||||
elif USBHardware.isOFL5(buf, start+0, StartOnHiNibble):
|
||||
result = CWeatherTraits.PressureOFL()
|
||||
elif StartOnHiNibble :
|
||||
result = (buf[0][start+0] >> 4)* 100 \
|
||||
@@ -2404,12 +2404,11 @@ class CCurrentWeatherData(object):
|
||||
self._WindDirection5 = w5
|
||||
|
||||
if DEBUG_WEATHER_DATA > 2:
|
||||
unknownbuf = [0]
|
||||
unknownbuf[0] = [0]*9
|
||||
unknownbuf = [0]*9
|
||||
for i in xrange(0,9):
|
||||
unknownbuf[0][i] = nbuf[0][163+i]
|
||||
unknownbuf[i] = nbuf[163+i]
|
||||
strbuf = ""
|
||||
for i in unknownbuf[0]:
|
||||
for i in unknownbuf:
|
||||
strbuf += str("%.2x " % i)
|
||||
logdbg('Bytes with unknown meaning at 157-165: %s' % strbuf)
|
||||
|
||||
@@ -3095,13 +3094,13 @@ class sHID(object):
|
||||
handle = dev.open()
|
||||
try:
|
||||
buf = self.readCfg(handle, 0x1F9, 7)
|
||||
sn = str("%02d"%(buf[0]))
|
||||
sn += str("%02d"%(buf[1]))
|
||||
sn += str("%02d"%(buf[2]))
|
||||
sn += str("%02d"%(buf[3]))
|
||||
sn += str("%02d"%(buf[4]))
|
||||
sn += str("%02d"%(buf[5]))
|
||||
sn += str("%02d"%(buf[6]))
|
||||
sn = str("%02d" % (buf[0]))
|
||||
sn += str("%02d" % (buf[1]))
|
||||
sn += str("%02d" % (buf[2]))
|
||||
sn += str("%02d" % (buf[3]))
|
||||
sn += str("%02d" % (buf[4]))
|
||||
sn += str("%02d" % (buf[5]))
|
||||
sn += str("%02d" % (buf[6]))
|
||||
if str(serial) == sn:
|
||||
loginf('found transceiver at bus=%s device=%s serial=%s' % (bus.dirname, dev.filename, sn))
|
||||
return dev
|
||||
@@ -3197,7 +3196,7 @@ class sHID(object):
|
||||
StateBuffer[0][0]=buf[1]
|
||||
StateBuffer[0][1]=buf[2]
|
||||
|
||||
def readConfigFlash(self,addr,numBytes,data):
|
||||
def readConfigFlash(self, addr, numBytes, data):
|
||||
if numBytes > 512:
|
||||
raise Exception('bad number of bytes')
|
||||
|
||||
@@ -3205,8 +3204,8 @@ class sHID(object):
|
||||
buf=[0xcc]*0x0f #0x15
|
||||
buf[0] = 0xdd
|
||||
buf[1] = 0x0a
|
||||
buf[2] = (addr >>8) & 0xFF
|
||||
buf[3] = (addr >>0) & 0xFF
|
||||
buf[2] = (addr >>8) & 0xFF
|
||||
buf[3] = (addr >>0) & 0xFF
|
||||
if DEBUG_COMM > 1:
|
||||
self.dump('readCfgFlash>', buf, fmt=DEBUG_DUMP_FORMAT)
|
||||
self.devh.controlMsg(usb.TYPE_CLASS + usb.RECIP_INTERFACE,
|
||||
@@ -3224,7 +3223,7 @@ class sHID(object):
|
||||
index=0x0000000,
|
||||
timeout=self.timeout)
|
||||
new_data=[0]*0x15
|
||||
if ( numBytes < 16 ):
|
||||
if numBytes < 16:
|
||||
for i in xrange(0, numBytes):
|
||||
new_data[i] = buf[i+4]
|
||||
numBytes = 0
|
||||
@@ -3235,7 +3234,7 @@ class sHID(object):
|
||||
addr += 16
|
||||
if DEBUG_COMM > 1:
|
||||
self.dump('readCfgFlash<', buf, fmt=DEBUG_DUMP_FORMAT)
|
||||
data[0] = new_data
|
||||
data[0] = new_data # FIXME: new_data might be unset
|
||||
|
||||
def setState(self,state):
|
||||
buf = [0]*0x15
|
||||
|
||||
Reference in New Issue
Block a user