From 30aca823917208e6f1a212ee51a6fca0683a9a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Socho=C5=84?= Date: Sat, 6 Jul 2024 16:29:42 +0200 Subject: [PATCH] Tweak systemd service to enable auto-restart --- README.md | 45 ++++++++++++----------------------- docs/troubleshooting.md | 5 ++++ prusa-connect-camera@.service | 7 ++++-- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index a2863d5..6a69f26 100644 --- a/README.md +++ b/README.md @@ -4,40 +4,23 @@ Linux shell script to send still camera images to Prusa Connect -See [docs here](https://nvtkaszpir.github.io/prusa-connect-camera-script) +## Documentation -## Quick start +See [docs here](https://nvtkaszpir.github.io/prusa-connect-camera-script) for: -RaspberryPi with CSI camera with libcamera: +* feature list +* requirements +* general step-by-step install +* example configs +* advanced tweaks -```shell -# go to Prusa Connect site, add camera, copy token, turn on your 3D printer - -cp csi.dist .env -# edit .env file, set token and fingerprint +## Development -set -o allexport; source .env; set +o allexport +Those are generally notes to myself :) -./prusa-connect-camera.sh - -``` +### Docs -Any linux host with ffmpeg and RTSP camera: - -```shell -# go to Prusa Connect site, add camera, copy token, turn on your 3D printer - -cp ffmpeg-mediamtx-rtsp-tcp.dist .env -# edit .env file, set token and fingerprint -# change 'rtsp://raspberry-pi:8554/cam' to rtsp://:@/ - -set -o allexport; source .env; set +o allexport - -./prusa-connect-camera.sh - -``` - -## Docs +Preview documentation locally ```shell pip install -r requirements.txt @@ -47,7 +30,9 @@ mkdocs serve Auto-published by github action when pushed to master. -## Code commits +### Code commits + +ensure to have [pre-commit](https://pre-commit.com/) installed. ```shell npm install -g markdown-link-check @@ -58,7 +43,7 @@ git add . pre-commit run --all ``` -## Docker container build +### Docker container build ```shell make quay diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 92f4e2c..89fce0d 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -4,6 +4,11 @@ Things to check if it does not work. ## General +- some USB cameras require physical unplung/plug-in AFTER + the Rasberry Pi was turned on, there is no fix for this yet, see + [raspberrypi/linux/issues/6255](https://github.com/raspberrypi/linux/issues/6255) + for such example + - check `/dev/shm/camera_*.stdout` and `/dev/shm/camera_*.stderr` files for more details - if they still that 'everything is okay' then probably you have issues with permissions when running script diff --git a/prusa-connect-camera@.service b/prusa-connect-camera@.service index 3a68d5c..05c2423 100644 --- a/prusa-connect-camera@.service +++ b/prusa-connect-camera@.service @@ -1,13 +1,16 @@ [Unit] Description=Prusa Connect Camera Script -After=network.target +After=network.target systemd-udev-trigger.service +Wants=network.target +Requires=systemd-udev-trigger.service [Service] User=pi Group=pi EnvironmentFile=/home/pi/src/prusa-connect-camera-script/.%i ExecStart=/home/pi/src/prusa-connect-camera-script/prusa-connect-camera.sh -Restart=on-failure +Restart=always +RestartSec=15 [Install] WantedBy=multi-user.target