Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

1,291 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrusaLink

PrusaLink is a compatibility layer between 8-bit Prusa 3D printers (MK2.5, MK2.5S, MK3, MK3S and MK3S+) and PrusaConnect, which lets you control and monitor your 3D printer from anywhere. Get more info at connect.prusa3d.com

PrusaLink also provides a local web interface: Prusa-Link-Web

About this fork

This fork follows upstream master with these changes:

  • The Raspberry Pi image starts PrusaLink with a systemd service (prusalink.service), not from rc.local. On the stock image, PrusaLink would sometimes not start on boot. systemd also restarts PrusaLink if it crashes, and after a self-update.
  • The image reconnects Wi-Fi after NetworkManager gives up on it (nm-nosecrets-recover.service). When a reconnect hits a failed handshake, NetworkManager assumes the key is wrong, asks for a new one and, with nobody to type it on a headless Pi, blocks autoconnect until someone intervenes. The service waits for exactly that failure (device state FAILED, reason NO_SECRETS) and reconnects with the saved key.
  • The image builder installs PrusaLink from this fork, not from PyPI.
  • The Prusa Connect SDK is capped below 0.9, which this PrusaLink does not support yet.

To switch a Pi that is already set up (stock image or older fork) to this fork, run this as the first user (pi/jo):

pip install --user --break-system-packages --upgrade \
    git+https://github.com/neoyarus/Prusa-Link.git
# Remove the PrusaLink start (prusalink-boot, rm prusalink.pid and the
# "su ... prusalink -i start" line) from /etc/rc.local, then:
DATA=$(python3 -c "from importlib.resources import files; print(files('prusa.link') / 'data' / 'image_builder')")
sudo install -m 755 "$DATA/prusalink-systemd-runner.sh" /usr/local/sbin/prusalink-systemd-runner
sudo install -m 644 "$DATA/prusalink.service" /etc/systemd/system/prusalink.service
sudo install -m 755 "$DATA/nm-nosecrets-recover.sh" /usr/local/sbin/nm-nosecrets-recover
sudo install -m 644 "$DATA/nm-nosecrets-recover.service" /etc/systemd/system/nm-nosecrets-recover.service
sudo systemctl daemon-reload
sudo systemctl enable --now prusalink nm-nosecrets-recover

Known issue: Pi Zero 2 W Wi-Fi drops every 60 seconds

With some Wi-Fi country codes (BY, RU and about 50 others), a Pi Zero 2 W disconnects itself exactly 60 seconds after every association and reconnects (CTRL-EVENT-DISCONNECTED ... reason=3 locally_generated=1, iwconfig shows only legacy rates like 18 or 54 Mb/s). The AP's Country IE re-arms a 60 s regulatory re-check in cfg80211, which rejects the channel because brcmfmac reports HT 20 MHz for a firmware without HT. See raspberrypi/firmware#2019, fixed in raspberrypi/linux#7789 (rpi-6.18.y only so far).

Until the fixed kernel reaches your Pi, boot with the world regulatory domain. The AP's Country IE still applies the local rules once connected:

sudo cp /boot/firmware/cmdline.txt /boot/firmware/cmdline.txt.bak
sudo sed -i 's/cfg80211\.ieee80211_regdom=[A-Z0-9]*/cfg80211.ieee80211_regdom=00/' /boot/firmware/cmdline.txt
sudo reboot

Check on it with systemctl status prusalink and journalctl -u prusalink. Don't use prusalink status, which can start a second instance.

Setup

To use PrusaLink please follow our Setup Guide

Login

If you wish to log into the console environment and haven't changed the credentials, you'll need these default ones:

username: jo
password: raspberry

Dev Setup

If using the Raspberry Pi pins, follow the guide above for the hardware preparation. Pins can be used even on regular (non-Zero) Pis through Dupont jumper cables. Just make sure those make proper contact with the Einsy board. A connection over USB is also possible, making PrusaLink compatible with pretty much any Linux system, but since the RPi has been used as a reference, please excuse the Debian specific instructions.

If using the Pi, create your micro SD card the usual way, a Lite image will do nicely. Just in case, here's a guide: https://www.youtube.com/watch?v=ntaXWS8Lk34

UART over GPIO pins

On some RPis, the main UART is handling Bluetooth, so the printer communication would get handled by a miniUART, which doesn't work for us. To disable Bluetooth, add these lines into config.txt which is located in the Pi's boot partition.

