Replies: 1 comment 2 replies
-
I don't see straight connection between state of the watched service and state of USB ports. If service is down, it doesn't necessarily mean that anything was wrong with USB. And if service is not running, this script doesn't do anything about it (e.g. try to start it again), but simply resets USB ports. Long story short, I wouldn't necessarily trust anything that chatgpt recommends. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
ChatGPT have me this:
To create a USB watchdog script for a Raspberry Pi using
uhubctl
, follow these steps:Step 1: Install uhubctl
First, you need to install
uhubctl
, which allows you to control the power of USB ports.Update your Raspberry Pi:
Install
uhubctl
:Step 2: Identify Your USB Hub and Port
Use
uhubctl
to list your USB hubs and ports:This will give you information about available USB hubs and ports, which you’ll need to control specific ports.
Step 3: Create the Watchdog Script
You can create a script that monitors a particular service or process and toggles the power on a USB port if the service/process is unresponsive.
Here’s an example script:
Step 4: Make the Script Executable
Give execution permission to the script:
Step 5: Run the Script
You can run the script manually or set it up to run on startup.
To run the script manually:
Step 6: (Optional) Run the Script on Startup
To run the script on startup, you can add it to
/etc/rc.local
or create a systemd service.For
/etc/rc.local
, add the following line beforeexit 0
:/path/to/your-script.sh &
Or, you can create a systemd service file:
Create a new service file:
Add the following content:
Enable and start the service:
sudo systemctl enable usb-watchdog.service sudo systemctl start usb-watchdog.service
This script will monitor your specified service and reset the USB port if the service is down, effectively acting as a watchdog for connected devices.
Anyone thinks this is feasible on a RPI4?
Beta Was this translation helpful? Give feedback.
All reactions