mirror of https://github.com/Desuuuu/klipper.git
palette2: Fix UART encoding
Raised from issue #5645, UTF-8 encoded symbols or other unexpected symbols on the UART raise an exception which causes klipper to stop. This change support UTF-8 encoded characters (from file names) as well as ignoring unexpected bytes. Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
This commit is contained in:
parent
b1dcd35b7a
commit
ce27d35924
|
@ -544,7 +544,9 @@ class Palette2:
|
|||
self.cmd_Disconnect()
|
||||
return self.reactor.NEVER
|
||||
if len(raw_bytes):
|
||||
text_buffer = self.read_buffer + str(raw_bytes.decode())
|
||||
new_buffer = str(raw_bytes.decode(encoding='UTF-8',
|
||||
errors='ignore'))
|
||||
text_buffer = self.read_buffer + new_buffer
|
||||
while True:
|
||||
i = text_buffer.find("\n")
|
||||
if i >= 0:
|
||||
|
@ -646,5 +648,6 @@ class Palette2:
|
|||
status["ping"] = self.omega_pings[-1]
|
||||
return status
|
||||
|
||||
|
||||
def load_config(config):
|
||||
return Palette2(config)
|
||||
|
|
Loading…
Reference in New Issue