Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release main/Smdn.Devices.BP35XX-2.0.0 #7

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Smdn.Devices.BP35XX.dll (Smdn.Devices.BP35XX-1.0.0)
// Smdn.Devices.BP35XX.dll (Smdn.Devices.BP35XX-2.0.0)
// Name: Smdn.Devices.BP35XX
// AssemblyVersion: 1.0.0.0
// InformationalVersion: 1.0.0+e4163ada5b034b45c5cc0dac179b412cf54198cd
// AssemblyVersion: 2.0.0.0
// InformationalVersion: 2.0.0+ef185af5c73268aab02d6909202fffce4560122b
// TargetFramework: .NETCoreApp,Version=v6.0
// Configuration: Release
// Referenced assemblies:
Expand All @@ -27,15 +27,8 @@
using Smdn.Net.SkStackIP;

namespace Smdn.Devices.BP35XX {
public interface IBP35Configurations {
BP35UartBaudRate BaudRate { get; }
SkStackERXUDPDataFormat ERXUDPDataFormat { get; }
string? SerialPortName { get; }
bool TryLoadFlashMemory { get; }
}

public interface IBP35SerialPortStreamFactory {
Stream CreateSerialPortStream(IBP35Configurations configurations);
public interface IBP35SerialPortStreamFactory : IDisposable {
Stream CreateSerialPortStream(string? serialPortName);
}

public enum BP35UartBaudRate : byte {
Expand Down Expand Up @@ -72,13 +65,13 @@ public static ValueTask<BP35A1> CreateAsync(BP35A1Configurations configurations,
public static ValueTask<BP35A1> CreateAsync(string? serialPortName, IServiceProvider? serviceProvider = null, CancellationToken cancellationToken = default) {}
}

public sealed class BP35A1Configurations : IBP35Configurations {
public sealed class BP35A1Configurations {
public BP35A1Configurations() {}

public BP35UartBaudRate BaudRate { get; set; }
public string? SerialPortName { get; set; }
SkStackERXUDPDataFormat IBP35Configurations.ERXUDPDataFormat { get; }
public bool TryLoadFlashMemory { get; set; }
public bool UseFlowControl { get; set; }
}

public abstract class BP35Base : SkStackClient {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Smdn.Devices.BP35XX.dll (Smdn.Devices.BP35XX-1.0.0)
// Smdn.Devices.BP35XX.dll (Smdn.Devices.BP35XX-2.0.0)
// Name: Smdn.Devices.BP35XX
// AssemblyVersion: 1.0.0.0
// InformationalVersion: 1.0.0+e4163ada5b034b45c5cc0dac179b412cf54198cd
// AssemblyVersion: 2.0.0.0
// InformationalVersion: 2.0.0+ef185af5c73268aab02d6909202fffce4560122b
// TargetFramework: .NETCoreApp,Version=v8.0
// Configuration: Release
// Referenced assemblies:
Expand All @@ -27,15 +27,8 @@
using Smdn.Net.SkStackIP;

namespace Smdn.Devices.BP35XX {
public interface IBP35Configurations {
BP35UartBaudRate BaudRate { get; }
SkStackERXUDPDataFormat ERXUDPDataFormat { get; }
string? SerialPortName { get; }
bool TryLoadFlashMemory { get; }
}

public interface IBP35SerialPortStreamFactory {
Stream CreateSerialPortStream(IBP35Configurations configurations);
public interface IBP35SerialPortStreamFactory : IDisposable {
Stream CreateSerialPortStream(string? serialPortName);
}

public enum BP35UartBaudRate : byte {
Expand Down Expand Up @@ -72,13 +65,13 @@ public static ValueTask<BP35A1> CreateAsync(BP35A1Configurations configurations,
public static ValueTask<BP35A1> CreateAsync(string? serialPortName, IServiceProvider? serviceProvider = null, CancellationToken cancellationToken = default) {}
}

public sealed class BP35A1Configurations : IBP35Configurations {
public sealed class BP35A1Configurations {
public BP35A1Configurations() {}

public BP35UartBaudRate BaudRate { get; set; }
public string? SerialPortName { get; set; }
SkStackERXUDPDataFormat IBP35Configurations.ERXUDPDataFormat { get; }
public bool TryLoadFlashMemory { get; set; }
public bool UseFlowControl { get; set; }
}

public abstract class BP35Base : SkStackClient {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Smdn.Devices.BP35XX.dll (Smdn.Devices.BP35XX-1.0.0)
// Smdn.Devices.BP35XX.dll (Smdn.Devices.BP35XX-2.0.0)
// Name: Smdn.Devices.BP35XX
// AssemblyVersion: 1.0.0.0
// InformationalVersion: 1.0.0+e4163ada5b034b45c5cc0dac179b412cf54198cd
// AssemblyVersion: 2.0.0.0
// InformationalVersion: 2.0.0+ef185af5c73268aab02d6909202fffce4560122b
// TargetFramework: .NETStandard,Version=v2.1
// Configuration: Release
// Referenced assemblies:
Expand All @@ -23,15 +23,8 @@
using Smdn.Net.SkStackIP;

namespace Smdn.Devices.BP35XX {
public interface IBP35Configurations {
BP35UartBaudRate BaudRate { get; }
SkStackERXUDPDataFormat ERXUDPDataFormat { get; }
string? SerialPortName { get; }
bool TryLoadFlashMemory { get; }
}

public interface IBP35SerialPortStreamFactory {
Stream CreateSerialPortStream(IBP35Configurations configurations);
public interface IBP35SerialPortStreamFactory : IDisposable {
Stream CreateSerialPortStream(string? serialPortName);
}

public enum BP35UartBaudRate : byte {
Expand Down Expand Up @@ -68,13 +61,13 @@ public static ValueTask<BP35A1> CreateAsync(BP35A1Configurations configurations,
public static ValueTask<BP35A1> CreateAsync(string? serialPortName, IServiceProvider? serviceProvider = null, CancellationToken cancellationToken = default) {}
}

public sealed class BP35A1Configurations : IBP35Configurations {
public sealed class BP35A1Configurations {
public BP35A1Configurations() {}

public BP35UartBaudRate BaudRate { get; set; }
public string? SerialPortName { get; set; }
SkStackERXUDPDataFormat IBP35Configurations.ERXUDPDataFormat { get; }
public bool TryLoadFlashMemory { get; set; }
public bool UseFlowControl { get; set; }
}

public abstract class BP35Base : SkStackClient {
Expand Down
88 changes: 0 additions & 88 deletions src/Smdn.Devices.BP35XX/CompatibilitySuppressions.xml

This file was deleted.

4 changes: 2 additions & 2 deletions src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ SPDX-License-Identifier: MIT
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
<!-- <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> -->
<Nullable>enable</Nullable>
<RootNamespace/> <!-- empty the root namespace so that the namespace is determined only by the directory name, for code style rule IDE0030 -->
<NoWarn>CS1591;$(NoWarn)</NoWarn> <!-- CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member' -->
Expand Down
13 changes: 12 additions & 1 deletion src/Smdn.Devices.BP35XX/Smdn.Devices.BP35XX/BP35A1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public class BP35A1 : BP35Base {
/// </remarks>
internal const BP35UartBaudRate DefaultValueForBP35UartBaudRate = BP35UartBaudRate.Baud115200;

/// <summary>
/// Refer to the initial value of the flow control for UART setting in the BP35A1.
/// </summary>
/// <remarks>
/// See 'BP35A1コマンドリファレンス 3.32. WUART (プロダクト設定コマンド)' for detailed specifications.
/// </remarks>
internal const bool DefaultValueForUseFlowControl = false;

public static ValueTask<BP35A1> CreateAsync(
string? serialPortName,
IServiceProvider? serviceProvider = null,
Expand Down Expand Up @@ -67,14 +75,17 @@ private BP35A1(
)
: base(
serialPortName: configurations.SerialPortName,
#pragma warning disable CA2000
serialPortStreamFactory: serviceProvider?.GetService<IBP35SerialPortStreamFactory>() ?? new BP35A1SerialPortStreamFactory(configurations),
#pragma warning restore CA2000
erxudpDataFormat: SkStackERXUDPDataFormat.Binary,
logger: serviceProvider?.GetService<ILoggerFactory>()?.CreateLogger<BP35A1>()
)
{
}

private protected class BP35A1SerialPortStreamFactory(BP35A1Configurations configurations) : SerialPortStreamFactory {
private class BP35A1SerialPortStreamFactory(BP35A1Configurations configurations) : SerialPortStreamFactory {
public override BP35UartBaudRate BaudRate { get; } = configurations.BaudRate;
public override bool UseFlowControl { get; } = configurations.UseFlowControl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public sealed class BP35A1Configurations {
/// </summary>
public BP35UartBaudRate BaudRate { get; set; } = BP35A1.DefaultValueForBP35UartBaudRate;

/// <summary>
/// Gets or sets a value indicating whether or not to use the Request-to-Send (RTS) hardware flow control for communicating with the device.
/// </summary>
public bool UseFlowControl { get; set; } = BP35A1.DefaultValueForUseFlowControl;

/// <summary>
/// Gets or sets a value indicating whether or not to attempt to load the configuration from flash memory during initialization.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ namespace Smdn.Devices.BP35XX;
#pragma warning disable IDE0040
partial class BP35Base {
#pragma warning restore IDE0040
private protected abstract class SerialPortStreamFactory : IBP35SerialPortStreamFactory {
internal abstract class SerialPortStreamFactory : IBP35SerialPortStreamFactory {
public abstract BP35UartBaudRate BaudRate { get; }
public abstract bool UseFlowControl { get; }

public void Dispose()
{
// nothing to do in this class
}

public Stream CreateSerialPortStream(string? serialPortName)
{
Expand Down Expand Up @@ -41,9 +47,9 @@ public Stream CreateSerialPortStream(string? serialPortName)
dataBits: 8,
stopBits: StopBits.One
) {
Handshake = Handshake.None, // TODO: RequestToSend
Handshake = UseFlowControl ? Handshake.RequestToSend : Handshake.None,
DtrEnable = false,
RtsEnable = false,
RtsEnable = UseFlowControl,
NewLine = CRLF,
};
#pragma warning restore CA2000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// SPDX-FileCopyrightText: 2024 smdn <smdn@smdn.jp>
// SPDX-License-Identifier: MIT
using System;
using System.IO;

namespace Smdn.Devices.BP35XX;

public interface IBP35SerialPortStreamFactory {
public interface IBP35SerialPortStreamFactory : IDisposable {
Stream CreateSerialPortStream(string? serialPortName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public PseudoSerialPortStreamFactory()
{
}

public void Dispose()
{
// nothing to do in this class
}

public Stream CreateSerialPortStream(string? serialPortName)
=> Stream;
}