I have been trying to get a serial port working with little success.
The code below is the code I am using.
The board has UARTS 1…8 with corresponding port names of /dev/ttySTM0…7.
To start testing I put a jumper wire between PE8<->PF6.
I left all of the SerialPort parameters, except for the port name, at the defaults. I used port name “/dev/ttySTM6”.
I verified port names to pin mapping by looking at the domino Pinout map and the Endpoint library code for SerialPort.
If I check the serial port bytes to write immediately after writing, I can see bytes in the output buffer. Actually, a larger buffer needs to be written to catch queued bytes to write before they are gone.
So, I seem to be writing but I never get any input.
I checked the jumper for continuity.
Anyone got a serial port working?
Suggestions?
using System.IO.Ports;
namespace SerialGPS_Test
{
internal class Program
{
static SerialPort uart = new SerialPort();
static void Main(string[] args)
{
uart.PortName = "/dev/ttySTM6";
uart.Open();
byte[] testBuffer = [ 1, 2, 3, 4, 5 ];
uart.Write(testBuffer, 0, testBuffer.Length);
Thread.Sleep(1000);
Console.WriteLine($"bytes to read {uart.BytesToRead}");
byte c = (byte)uart.ReadByte();
Console.WriteLine("*** DATA ****");
Thread.Sleep(Timeout.Infinite);
}
}
}