Page 1 of 1

Webapp not sending key presses

PostPosted: Sat Jan 28, 2017 1:48 pm
by satch80
I've somehow messed up my Webapp install during an upgrade. Everything seems to be working fine except I can't use the Webapp to send keypresses to the alarm panel. The diagnostic communications work fine (both send and receive).

I'm running on a Rpi using a AD2USB device.

After attempting to send keypresses I get the following traceback. Any help would be appreciated.

File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/opt/alarmdecoder-webapp/ad2web/app.py", line 95, in __call__
return self.app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1473, in full_dispatch_request
rv = self.preprocess_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1666, in preprocess_request
rv = func()
File "/opt/alarmdecoder-webapp/ad2web/socketioflaskdebug/debugger.py", line 36, in protected_method
return f(*args, **kwargs)
File "/opt/alarmdecoder-webapp/ad2web/decoder.py", line 635, in on_keypress
self._alarmdecoder.device.send(key)
File "/opt/alarmdecoder/alarmdecoder/decoder.py", line 253, in send
self._device.write(data)
File "/opt/alarmdecoder/alarmdecoder/devices.py", line 803, in write
self._device.write(data)
File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 518, in write
d = to_bytes(data)
File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 63, in to_bytes
raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: u'1'

Re: Webapp not sending key presses

PostPosted: Mon Jan 30, 2017 11:20 am
by Scott
I think this is actually a bug on our end. Sorry about that! I'll try and get a bugfix release out today or tomorrow.

Thanks,
Scott

Re: Webapp not sending key presses

PostPosted: Tue Jan 31, 2017 6:27 pm
by David.B
Same issue here...

Re: Webapp not sending key presses

PostPosted: Tue Jan 31, 2017 6:51 pm
by David.B
Until official update; I changed the serial write to send as string... it fixes the issue.


file: /opt/alarmdecoder/alarmdecoder/devices.py

Line 803:

self._device.write(data) change to self._device.write(str(data))

Code as fixed below...

Code: Select all
def write(self, data):
        """
        Writes data to the device.

        :param data: data to write
        :type data: string

        :raises: py:class:`~alarmdecoder.util.CommError`
        """
        try:
            self._device.write(str(data))

        except serial.SerialTimeoutException:
            pass

        except serial.SerialException as err:
            raise CommError('Error writing to device.', err)

        else:
            self.on_write(data=data)

Re: Webapp not sending key presses

PostPosted: Wed Feb 01, 2017 11:33 am
by Scott
New bugfix release pushed up. Should take care of this issue.

Thanks for the suggestion David. Ended up being a little more complicated since we're trying to support both Python 2 and 3 in the library itself. Just a note, you should revert your changes prior to updating as it will cause the updater to fail.

Thanks,
Scott

Re: Webapp not sending key presses

PostPosted: Wed Feb 01, 2017 4:16 pm
by satch80
Very nice. That's working perfectly now.

Thanks for the fast fix!