Skip to content

Commit 2d95743

Browse files
committed
add support for using flow control with BP35A1
1 parent 2890430 commit 2d95743

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/BP35A1.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public class BP35A1 : BP35Base {
2121
/// </remarks>
2222
internal const BP35UartBaudRate DefaultValueForBP35UartBaudRate = BP35UartBaudRate.Baud115200;
2323

24+
/// <summary>
25+
/// Refer to the initial value of the flow control for UART setting in the BP35A1.
26+
/// </summary>
27+
/// <remarks>
28+
/// See 'BP35A1コマンドリファレンス 3.32. WUART (プロダクト設定コマンド)' for detailed specifications.
29+
/// </remarks>
30+
internal const bool DefaultValueForUseFlowControl = false;
31+
2432
public static ValueTask<BP35A1> CreateAsync(
2533
string? serialPortName,
2634
IServiceProvider? serviceProvider = null,
@@ -78,5 +86,6 @@ private BP35A1(
7886

7987
private protected class BP35A1SerialPortStreamFactory(BP35A1Configurations configurations) : SerialPortStreamFactory {
8088
public override BP35UartBaudRate BaudRate { get; } = configurations.BaudRate;
89+
public override bool UseFlowControl { get; } = configurations.UseFlowControl;
8190
}
8291
}

src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/BP35A1Configurations.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public sealed class BP35A1Configurations {
1313
/// </summary>
1414
public BP35UartBaudRate BaudRate { get; set; } = BP35A1.DefaultValueForBP35UartBaudRate;
1515

16+
/// <summary>
17+
/// Gets or sets a value indicating whether or not to use the Request-to-Send (RTS) hardware flow control for communicating with the device.
18+
/// </summary>
19+
public bool UseFlowControl { get; set; } = BP35A1.DefaultValueForUseFlowControl;
20+
1621
/// <summary>
1722
/// Gets or sets a value indicating whether or not to attempt to load the configuration from flash memory during initialization.
1823
/// </summary>

src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/BP35Base.SerialPortStreamFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ partial class BP35Base {
1212
#pragma warning restore IDE0040
1313
private protected abstract class SerialPortStreamFactory : IBP35SerialPortStreamFactory {
1414
public abstract BP35UartBaudRate BaudRate { get; }
15+
public abstract bool UseFlowControl { get; }
1516

1617
public void Dispose()
1718
{
@@ -46,9 +47,9 @@ public Stream CreateSerialPortStream(string? serialPortName)
4647
dataBits: 8,
4748
stopBits: StopBits.One
4849
) {
49-
Handshake = Handshake.None, // TODO: RequestToSend
50+
Handshake = UseFlowControl ? Handshake.RequestToSend : Handshake.None,
5051
DtrEnable = false,
51-
RtsEnable = false,
52+
RtsEnable = UseFlowControl,
5253
NewLine = CRLF,
5354
};
5455
#pragma warning restore CA2000

0 commit comments

Comments
 (0)