运行pigpiod守护进程 - 使用python或Ubuntu b

2024-04-24 19:18:52 发布

您现在位置:Python中文网/ 问答频道 /正文

为了在Python中使用pigpio模块(针对Raspberry Pi的远程GPIO),必须将pigpiod加载到每个RPi上的内存中。在

  1. 正确的方法是什么?在Ubuntu的引导或者Python脚本的一部分?在
  2. 既然它需要sudo pigpiod-它是如何完成的(包括Ubuntu和Python)?在

Tags: 模块方法内存脚本gpio远程ubuntupi
3条回答

我没有使用pigpiod,但我假设它是一个守护进程(一个长时间运行的Linux进程),您希望在启动时启动它。在大多数现代Linux系统(包括Raspberri-Pi)中,标准的方法是使用systemd。请尝试以下命令:

systemctcl start pigpiod # start it now
systemctl enable pigpiod # start it each boot
systemctl status pigpiod # make sure it started
# https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs
journalctl -u pigpiod # Use this to see logs.

如果systemctl抱怨找不到服务,则必须为其创建服务文件。这是一个放置在目录中的文本文件,它告诉systemd如何取消进程的监控。Here是一篇有人这样做的博客文章,如果没有帮助的话,Google应该会找到其他人。在

然后您应该能够与Python连接。在

另一种方法是在cron中使用重新启动选项

运行:

crontab -e

然后添加条目:

^{pr2}$

这将在系统每次引导时运行该进程。在

相关问题 更多 >