Skip to content

Commit 5cb6aa9

Browse files
authored
Implement InvertSignalLevels on SerialPort (#57)
1 parent ab87ec0 commit 5cb6aa9

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
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.2.0")]
15+
[assembly: AssemblyNativeVersion("100.1.3.0")]
1616
////////////////////////////////////////////////////////////////
1717

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

System.IO.Ports/SerialPort.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,26 @@ public extern int BytesToRead
464464
get;
465465
}
466466

467+
/// <summary>
468+
/// Gets or sets the logic level of the RX and TX signals.
469+
/// </summary>
470+
/// <exception cref="InvalidOperationException">Trying to set this property when the <see cref="SerialPort"/> is already opened and the driver doesn't support it.</exception>
471+
/// <exception cref="NotSupportedException">Trying to set this property on a target that does not support signal inversion.</exception>
472+
/// <remarks>
473+
/// When the signal levels are not inverted (reads <see langword="false"/>) the RX, TX pins use the standard logic levels (VDD = 1/idle, GND = 0/mark).
474+
/// Setting this property to <see langword="true"/>, will invert those signal levels, which will become inverted (VDD = 0/mark, GND= 1/idle).
475+
/// Some targets may not support this setting and accessing it will throw a <see cref="NotSupportedException"/> exception.
476+
/// This is a .NET nanoFramework property only. Doesn't exist on other .NET platforms.
477+
/// </remarks>
478+
public extern bool InvertSignalLevels
479+
{
480+
[MethodImpl(MethodImplOptions.InternalCall)]
481+
get;
482+
483+
[MethodImpl(MethodImplOptions.InternalCall)]
484+
set;
485+
}
486+
467487
#endregion
468488

469489
/// <summary>
@@ -732,7 +752,7 @@ public void Dispose()
732752

733753
[MethodImpl(MethodImplOptions.InternalCall)]
734754
internal static extern string GetDeviceSelector();
735-
755+
736756
#endregion
737757
}
738758
}

0 commit comments

Comments
 (0)