From ae75570442954851204b0e6254f585ae53cb9dd2 Mon Sep 17 00:00:00 2001 From: Edward Wright Date: Wed, 20 Oct 2021 11:46:17 -0400 Subject: [PATCH] Corrected default baud rate for CircuitPython devices. (Closes #15) --- SimplySerial/SimplySerial.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SimplySerial/SimplySerial.cs b/SimplySerial/SimplySerial.cs index bcca977..acedb86 100644 --- a/SimplySerial/SimplySerial.cs +++ b/SimplySerial/SimplySerial.cs @@ -39,7 +39,7 @@ namespace SimplySerial static bool Quiet = false; static AutoConnect autoConnect = AutoConnect.ONE; static ComPort port; - static int baud = 9600; + static int baud = -1; static Parity parity = Parity.None; static int dataBits = 8; static StopBits stopBits = StopBits.One; @@ -187,6 +187,14 @@ namespace SimplySerial // attempt to set the baud rate, fail if the specified value is not supported by the hardware try { + if (baud < 0) + { + if (port.board.isCircuitPython) + baud = 115200; + else + baud = 9600; + } + serialPort.BaudRate = baud; } catch (ArgumentOutOfRangeException)