Help me get USB Serial Comms working on Xamarin Android (Forms) or MAUI
Budget: £20 – £250 GBP
I have an in house project I'm pulling my hair out over. All I need is a fairly simple c# script that works on Xamarin forms. I've written all of the software but i'm not able to get the serial comms working. Basically I have a ESP32 set up to read RFID cards and pass the data over serial. I have tested it on winforms using the following code:
Debug.WriteLine("Starting Serial....");
SerialPort port = new SerialPort("COM4", 115200, Parity.None, 8, StopBits.One);
port.Open();
while (true)
{
string serialdata = port.ReadLine();
Console.WriteLine(serialdata);
label1.Text = serialdata;
}
But I can't use System.IO.Ports in android as it's not supported. There are various libraries online, but i find myself going around in circles.
If someone can provide a working snippet of code which will listen to a certain serial port then I will pay. I know the way android handles serial ports is different to windows, the usb chip on the esp32 is a CP21x
Also, if the strings could be formatted so that a whole line is received each time. I would like to receive a single line each transmission with something like "ROM = 1 6E 41 70 1 0 0 CA"
Thanks for your help
Andrew
Debug.WriteLine("Starting Serial....");
SerialPort port = new SerialPort("COM4", 115200, Parity.None, 8, StopBits.One);
port.Open();
while (true)
{
string serialdata = port.ReadLine();
Console.WriteLine(serialdata);
label1.Text = serialdata;
}
But I can't use System.IO.Ports in android as it's not supported. There are various libraries online, but i find myself going around in circles.
If someone can provide a working snippet of code which will listen to a certain serial port then I will pay. I know the way android handles serial ports is different to windows, the usb chip on the esp32 is a CP21x
Also, if the strings could be formatted so that a whole line is received each time. I would like to receive a single line each transmission with something like "ROM = 1 6E 41 70 1 0 0 CA"
Thanks for your help
Andrew