From a8068becba12277dbf186aa5239c36055110eff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sat, 13 Jul 2024 15:22:16 +0200 Subject: [PATCH] More migration fun --- Nefarius.Peripherals.SerialPort/NativeMethods.txt | 3 ++- Nefarius.Peripherals.SerialPort/SerialPort.cs | 8 ++++---- Nefarius.Peripherals.SerialPort/Win32PInvoke/Win32Com.cs | 5 ----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Nefarius.Peripherals.SerialPort/NativeMethods.txt b/Nefarius.Peripherals.SerialPort/NativeMethods.txt index 9de20e0..0794950 100644 --- a/Nefarius.Peripherals.SerialPort/NativeMethods.txt +++ b/Nefarius.Peripherals.SerialPort/NativeMethods.txt @@ -19,4 +19,5 @@ WaitCommEvent WriteFile CreateFile ESCAPE_COMM_FUNCTION -EscapeCommFunction \ No newline at end of file +EscapeCommFunction +CLEAR_COMM_ERROR_FLAGS \ No newline at end of file diff --git a/Nefarius.Peripherals.SerialPort/SerialPort.cs b/Nefarius.Peripherals.SerialPort/SerialPort.cs index 9dbe232..d5bc17d 100644 --- a/Nefarius.Peripherals.SerialPort/SerialPort.cs +++ b/Nefarius.Peripherals.SerialPort/SerialPort.cs @@ -496,7 +496,7 @@ public partial class SerialPort : IDisposable if (PInvoke.ClearCommError(_hPort, &errs, null)) { StringBuilder s = new("UART Error: ", 40); - if (((uint)errs & Win32Com.CE_FRAME) != 0) + if (((uint)errs & (uint)CLEAR_COMM_ERROR_FLAGS.CE_FRAME) != 0) { s = s.Append("Framing,"); } @@ -506,17 +506,17 @@ public partial class SerialPort : IDisposable s = s.Append("IO,"); } - if (((uint)errs & Win32Com.CE_OVERRUN) != 0) + if (((uint)errs & (uint)CLEAR_COMM_ERROR_FLAGS.CE_OVERRUN) != 0) { s = s.Append("Overrun,"); } - if (((uint)errs & Win32Com.CE_RXOVER) != 0) + if (((uint)errs & (uint)CLEAR_COMM_ERROR_FLAGS.CE_RXOVER) != 0) { s = s.Append("Receive Overflow,"); } - if (((uint)errs & Win32Com.CE_RXPARITY) != 0) + if (((uint)errs & (uint)CLEAR_COMM_ERROR_FLAGS.CE_RXPARITY) != 0) { s = s.Append("Parity,"); } diff --git a/Nefarius.Peripherals.SerialPort/Win32PInvoke/Win32Com.cs b/Nefarius.Peripherals.SerialPort/Win32PInvoke/Win32Com.cs index 9d34003..2fae8d2 100644 --- a/Nefarius.Peripherals.SerialPort/Win32PInvoke/Win32Com.cs +++ b/Nefarius.Peripherals.SerialPort/Win32PInvoke/Win32Com.cs @@ -6,11 +6,6 @@ namespace Nefarius.Peripherals.SerialPort.Win32PInvoke; internal class Win32Com { //Constants for lpErrors: - internal const UInt32 CE_RXOVER = 0x0001; - internal const UInt32 CE_OVERRUN = 0x0002; - internal const UInt32 CE_RXPARITY = 0x0004; - internal const UInt32 CE_FRAME = 0x0008; - internal const UInt32 CE_BREAK = 0x0010; internal const UInt32 CE_TXFULL = 0x0100; internal const UInt32 CE_PTO = 0x0200; internal const UInt32 CE_IOE = 0x0400;