Hi,
I am having some trouble with serial communication on Linux. I am trying to send and receive information between an arduino and Unity. I suspect that it might be a Linux permission thing, but it might also be some Unity setting that I have missed.
I already added the Linux user to the dialout group as per instructions on the Arduino website, and I made sure to select .NET 4.x in the Unity project settings.
The serial communication is actually working when I compile and run the following C# using mono, outside of Unity:
using System.IO.Ports;
sp = new SerialPort("/dev/ttyACM0", 9600);
sp.Open();
However, the same code in Unity at run-time tells me:
IOException: No such file or directory
The frustrating thing is that this is actually working on another Linux machine and I am having trouble understanding what the difference could be that is causing it not to work on the other.
Here are some differences on both systems:
The working Linux is Lubuntu 19 with the Unity installation inside of /home, which is on the same partition as root. The Unity version is 2019.2.
The non-working system is Linux Mint 19.3 with the Unity installation also in /home, but this is a different partition from root. The Unity version is 2019.3.
The permissions look slightly different too:
crw-rw----+ 1 root dialout 166, 0 mei 1 05:08 /dev/ttyACM0 --> Lubuntu
crw-rw---- 1 root dialout 166, 0 May 1 15:03 /dev/ttyACM0 --> Mint
Also:
getfacl /dev/ttyACM0
gives me the following on Lubuntu (working):
# file: dev/ttyACM0
# owner: root
# group: dialout
user::rw-
user:myname:rw-
group::rw-
mask::rw-
other::---
and the following on Linux Mint (not working):
# file: dev/ttyACM0
# owner: root
# group: dialout
user::rw-
group::rw-
other::---
Does anyone have any insight into why in one scenario Unity can’t access /dev/ttyACM0, while in the other one it can? Or any idea’s how I might find out?
(Also, I wanted to test this out with the same 2019.2 Unity version, but for some reason my Unity Hub does not want to load any archived installation).