Samraksh / eMote

eMote OS -- Multiple Ports (using .NET MF v4.3)
0 stars 0 forks source link

Exception when instantiating SerialPort #126

Open WilliamAtSamraksh opened 10 years ago

WilliamAtSamraksh commented 10 years ago

In an ADAPT program, executing

_serial = new SerialPort("COM29") { BaudRate = 115200, Parity = Parity.None, DataBits = 8, StopBits = StopBits.One };

results in an exception:

    #### Exception System.ArgumentException - 0xfd000000 (1) ####
    #### Message:
    #### Microsoft.SPOT.Hardware.NativeEventDispatcher::.ctor [IP: 0000] ####
    #### System.IO.Ports.SerialPort::.ctor [IP: 0030] ####
    #### System.IO.Ports.SerialPort::.ctor [IP: 000d] ####
    #### Samraksh.AppNote.DotNow.RadarDataExfiltrator.RadarDisplacementDetector::Main [IP: 0084] ####

I'm using a relatively recent build of eMote for ADAPT, one that has the fix for ADC in it.

WilliamAtSamraksh commented 10 years ago

Update. This works for COM1 but throws an exception for others that I've tried.

I'm changing this to a request that a meaningful exception message be given; something like "Port name must be COM1". It should be possible to do this in the interop, before it gets down to the native code.

MichaelAtSamraksh commented 10 years ago

Is there a way to communicate the "COM1" string to users, either in code in a Microsoft DLL or eMote DLL, or enumeration during execution, or in the user manual? The device COM port could easily confuse users since we already place burden on users to figure out which Windows COM port number to use. And the hard-coded string affects code portability.

WilliamAtSamraksh commented 10 years ago

An enumeration (or a class) is plausible since the choices are so limited . It would mean extending the SerialPort class to include an overload for the enumeration.