[Mono-dev] Question on SerialPort - Serial.c

Daniel Lo Nigro lists at dan.cx
Mon Jan 14 00:01:19 UTC 2013


>
>  So except anyone disagree, baudrate values should not be checked for
> anything different than that.

I agree - Mono should do whatever Microsoft .NET does.

In general terms, how often a new Mono version is released with all the
> accumulated fixes?

Releases of Mono 3.0 are coming out more frequently than previous releases
did. Mono 3.0 came out in October 2012 and there have already been releases
of 3.0.1, 3.0.2 and 3.0.3 to fix (mostly) minor bugs. I made a bug fix back
in December and it's already in Mono 3.0.3. I think the Mono team are
aiming for frequent small releases rather than infrequent massive releases.


> I am a Mercurial guy so have to get used to GIT in the first place…

Git is very similar to Mercurial, it shouldn't take you too long to get
used to Git :)




On Mon, Jan 14, 2013 at 9:56 AM, <foros at arocholl.com> wrote:

> >>Does Microsoft's implementation accept *any* baud rate, or are there
> only some that it accepts that Mono doesn't? If Microsoft's accepts any
> then maybe the baud rate validation should be moved from Mono.****
>
> ** **
>
> Apparently, yes, MS accepts any baudrate but zero or lower than zero.****
>
> ** **
>
> I tested several custom baudrate values and, as far as I can see, all them
> are accepted by .NET SerialPort. Perhaps the Microsoft approach is to ask
> the underlying driver to validate baudrates, if at all. In the case of the
> Windows CP2102 driver, it will accept any baudrate including ones that are
> not physically supported. For instance I tested 1,500,000bps which is not
> really going to work on the physical CP2102 hardware (max available speed
> is 920,000bps on the CP2102 device) and still the SerialPort accepts the
> 1,500,000 bps, connects to it and if you read the baudrate property, it
> returns 1,500,000. So probably the Mono approach is too limited, because it
> really depends on a switch/case with a set of hardcoded, predefined values.
> ****
>
> ** **
>
> See a fraction of Serial.c below****
>
> ** **
>
>             switch (baud_rate)****
>
>             {****
>
> ….****
>
>             case 115200: ****
>
>                 baud_rate = B115200;****
>
>                 break;****
>
>             case 57600:****
>
>                 baud_rate = B57600;****
>
>                 break;****
>
> ….****
>
>             case 50:****
>
>             case 0:****
>
>             default:****
>
>                 baud_rate = -1;****
>
>                         break;****
>
>             }****
>
> ** **
>
> Anything that is unknown goes to <default> which in the end returns an
> unsupported baudrate exception to the caller.****
>
> ** **
>
> However, that doesn’t seem the way the Windows .NET SerialPort class works
> and, in today’s world of interconnected USB COM custom devices, it really
> puts a hard limit on baudrates you can use. Interestingly, the
> documentation of SerialPort::Open doesn’t explicitly document any baudrate
> value being invalid, except if it is equal or lower than zero. From MSDN:*
> ***
>
> ** **
>
> ArgumentOutOfRangeException<http://msdn.microsoft.com/en-us/library/system.argumentoutofrangeexception%28v=vs.100%29.aspx>
> ****
>
> One or more of the properties for this instance are invalid. For example,
> the Parity<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.parity%28v=vs.100%29.aspx>,
> DataBits<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.databits%28v=vs.100%29.aspx>,
> or Handshake<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.handshake%28v=vs.100%29.aspx>properties are not valid values; the
> BaudRate<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.baudrate%28v=vs.100%29.aspx>is less than or equal to zero; the
> ReadTimeout<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.readtimeout%28v=vs.100%29.aspx>or
> WriteTimeout<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.writetimeout%28v=vs.100%29.aspx>property is less than zero and is not
> InfiniteTimeout<http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.infinitetimeout%28v=vs.100%29.aspx>.
> ****
>
> ** **
>
> ** **
>
> So except anyone disagree, baudrate values should not be checked for
> anything different than that. I will then fill in a bugzilla entry and pull
> a request in a few days. I am a Mercurial guy so have to get used to GIT in
> the first place…****
>
> ** **
>
> In general terms, how often a new Mono version is released with all the
> accumulated fixes? I saw releases are probably a few months apart in the
> official download site, is that driven by a scheduled event of any kind?**
> **
>
> ** **
>
> >> You should be able to run "make" and "make install" in the directory
> of the file you're modifying, and that should compile and install just that
> component.****
>
> ** **
>
> Thanks for the tip, this is much better. It works nicely.****
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130114/37e2fe5e/attachment-0001.html>


More information about the Mono-devel-list mailing list