Print2Go

PrintAndGo

3D printer host written in Go language with “Octoprint” functionalities

Convert any router with a USB port in a 3D printer host, with an Octoprint-like API

PrintAndGo is a lightweight and simple web based program written in Go to feed gcode to a 3d printer (aka gcode sender, 3d printer host)

It offers a convenient webinterface and mimics Octoprints upload API, meaning that common slicer software will be able to directly upload gcode to PrintAndGo.

It’s based in the code of Takoprint by Adrian

Features

Brief story of the objective an purpose of this project

This project is related to OctoWrt, and the addition of the Creality WifiBox (WB01) in OpenWRT. OctoPrint is a great sofware and tool, but not very optimized for low resource hardware (lower than a raspberry pi 3, which was the original target hardware as far as I know) such as a router. I had previously contributed in a Octoprint-like (or mimic) firmware for embedded devices as ESP8266 or ESP32 see WirelessPrinting, but there was missing sofware solution for the intermediate hardware between embedded devices and mini-pc. So it needed some leverage, then I found Takoprint, added some functions and connected the other projects (OctoWrt and OpenWRT) together.

Screenshots

webinterface

webinterface

webinterface

webinterface

Install, Run and Usage

No install is required, just run the executables/binaries according to your platform/OS

Run in host machine

In a command line or shell in windows or linux, run:

./PrintAndGo  -tty <host_device_path>

Note: In windows you can double click the .exe, but will use the default configuration

Examples:

./PrintAndGo -tty COM3
./PrintAndGo -tty /dev/ttyUSB0

PrintAndGo is configured via flags. By default, PrintAndGo will listen on 127.0.0.1:5001 and expect a printer on /dev/ttyUSB0 (Linux) or COM3 (Windows):

$ ./PrintAndGo -h
Usage of ./PrintAndGo:
  -baud int
        baud rate of -port (default 115200)
  -gcode string
        file containing gcode
  -listen string
        ip:port to bind to (default "127.0.0.1:5001")
  -shutdown-script string
        script to execute to shutdown the printer (default "/usr/lib/printandgo-shutdown.sh")
  -storage string
        path to store gcode in (default "/tmp/printandgo")
  -tty string
        tty to use (default "/dev/ttyUSB0")

Note that PrintAndGo only listens on 127.0.0.1 by default. You can tell PrintAndGo to listen on all interfaces by running it via:

$ ./printandgo -listen ':5001'

With docker

  1. After build, first time run the container, run detached and interactive terminal You need to configure Map the usb device from host to container –device=: `docker run -p 5001:5001 -d -it --device=/dev/ttyUSB0:/dev/ttyUSB0 --name go-container go-builder-linux-img:1.0`

Note: Mapping usb devices from windows as host to linux involves configuring WSL2, not the aim of this guide For dev or other purposes can be run without mapping usb device docker run -p 5001:5001 -d -it --name go-container go-builder-linux-img:1.0

  1. Run PrintAndGo docker exec -it go-container /app/PrintAndGo -tty /dev/ttyUSB0 -listen 0.0.0.0:5001

Note: PrintAndGo uses default ip 127.0.0.1 which is local only (cannot access from outside container), on the other hand docker uses 0.0.0.0 for exposing ports and services outside container, so we specify -listen 0.0.0.0, the port 5001 is the default of octoprint and can be changed (but need to change the docker file if you want another port)

Other commands:

Start a previously run container, with interactive shell (useful for build/running commands in the container) docker start -a -i go-container

interactive shell access docker exec -it go-container bash

Excecute command in container docker exec -it go-container /app/myapp -tty /dev/ttyUSB0

Run in OpWRT ./PrintAndGo -tty <USBdevice> -listen <localip:port> Example ./PrintAndGo -tty /dev/ttyUSB0 -listen 192.168.8.155:5001

Development Build (Win/Linux)

See Readme-dev.md

Post print Script

PrintAndGo can be configured to run a command after the print finished. Eg. Automatic shutdown By default, /usr/lib/takoprint-shutdown.sh will be executed (can be configured using the -shudtown-script flag).

The script could then execute a command to turn off a ‘smart’ power plug. I’m using a Sonoff device running TASMOTA in my setup with the following shutdown script:

$ cat /usr/lib/takoprint-shutdown.sh
#!/bin/bash

# retry 3x as my wifi connection can be crappy:
for x in 1 2 3 ; do
        until wget -O - -q "http://192.168.2.230/cm?cmnd=Power%20OFF"
        do
                echo "retry poweroff..."
                sleep 3
        done
        sleep 1
done

Octoprint API Coverage

PrintAndGo implements the minimum required for printing of the Octoprint API Some are just the endpoint with hardcoded response and no logic or validation. The endpoints are coded in webapi.go and implemented in octoapi.go

Autostart

Acording to instructions, there is an example file included in the repo to make the script autostart at boot as a service. See: PrintAndGo-srv, modify it acordingly to your configuration and ip.

Planned features/idea

Licence

GPLv3. See licence file

Acknowledgement

Adrian Ulrich - Takoprint https://git.sr.ht/~adrian-blx/takoprint