MulAvailable

This commit is contained in:
Nitload
2025-12-16 23:13:17 +08:00
parent 28ea5d1d1e
commit 3486375470
2637 changed files with 23787 additions and 838773 deletions
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace EM.LowLevel
{
/// <summary>
/// High-level transport abstraction for device communication. Derives from Stream and
/// encapsulates initialization/handshake and frame (header/tail/checksum) handling as needed
/// by the device. Implementations may wrap SerialPort, Sockets, USB, etc.
/// </summary>
public abstract class PortStream : Stream
{
/// <summary>
/// Optional bytes available hint if the transport can provide it.
/// </summary>
public virtual long? BytesAvailable => null;
/// <summary>
/// Close the underlying transport and release resources.
/// </summary>
public abstract override void Close();
/// <summary>
/// Ensure the port is opened and ready. Idempotent. May perform device-specific
/// handshakes.
/// </summary>
public abstract ValueTask OpenAsync(CancellationToken cancellationToken = default);
// Concrete transports must implement Stream's abstract members.
// Seek-related members are typically not supported and should throw NotSupportedException.
}
}