[all]
enable_uart=1
dtoverlay=disable-bt

Installation

PrusaLink needs libpcap headers installed to name its OS threads. Git and Pip are needed for installation, while pigpio is only needed if the RPi GPIO pins are to be used.

sudo apt install git python3-pip pigpio libcap-dev libmagic1 libturbojpeg0 libatlas-base-dev python3-numpy libffi-dev libopenblas0

# If you are using different distro (e.g. Ubuntu), use libturbojpeg library
# instead of libturbojpeg0

# for the Raspberry Pi camera module support
# pre-installed on the newer Raspberry Pi OS images post September 2022
sudo apt install -y python3-libcamera --no-install-recommends

pip install PrusaLink

# Or install straight from GitHub
pip install git+https://github.com/prusa3d/gcode-metadata.git
pip install git+https://github.com/prusa3d/Prusa-Connect-SDK-Printer.git
pip install git+https://github.com/prusa3d/Prusa-Link.git

Config

PrusaLink behavior can be altered using command arguments and configuration files. The default configuration path is /etc/prusalink/prusalink.ini and does not get created automatically. The configuration documentation can be found under prusa/link/data/prusalink.ini. The executable argument documentation is provided in the standard help text screen shown after running prusalink --help

The prusa_printer_settings.ini file is created by the PrusaLink wizard, and can be downloaded from the PrusaConnect settings page once you register your printer.

Configuring PrusaLink on the SD card

If you need to manually configure PrusaLink on the SD created from our image, it now comes with an auto-copy script. Put your prusalink.ini or prusa_printer_settings.ini files into the boot portion of the SD, That's the only one that shows up under Windows or Mac, and they will get copied over to their default locations on the next boot.

Permission denied

Make sure the user you're running PrusaLink under is a member of the group dialout. To add it, run

sudo usermod -a -G dialout <username>

then log out and in with that user.

Access on port 80

PrusaLink has a local web interface, to make it accessible on the default port 80, either start it as root and configure the user to which it should de-elevate itself after the web server is up, or start it as a normal user on port 8080 - or any other, then redirect the port 80 to the port PrusaLink is listening on using these commands.

Running behind a reverse-proxy

If you got a proxy that changes the URI path, add the X-Forwarded-Prefix header. PrusaLink will use it to construct the correct URLs for the web interface.

# use -i to specify the interface affected
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

PrusaLink advertises itself on the local network. This makes it visible in PrusaSlicer under Physical Printers -> Browse. To advertise port 80, the instance has to be able to ping itself. This can be done by setting up a similar redirect on the loopback interface

iptables -t nat -I OUTPUT -p tcp -o <loopback device name> -d localhost --dport 80 -j REDIRECT --to-ports 8080

Multi-instance

If you want to connect multiple printers to a single pi, have a look at MULTIINSTANCE.md

Usage

By default, the executable starts the daemon process and exits. The executable is called prusalink and can be used to control the daemon, if you want to run it in your terminal instead, use the -f option To get the most recent help screen use prusalink --help, here's what it says in 0.7.0

usage: prusalink [-h] [-f] [-c <file>] [-p <FILE>] [-a <ADDRESS>] [-t <PORT>]
                 [-I] [-s <PORT>] [-i] [-d] [-l MODULE_LOG_LEVEL] [--profile]
                 [command]

PrusaLink daemon.

positional arguments:
  command               daemon action (start|stop|restart|status) (default:
                        start)

options:
  -h, --help            show this help message and exit
  -f, --foreground      run as script on foreground
  -c <file>, --config <file>
                        path to config file (default:
                        /etc/prusalink/prusalink.ini)
  -p <FILE>, --pidfile <FILE>
                        path to pid file
  -a <ADDRESS>, --address <ADDRESS>
                        IP listening address (host or IP)
  -t <PORT>, --tcp-port <PORT>
                        TCP/IP listening port
  -I, --link-info       /link-info debug page
  -s <PORT>, --serial-port <PORT>
                        Serial (printer's) port or 'auto'
  -i, --info            more verbose logging level INFO is set
  -d, --debug           DEBUG logging level is set
  -l MODULE_LOG_LEVEL, --module-log-level MODULE_LOG_LEVEL
                        sets the log level of any submodule(s). use
                        <module_path>=<log_level>
  --profile             Use cProfile for profiling application.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages