0
1

More than 1 year has passed since last update.

RaspberryPiでspidevをつかったプログラムをrc.localで自動起動できない

Posted at

RaspberryPiで、spidevを使ったpython3のプログラムをrc.localで自動起動できない

状況

spidevを用いたpythonプログラムが、rc.localに書いても自動起動してくれない。
起動ログを確認すると以下のようになっていた。(一部抜粋)

self.spi.open(0, 0)
FileNotFoundError: [Errno 2] No such file or directory

おそらく、spiに関するサービスが起動する以前にプログラムがロードされエラーになっているのだろう。

解決策

rc.localではなくてsystemdを使おう。
以下の記事がとても参考になった。ありがとうございます。

[Install]
WantedBy=multi-user.target

とすることで、GUI環境が起動した後にプログラムをロードできるそう。
あとはsystemctlでサービスを有効にすれば正常起動できた。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1