0

I'm running a .NET Core application on Raspberry Pi OS (32-bit Debian).

pi@raspberrypi:~ $ cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

The console app uses a standard2.0 classlib DLL to access a device via UART0. UART0 should be accessible via /dev/ttyAMA0. I'm using System.IO.Ports.SerialPort. The serial console is disabled, the serial port is enabled (raspi-config). However if I try to initialize the driver with pseudo-code like this one

_serialPort = new SerialPort();
_serialPort.PortName = "/dev/ttyAMA0";
_serialPort.PortName = SetPortName(_serialPort.PortName);
// set properties
_serialPort.Open();

I'm getting

Unhandled exception. System.InvalidOperationException: The port is closed.

2
  • 2
    What Pi? What /etc/os-release? Why not /dev/serial0?
    – joan
    Oct 21 at 15:54
  • I've added the releaase info. Ah, thanks. I've found /dev/ttyAMA0 in some example code in the wild. However /dev/serial0 makes a lot more sense.
    – thinwybk
    Oct 22 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.