AmedeeBulle / pyrak811

RAK811 Python 3 library for Raspberry Pi
Apache License 2.0
49 stars 24 forks source link

Read thread can receive non-ASCII characters when the serial line is not configured properly #1

Closed AmedeeBulle closed 5 years ago

AmedeeBulle commented 5 years ago

Traceback:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/rak811/serial.py", line 111, in _read_loop
    line = line.decode('ascii').rstrip(EOL)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 311: ordinal not in range(128)

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    lora.mode = Mode.LoRaWan
  File "/usr/local/lib/python3.5/dist-packages/rak811/rak811.py", line 281, in mode
    self._send_command('mode={0}'.format(value))
  File "/usr/local/lib/python3.5/dist-packages/rak811/rak811.py", line 221, in _send_command
    response = self._serial.get_response()
  File "/usr/local/lib/python3.5/dist-packages/rak811/serial.py", line 133, in get_response
    'Timeout while waiting for response'
rak811.serial.Rak811TimeoutError: Timeout while waiting for response