Skip to content
This repository

UnicodeDecodeError on connect #170

Closed
else opened this Issue July 15, 2012 · 4 comments

2 participants

Simon Elsbrock daid
Simon Elsbrock
else commented July 15, 2012

I get the following error when trying to connect:

else@butters ~/opt/linux-Cura-12.07 % ./cura.sh                                  
Serial<id=0x7f1f19495b10, open=True>(port=u'/dev/ttyACM1', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False)
Loaded: /home/else/Downloads/MicroTardis-mk06-top_export.gcode (1003)            
Traceback (most recent call last):                                               
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14665, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )                      
  File "/home/else/opt/linux-Cura-12.07/Cura/gui/printWindow.py", line 356, in AddTermLog
    self.termLog.AppendText(line)                                                
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_controls.py", line 1850, in AppendText
    return _controls_.TextCtrl_AppendText(*args, **kwargs)                       
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode               
    return codecs.utf_8_decode(input, errors, True)

(it keeps going on like this)

I do not get a connection at all though. I printed the contents of line and got garbage/binary output. Here are my system details:

else@butters ~ % python --version                                                
Python 2.7.3rc2                                                                  
else@butters ~ % locale                                                          
LANG=en_US.UTF-8                                                                 
LANGUAGE=en_US:en                                                                
LC_CTYPE="en_US.UTF-8"                                                           
LC_NUMERIC="en_US.UTF-8"                                                         
LC_TIME=en_DK.utf-8                                                              
LC_COLLATE="en_US.UTF-8"                                                         
LC_MONETARY="en_US.UTF-8"                                                        
LC_MESSAGES="en_US.UTF-8"                                                        
LC_PAPER="en_US.UTF-8"                                                           
LC_NAME="en_US.UTF-8"                                                            
LC_ADDRESS="en_US.UTF-8"                                                         
LC_TELEPHONE="en_US.UTF-8"                                                       
LC_MEASUREMENT="en_US.UTF-8"                                                     
LC_IDENTIFICATION="en_US.UTF-8"                                                  
LC_ALL=                                                                          
else@butters ~ % uname -a                                                        
Linux butters 3.2.0-1-amd64 #1 SMP Fri Feb 17 05:17:36 UTC 2012 x86_64 GNU/Linux

Any idea? I'd be happy to write a fix, but I don't actually know what's happening here.

Thanks in advance! (The software is working fine on Windows :-))

daid
Owner
daid commented July 16, 2012

It looks like Cura is receiving some "malformed" data from the printer, and when it tries to add that to the term window of the printer interface wxWidgets tries to UTF-8 decode it. This decoding fails, which causes the error.

Did you install the firmware from Linux or from Windows? (Cura selects a different firmware if you install from Linux, because the 250000 baudrate that is used for Windows does not work in every Linux version)

Simon Elsbrock
else commented July 16, 2012

daid, thanks for your response. The firmware was indeed installed from a Windows machine and I have manually selected a baudrate of 115200 on my Linux box. Sounds like this is the reason the serial connection returns garbage. Why is it that 250000 is no option on some Linux distributions?

daid
Owner
daid commented July 16, 2012

250000 can work on Linux, depending on your Kernel version. In the Linux kernel they changed the "custom baudrate" programming interface. And PySerial is still using the old interface. Some kernels accept both the old and the new interface, and some only accept the new interface. So it is a bit of a guess when it will work or not. As it is not working with Ubuntu, I choose to have Linux users default on 115200.

Some people are experimenting with 230400 on Linux, which also seems to work. But they only started a few days before I released 12.07, so I did not want to change my 115200 default for Linux.

daid
Owner
daid commented July 19, 2012

Note. I've added an fix for the backtrace error you posted in the first message. So baudrate errors will be handled a bit more gracefully now.

daid daid closed this August 02, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.