Colibri IMX6 .NET UART Access

Hello,

OS: Torizon 5.0
Module: Colibri iMX6DL 512MB

I am trying to access the UART on the module using .NET Core and its System.IO.Ports Library.

I had added “RUN usermod -a -G dialout torizon” to buildcommands and “/dev/ttymxc0” to devices in the Torizon Container Configuration.

I am getting the following error:

Unhandled exception. System.UnauthorizedAccessException: Access to the port '/dev/ttymxc0' is denied.
 ---> System.IO.IOException: Unknown error 203
   --- End of inner exception stack trace ---
   at System.IO.Ports.SafeSerialDeviceHandle.Open(String portName)
   at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
   at System.IO.Ports.SerialPort.Open()

Code:

using System;
using System.Threading;
using System.IO.Ports;

namespace UART_Test
{
    class Program
    {
        static void Main(string[] args)
        {     
            SerialPort serialPort;

            serialPort = new SerialPort();

            serialPort.PortName = "/dev/ttymxc0";
            serialPort.BaudRate = 115200;
            serialPort.Open();

            while (true) {
                serialPort.WriteLine("Hello, World!");
                Thread.Sleep(1000);
            }
        }
    }
}

Am I missing some step in the configuration?

If I try to directly access the UART using stty and echoing text to the device, it works.

Hope you can help.

Greetings @atharvalele,

I took your code and it worked just fine with no modifications on my i.MX6. This leads me to believe there maybe some small error or misconfiguration on your setup.

Can you double-check and make sure that you added /dev/ttymxc0 to the devices configuration and RUN usermod -a -G dialout torizon to the buildcommands configuration. Other than these two configurations I didn’t do anything else differently.

Best Regards,
Jeremias