Skip to content

Commit f133020

Browse files
authored
Improvements and fixes in SerialPort (#16)
1 parent 23c4720 commit f133020

File tree

7 files changed

+111
-121
lines changed

7 files changed

+111
-121
lines changed

System.IO.Ports/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
////////////////////////////////////////////////////////////////
1414
// update this whenever the native assembly signature changes //
15-
[assembly: AssemblyNativeVersion("100.1.1.2")]
15+
[assembly: AssemblyNativeVersion("100.1.1.3")]
1616
////////////////////////////////////////////////////////////////
1717

1818
// Setting ComVisible to false makes the types in this assembly not visible

System.IO.Ports/SerialData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ public enum SerialData
2020
/// </summary>
2121
WatchChar = 2
2222
}
23-
}
23+
}

System.IO.Ports/SerialDataReceivedEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ internal SerialDataReceivedEventArgs(SerialData eventCode)
2222
/// </summary>
2323
public SerialData EventType { get => _data; }
2424
}
25-
}
25+
}

System.IO.Ports/SerialDataReceivedEventHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ namespace System.IO.Ports
1111
/// </summary>
1212
/// <param name="sender">The sender of the event, which is the <see cref="SerialPort"/> object.</param>
1313
/// <param name="e">A <see cref="SerialDataReceivedEventArgs"/> object that contains the event data.</param>
14-
public delegate void SerialDataReceivedEventHandler(object sender, SerialDataReceivedEventArgs e);
14+
public delegate void SerialDataReceivedEventHandler(
15+
object sender,
16+
SerialDataReceivedEventArgs e);
1517
}

System.IO.Ports/SerialDeviceController.cs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ namespace System.IO.Ports
1010
/// <summary>
1111
/// This class is used to keep tabs on what serial ports are open.
1212
/// </summary>
13-
internal sealed class SerialDeviceController
13+
internal static class SerialDeviceController
1414
{
1515
// this is used as the lock object
1616
// a lock is required because multiple threads can access the SerialDevice controller
17+
[System.Diagnostics.DebuggerBrowsable(Diagnostics.DebuggerBrowsableState.Never)]
1718
private static object _syncLock;
1819

19-
// we can have only one instance of the SerialDeviceController
20-
// need to do a lazy initialization of this field to make sure it exists when called elsewhere.
21-
private static SerialDeviceController s_instance;
22-
2320
// backing field for DeviceCollection
2421
private static ArrayList s_deviceCollection;
2522

@@ -57,30 +54,5 @@ internal static ArrayList DeviceCollection
5754
s_deviceCollection = value;
5855
}
5956
}
60-
61-
/// <summary>
62-
/// Gets the default serial device controller for the system.
63-
/// </summary>
64-
/// <returns>The default GPIO controller for the system, or null if the system has no GPIO controller.</returns>
65-
internal static SerialDeviceController GetDefault()
66-
{
67-
if (s_instance == null)
68-
{
69-
if (_syncLock == null)
70-
{
71-
_syncLock = new object();
72-
}
73-
74-
lock (_syncLock)
75-
{
76-
if (s_instance == null)
77-
{
78-
s_instance = new SerialDeviceController();
79-
}
80-
}
81-
}
82-
83-
return s_instance;
84-
}
8557
}
8658
}

0 commit comments

Comments
 (0)