Arduino linuxで書き込みエラー error opening serial port

スポンサーリンク

はじめに

linuxArduino ideからコードを書き込みしようとしたら、
エラーが出て出来なかった。
その対処法を記しておく。

環境

Linux mint
Arduino 1.8.5

エラー

エラーは下のスクリーンショット
シリアルポートが開けないみたいだ。

f:id:shangtian:20191104111147p:plain

エラーコードは次のよう

Arduino: 1.8.5 (Linux), Board: "Arduino/Genuino Uno"

Error opening serial port '/dev/ttyACM0'. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission
Error opening serial port '/dev/ttyS0'. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission
Error opening serial port '/dev/ttyS0'. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission
Error opening serial port '/dev/ttyACM0'. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

対処法

シリアルポートのパーミッションで拒否されているみたいなので
ここを変更していく。

$ ls -l /dev/ttyACM*
crw-rw---- 1 root dialout 166, 0 11月  4 10:58 /dev/ttyACM0

所有者とグループユーザーには読み込み権限と
書き込み権限が付与されているのが、シリアル通信できていない
と言うことは、その他に書き込み権限と読み込み権限を
与えないといけないみたいだ。

$ sudo chmod o+r /dev/ttyACM0 
$ sudo chmod o+w /dev/ttyACM0

これで通信できるようになった。

ただし、一度USBを抜いてしまうと同じ作業をしないと通信できない。

<参考文献>

Arduino Playground - All

Linuxの権限確認と変更(chmod)(超初心者向け) - Qiita