I have installed .NET NanoFramework on a LOLIN S2 mini (ESP32-S2 chip). It is working fine. But - I cannot find a way to send serial output via the USB port to the PC. I am not sure which COM port number I have to use, so I tried COM1 & COM2
My test code:
using System;
using System.Diagnostics;
using System.Threading;
using System.Device.Gpio;
using nanoFramework;
using System.IO.Ports;
namespace NFApp1
{
public class Program
{
private static GpioController s_GpioController;
public static void Main()
{
var port = new SerialPort("COM1", 115200);
s_GpioController = new GpioController();
GpioPin led = s_GpioController.OpenPin(15, PinMode.Output);
led.Write(PinValue.Low);
port.Open();
while (true)
{
port.Write("Test... ");
led.Toggle();
Thread.Sleep(125);
led.Toggle();
Thread.Sleep(125);
led.Toggle();
Thread.Sleep(125);
led.Toggle();
Thread.Sleep(525);
}
}
}
}
When using COM1 my code is running, but "Test... " does not show up. Next issue is that I am not able to deploy solution again. I have to nanoff to reflash firmware.
When using COM2 my code is not executing at all. The deploy issue does not appear.
Any suggestions ?
Best regards, Brian
I tried all that I was able to figure out
You'll see that test output on Visual Studio output pane.
On which COM port you should use, it depends on your hardware exposes. Know that one of the COM ports (usually the 1st one) it's reserved for Wire Protocol (meaning communicating with VS, deploying and debugging) so you CAN NOT use it, otherwise your system get's isolated from the outside world.
In order to add logging to your application, you may want to look at nanoFramework logging library. Choose the flavor that better fits your purpose.