[Mono-dev] Patch for Bug 8207: Can't set 1000000 baud with System.IO.Ports.SerialPort.BaudRate

Miguel de Icaza miguel at xamarin.com
Tue May 12 13:50:59 UTC 2015


Mono 4.0 branched a long time ago, so it is possible that this is just a
side effect of that.

But you can check the patch in git, if the patch is not on the mono 4.0.0
branch, and only in master, it means that it will be part of Mono 4.2

Miguel

On Tue, May 12, 2015 at 4:47 AM, Ariel Rocholl <publico at arocholl.com> wrote:

> Hi there,
>
>
>
> I don’t see this included in Mono 4.0, probably misunderstood this one
> would be merged into 4.0.
>
>
>
> Do you have a target release where this will be available?
>
>
> Best Regards,
> ----
> Ariel Rocholl
>
>
>
> *From:* mono-devel-list-bounces at lists.ximian.com [mailto:
> mono-devel-list-bounces at lists.ximian.com] *On Behalf Of *Miguel de Icaza
> *Sent:* Wednesday, February 25, 2015 17:45
> *To:* Christian Hofstaedtler
> *Cc:* mono-devel
> *Subject:* Re: [Mono-dev] Patch for Bug 8207: Can't set 1000000 baud with
> System.IO.Ports.SerialPort.BaudRate
>
>
>
> Applied, and updated also to support Mac.
>
>
>
> On Tue, Feb 24, 2015 at 3:45 PM, Christian Hofstaedtler <
> ch---mono-devel at zeha.at> wrote:
>
> This patch (against mono-2.10.8.1 from Debian) allows setting
> custom baud rates, and very likely would support a baudrate of
> 1000000.
>
> I release this patch under the MIT license.
>
>
> --- serial.c.orig       2013-01-30 12:06:52.379691461 +0100
> +++ serial.c.orig       2013-01-30 13:05:50.383390154 +0100
> @@ -17,6 +17,11 @@
>  #endif
>  #include <sys/ioctl.h>
>
> +/* This is for ASYNC_*, serial_struct on linux */
> +#if defined(__linux__)
> +#include <linux/serial.h>
> +#endif
> +
>  #include <glib.h>
>
>  /* This is for FIONREAD on solaris */
> @@ -151,6 +156,7 @@
>  set_attributes (int fd, int baud_rate, MonoParity parity, int dataBits,
> MonoStopBits stopBits, MonoHandshake handshake)
>  {
>         struct termios newtio;
> +       gboolean custom_baud_rate = FALSE;
>
>         if (tcgetattr (fd, &newtio) == -1)
>                 return FALSE;
> @@ -227,8 +233,10 @@
>             break;
>         case 50:
>         case 0:
> -       default:
>             baud_rate = B9600;
> +           break;
> +       default:
> +           custom_baud_rate = TRUE;
>                 break;
>         }
>
> @@ -319,16 +327,54 @@
>             newtio.c_iflag |= IXOFF | IXON;
>                 break;
>         }
> -
> -       if (cfsetospeed (&newtio, baud_rate) < 0 || cfsetispeed (&newtio,
> baud_rate) < 0 ||
> -           tcsetattr (fd, TCSANOW, &newtio) < 0)
> +
> +       if (custom_baud_rate == FALSE)
>         {
> -               return FALSE;
> +               if (cfsetospeed (&newtio, baud_rate) < 0 || cfsetispeed
> (&newtio, baud_rate) < 0)
> +               {
> +                       return FALSE;
> +               }
>         }
>         else
>         {
> -       return TRUE;
> +               /* On Linux, to set a custom baud rate, we must set the
> "standard" baud_rate
> +                * to 38400. */
> +               if (cfsetospeed (&newtio, B38400) < 0 || cfsetispeed
> (&newtio, B38400) < 0)
> +               {
> +                       return FALSE;
> +               }
> +       }
> +
> +       if (tcsetattr (fd, TCSANOW, &newtio) < 0)
> +       {
> +               return FALSE;
> +       }
> +
> +       if (custom_baud_rate == TRUE)
> +       {
> +#if defined(__linux__)
> +               struct serial_struct ser;
> +
> +               if (ioctl (fd, TIOCGSERIAL, &ser) < 0)
> +               {
> +                       return FALSE;
> +               }
> +
> +               ser.custom_divisor = ser.baud_base / baud_rate;
> +               ser.flags &= ~ASYNC_SPD_MASK;
> +               ser.flags |= ASYNC_SPD_CUST;
> +
> +               if (ioctl (fd, TIOCSSERIAL, &ser) < 0)
> +               {
> +                       return FALSE;
> +               }
> +#else
> +               /* Don't know how to set custom baud rate on this
> platform. */
> +               return FALSE;
> +#endif
>         }
> +
> +       return TRUE;
>  }
>
>
> _______________________________________________
> 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/20150512/16debf8d/attachment.html>


More information about the Mono-devel-list mailing list