added some more error handling
fixed pwm_freq not getting set on init
This commit is contained in:
@@ -51,25 +51,22 @@ class Controller(Base):
|
||||
i2c_device = Column(Integer)
|
||||
address = Column(String)
|
||||
stripes = relationship("Stripe", backref="controller")
|
||||
pwm_freq = Column("pwm_freq", Integer)
|
||||
_pwm_freq = Column("pwm_freq", Integer)
|
||||
|
||||
"""
|
||||
A controller controls a number of stripes.
|
||||
"""
|
||||
|
||||
@reconstructor
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._mode = None
|
||||
self.bus = smbus.SMBus(self.i2c_device)
|
||||
self._address = int(self.address, 16)
|
||||
self._pwm_freq = self.pwm_freq
|
||||
|
||||
@reconstructor
|
||||
def init_on_load(self):
|
||||
self._mode = None
|
||||
self.bus = smbus.SMBus(self.i2c_device)
|
||||
self._address = int(self.address, 16)
|
||||
self._pwm_freq = self.pwm_freq
|
||||
if self._pwm_freq:
|
||||
self.pwm_freq = self._pwm_freq
|
||||
else:
|
||||
self.pwm_freq = 1526
|
||||
|
||||
def __repr__(self):
|
||||
return "<Controller stripes={} cid={}>".format(len(self.stripes), self.id)
|
||||
|
@@ -388,7 +388,10 @@ class LedDProtocol(asyncio.Protocol):
|
||||
except UnicodeDecodeError:
|
||||
log.warning("Recieved undecodable data, ignoring")
|
||||
else:
|
||||
self.select_task(d_decoded)
|
||||
try:
|
||||
self.select_task(d_decoded)
|
||||
except JSONRPCError:
|
||||
log.warning("Recieved non-json data, ignoring")
|
||||
|
||||
def select_task(self, data):
|
||||
if data:
|
||||
|
Reference in New Issue
Block a user