Struct SerialSettings
A port's speed and character format: eight data bits, with the parity and stop bits given.
public readonly record struct SerialSettings : IEquatable<SerialSettings>
- Implements
- Inherited Members
Examples
var meter = new SerialSettings(9_600, Parity.Even);
// meter.ToString() is "9600 8E1", eleven bits a character
Constructors
SerialSettings(uint, Parity, byte)
A port's speed and character format: eight data bits, with the parity and stop bits given.
public SerialSettings(uint Baud, Parity Parity = Parity.None, byte StopBits = 1)
Parameters
BauduintThe speed, in bits a second.
ParityParityThe parity bit each character carries.
StopBitsbyte1 or 2.
Examples
var meter = new SerialSettings(9_600, Parity.Even);
// meter.ToString() is "9600 8E1", eleven bits a character
Properties
Baud
The speed, in bits a second.
public uint Baud { get; init; }
Property Value
BitsPerCharacter
The bits one character takes on the wire: a start bit, eight data bits, the parity bit if there is one, and the stop bits.
public uint BitsPerCharacter { get; }
Property Value
Exceptions
- PamojaException
The settings are not ones a port has.
CharacterNanos
How long one character takes on the wire, in nanoseconds, rounded up.
public ulong CharacterNanos { get; }
Property Value
Exceptions
- PamojaException
The settings are not ones a port has.
Parity
The parity bit each character carries.
public Parity Parity { get; init; }
Property Value
StopBits
1 or 2.
public byte StopBits { get; init; }
Property Value
Methods
ToNative()
Converts to the flat struct the C ABI takes, for a native call another package makes.
public PamojaSerialSettings ToNative()
Returns
- PamojaSerialSettings
The interop representation.
ToString()
Writes the settings the way a device's manual does, such as 9600 8E1.
public override string ToString()
Returns
- string
The speed, the eight data bits, the parity letter, and the stop bit count.
TransferMicros(int)
Returns how long bytes sent back to back take on the wire.
public ulong TransferMicros(int bytes)
Parameters
bytesintHow many bytes.
Returns
- ulong
The time in microseconds, rounded up.
Exceptions
- PamojaException
The settings are not ones a port has.