SolidElectronics / evl-emu

EnvisaLink EVL-4 emulator for DSC IT-100
10 stars 10 forks source link

An error occurs: UnicodeDecodeError: 'ascii' codec can't decode byte #6

Closed pelemarse closed 2 years ago

pelemarse commented 2 years ago

an error occurs in the emulator periodically at different times and data transfer stops.

journalctl -xeu "evl-emu.service" log below.

Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/evl-emu/evl-emu.py", line 254, in serialRead
    msgbuf += read_byte.decode('ASCII')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
SolidElectronics commented 2 years ago

Thanks for reporting this, I've noticed this on my installation as well, but it's only started recently. I've turned on debug logging and I'll try to find out what messages are triggering the error.

pelemarse commented 2 years ago

In my case this error occurs when the RS232 to TTL Serial Port Converter starts crashing and probably sending the wrong bytes.

SolidElectronics commented 2 years ago

I think you're probably right. I tried for a while, but I can't find a way to have Python catch and handle an exception in this situation. Unfortunately it seems like the only real solution is to use a better serial adapter, or a physical port. At least in my experience, the USB-serial adapters I have tend to work okay if plugged directly into the PC, but going through a hub causes it to crash every few hours. I'm going to close this issue since we're pretty sure it's a hardware problem.