Migrated all legacy PInvoke
This commit is contained in:
@@ -11,8 +11,6 @@ using Windows.Win32.Storage.FileSystem;
|
||||
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
using Nefarius.Peripherals.SerialPort.Win32PInvoke;
|
||||
|
||||
namespace Nefarius.Peripherals.SerialPort;
|
||||
|
||||
/// <summary>
|
||||
@@ -344,7 +342,7 @@ public partial class SerialPort : IDisposable
|
||||
public void SendImmediate(byte tosend)
|
||||
{
|
||||
CheckOnline();
|
||||
if (!Win32Com.TransmitCommChar(_hPort.DangerousGetHandle(), tosend))
|
||||
if (!PInvoke.TransmitCommChar(_hPort, new CHAR((sbyte)tosend)))
|
||||
{
|
||||
ThrowException("Transmission failure");
|
||||
}
|
||||
@@ -357,12 +355,12 @@ public partial class SerialPort : IDisposable
|
||||
protected ModemStatus GetModemStatus()
|
||||
{
|
||||
CheckOnline();
|
||||
if (!Win32Com.GetCommModemStatus(_hPort.DangerousGetHandle(), out uint f))
|
||||
if (!PInvoke.GetCommModemStatus(_hPort, out MODEM_STATUS_FLAGS f))
|
||||
{
|
||||
ThrowException("Unexpected failure");
|
||||
}
|
||||
|
||||
return new ModemStatus((MODEM_STATUS_FLAGS)f);
|
||||
return new ModemStatus(f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -591,12 +589,12 @@ public partial class SerialPort : IDisposable
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
if (!Win32Com.GetCommModemStatus(_hPort.DangerousGetHandle(), out uint f))
|
||||
if (!PInvoke.GetCommModemStatus(_hPort, out MODEM_STATUS_FLAGS f))
|
||||
{
|
||||
throw new CommPortException("IO Error [005]");
|
||||
}
|
||||
|
||||
OnStatusChange(new ModemStatus(i), new ModemStatus((MODEM_STATUS_FLAGS)f));
|
||||
OnStatusChange(new ModemStatus(i), new ModemStatus(f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,7 +618,7 @@ public partial class SerialPort : IDisposable
|
||||
|
||||
if (_online)
|
||||
{
|
||||
if (Win32Com.GetHandleInformation(_hPort.DangerousGetHandle(), out uint _))
|
||||
if (PInvoke.GetHandleInformation(_hPort, out uint _))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user