Support for UART serial communication
I'm not 100% sure this is not already somewhere in the codebase, but I couldn't find it. I need to start up a serial connection, write to it and read from it. I'd love to use common code syntax like:
Serial.Begin(speed [,rxPin, txPin]) Serial.Write Serial.Read Serial.OnData Serial.Close
Or something similar.
Thoughts?
Hi,
you can use the built in UART the same way as with every external serial port to usb adapter in C#. You have to disable the console output over UART at first. Unfortunately with RPi 3 you have to disable your bluetooth adapter by adding dtoverlay=pi3-disable-bt at the end of your /boot/config.txt file. I am not 100% sure what has to be changed on RPi 2 as i have not used one in a long time. I think you have to remove console=ttyAMA0,11520 in /boot/cmdline.txt to disable the console forwarding.
After these changes you can use the /dev/ttyAMA0 interface for your serial connection over UART.
SerialPort _uart = new SerialPort("/dev/ttyAMA0", 115200, Parity.None, 8, StopBits.One); _uart.WriteLine(...);
etc. did the trick for me.
Nevertheless this works for me i am not responsible for any damages or data loss on your hardware and software.
Best regards!