From cf1e28ccd590820c9dfc8e3db340e0a1df2fb8fd Mon Sep 17 00:00:00 2001 From: taylorza Date: Mon, 16 Jan 2023 20:35:33 -0500 Subject: [PATCH] Fixed null reference issues --- UARTReplacement/SerialPort.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UARTReplacement/SerialPort.cs b/UARTReplacement/SerialPort.cs index 07126d8..69a4e3b 100644 --- a/UARTReplacement/SerialPort.cs +++ b/UARTReplacement/SerialPort.cs @@ -193,6 +193,7 @@ public int Baud public void Reset(byte ResetByte) { + if (port is null) return; // bit 7 = Indicates the reset signal to the expansion bus and esp is asserted bool resetESP = (ResetByte & 128) == 128; if (resetESP) @@ -216,7 +217,7 @@ public void EnableEspGpio(byte EnableByte) public void SetEspGpio(byte GpioByte) { - if (enableEspGpio) + if (enableEspGpio || port is null) return; // bit 0 = Read / Write ESP GPIO0 (hard reset = 1)