nanoframework / Home

:house: The landing page for .NET nanoFramework repositories.
https://www.nanoframework.net
MIT License
844 stars 75 forks source link

ESP32_C6_THREAD thrown a System.ArgumentException at SerialPort with COM1 #1505

Closed romankiss closed 2 weeks ago

romankiss commented 3 weeks ago

Target name(s)

ESP32_C6_THREAD

Firmware version

all versions

Was working before? On which version?

no

Device capabilities

No response

Description

Product: M5NanoC6 SerialPort can be opened only for COM2 configuration:

Configuration.SetPinFunction(1, DeviceFunction.COM2_RX);  
Configuration.SetPinFunction(2, DeviceFunction.COM2_TX);
var uart = new SerialPort("COM2", 9600);
uart.Open();   

Using the COM1 the SerialPort throw the Exception in the Open method:

++++ Exception System.ArgumentException - 0xfd000000 (1) ++++
++++ Message: 
++++ System.IO.Ports.SerialPort::NativeInit [IP: 0000] ++++
++++ System.IO.Ports.SerialPort::Open [IP: 000f] ++++
Exception thrown: 'System.ArgumentException' in System.IO.Ports.dll

Note, that using the COM3 configuration, the following Exception is thrown at the SetPinFunction method:

++++ Exception System.ArgumentException - 0xfd000000 (1) ++++
++++ Message: 
++++ nanoFramework.Hardware.Esp32.Configuration::NativeSetPinFunction [IP: 0000] ++++
++++ nanoFramework.Hardware.Esp32.Configuration::SetPinFunction [IP: 0005] ++++    
Exception thrown: 'System.ArgumentException' in nanoFramework.Hardware.Esp32.dll

How to reproduce

Configuration.SetPinFunction(1, DeviceFunction.COM1_RX);
Configuration.SetPinFunction(2, DeviceFunction.COM1_TX); var uart = new SerialPort("COM1", 9600); uart.Open(); // <= throw System.ArgumentException

Expected behaviour

No response

Screenshots

No response

Aditional information

No response

AdrianSoundy commented 2 weeks ago

The ESP32_C6 has only 2 COM ports COM1 & COM2 which is why you get an exception on COM3.

Because the C3, C6 & H2 devices use the USB_Jtag interface instead of the COM1 for the connection to VS there is no reason to disable COM1 for these devices.

AdrianSoundy commented 2 weeks ago

Will add a change to enable COM1 if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED is defined.