TypeError: 'must be string without null bytes, not str'

What is the problem?

We've just upgraded with a fresh install to the latest version of OctoPi, but now get a connection problem when trying to print. OctoPrint is able to connect and monitor temperatures on the printer however.

This is a Monoprice Dual Extruder printer (clone of Replicator 2X) that has previously worked with the GPX plugin on a much older version of OctoPrint.

What did you already try to solve it?

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)

OctoPrint 1.3.6 running on OctoPi 0.14.0

Changing monitoring state from 'Offline' to 'Error: Connection error, see Terminal tab'
Unexpected error while connecting to serial port: AUTO IOError: 'AUTO port and baudrate not currently supported by GPX' @ comm.py:_openSerial:1931 (hook GPX)
Changing monitoring state from 'Offline' to 'Error: Connection error, see Terminal tab'
Unexpected error while connecting to serial port: AUTO IOError: 'AUTO port and baudrate not currently supported by GPX' @ comm.py:_openSerial:1931 (hook GPX)
Changing monitoring state from 'Offline' to 'Opening serial port'
Connected to: <GPX.gpxprinter.GpxPrinter instance at 0x6f4e56e8>, starting monitor
Changing monitoring state from 'Opening serial port' to 'Connecting'
Recv: start
Send: N0 M110 N0*125
Recv:  Makerbot v7.2
Recv: echo: gcode to x3g translation by GPX
Recv: SD init fail
Recv:  T:26 /0 B:0 /0 @:0 B@:0
Send: N0 M110 N0*125
Recv:  T:26 /0 B:0 /0 @:0 B@:0
Recv: ok
Changing monitoring state from 'Connecting' to 'Operational'
Send: N0 M110 N0*125
Recv: ok
Send: N1 M115*39
Recv: ok PROTOCOL_VERSION:0.1 FIRMWARE_NAME:Makerbot FIRMWARE_VERSION:7.2 FIRMWARE_URL:https://support.makerbot.com/learn/earlier-products/replicator-original/updating-firmware-for-the-makerbot-replicator-via-replicatorg_13302 MACHINE_TYPE:r2 EXTRUDER_COUNT:1
Send: N2 M21*18
Recv: ok
Recv: SD init fail
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:25 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:25 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:25 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:25 /0 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:26 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:29 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:32 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:35 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:39 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:42 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:46 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:51 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:55 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:59 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:62 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:66 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:71 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:76 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:79 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:84 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:87 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:91 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:95 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:99 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:102 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:106 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:109 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:112 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:116 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:120 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:123 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:127 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:129 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:132 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:135 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:139 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:142 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:144 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:147 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:150 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:153 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:156 /230 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:159 /230 B:0 /0 @:0 B@:0
Send: M105
Unexpected error while writing to serial port: IOError: '[Errno 5] Input/output error' @ comm.py:_do_send_without_checksum:2499
Changing monitoring state from 'Operational' to 'Offline: IOError: '[Errno 5] Input/output error' @ comm.py:_do_send_without_checksum:2499'
Connection closed, closing down monitor
Changing monitoring state from 'Offline' to 'Error: Connection error, see Terminal tab'
Unexpected error while connecting to serial port: AUTO IOError: 'AUTO port and baudrate not currently supported by GPX' @ comm.py:_openSerial:1931 (hook GPX)
Changing monitoring state from 'Offline' to 'Error: Connection error, see Terminal tab'
Unexpected error while connecting to serial port: AUTO IOError: 'AUTO port and baudrate not currently supported by GPX' @ comm.py:_openSerial:1931 (hook GPX)
Changing monitoring state from 'Offline' to 'Opening serial port'
Connected to: <GPX.gpxprinter.GpxPrinter instance at 0x6f46e1e8>, starting monitor
Changing monitoring state from 'Opening serial port' to 'Connecting'
Send: N0 M110 N0*125
Recv: start
Send: N0 M110 N0*125
Recv:  Makerbot v7.2
Recv: echo: gcode to x3g translation by GPX
Recv: SD init fail
Recv:  T:212 /212 B:0 /0 @:0 B@:0
Recv:  T:212 /212 B:0 /0 @:0 B@:0
Recv: ok
Changing monitoring state from 'Connecting' to 'Operational'
Send: N0 M110 N0*125
Recv: ok
Send: N1 M115*39
Recv: ok PROTOCOL_VERSION:0.1 FIRMWARE_NAME:Makerbot FIRMWARE_VERSION:7.2 FIRMWARE_URL:https://support.makerbot.com/learn/earlier-products/replicator-original/updating-firmware-for-the-makerbot-replicator-via-replicatorg_13302 MACHINE_TYPE:r2 EXTRUDER_COUNT:1
Send: N2 M21*18
Recv: ok
Recv: SD init fail
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:211 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Changing monitoring state from 'Operational' to 'Printing'
Send: N0 M110 N0*125
Recv: ok
Send: (@build "pushbtn-inst-225")
Recv: ok
Send: N1 M136 (pushbtn-inst-225)*84
Recv: ok
Send: ?1-pushbtn-inst-225??R???0????p?@??????4??@???????`?x
Unexpected error while writing to serial port: TypeError: 'must be string without null bytes, not str' @ comm.py:_do_send_without_checksum:2499
Changing monitoring state from 'Printing' to 'Offline: TypeError: 'must be string without null bytes, not str' @ comm.py:_do_send_without_checksum:2499'
Connection closed, closing down monitor
Changing monitoring state from 'Offline' to 'Opening serial port'
Connected to: <GPX.gpxprinter.GpxPrinter instance at 0x6f4dd788>, starting monitor
Changing monitoring state from 'Opening serial port' to 'Connecting'
Recv: start
Send: N0 M110 N0*125
Recv:  Makerbot v7.2
Send: N0 M110 N0*125
Recv: echo: gcode to x3g translation by GPX
Recv: SD init fail
Recv:  T:212 /212 B:0 /0 @:0 B@:0
Recv:  T:212 /212 B:0 /0 @:0 B@:0
Recv: ok
Changing monitoring state from 'Connecting' to 'Operational'
Send: N1 M105*38
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: N0 M110 N0*125
Recv: ok
Send: N1 M115*39
Recv: ok PROTOCOL_VERSION:0.1 FIRMWARE_NAME:Makerbot FIRMWARE_VERSION:7.2 FIRMWARE_URL:https://support.makerbot.com/learn/earlier-products/replicator-original/updating-firmware-for-the-makerbot-replicator-via-replicatorg_13302 MACHINE_TYPE:r2 EXTRUDER_COUNT:1
Send: M21
Recv: ok
Recv: SD init fail
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:211 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:213 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:213 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105
Recv: ok T:212 /212 B:0 /0 @:0 B@:0
Send: M105

Looks like your gcode file has a strange (perhaps Unicode) string on the line after the M136. What Slicer did you use? And can you attach the gcode file?

I used MakerBot Print 2.8.1 (current version) to slice an STL that I designed in Fusion 360. Here's the download link:

Ah. That's the problem. GPX is a gcode to x3g translator. It only understands gcode in, x3g out. You can only print gcode from OctoPrint as GPX translates it on the fly.

You can print x3g from the printer's SD card and only x3g.

You can print gcode from the Pi and only gcode.

Make sense?

Okay, got it. Maybe GPX could be improved to provide a more meaningful error message if the input file format is unsupported.

I believe older versions of MakerBot Print used to be able to output gcode files (which I had previously printed successfully in Octoprint) and this time I was also confused by it only being able to output x3g now. I've managed to print this file by saving it directly to the SD card for now. Thanks.

Yes. I was thinking an error message on upload would be handy, but haven't got around to it yet.