Dreamine.Communication.Serial
1.0.2
Dreamine.Communication.Serial 통신 기능과 관련 API를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
SerialPortStreamAdapter.cs
이 파일의 문서화 페이지로 가기
1
using
System;
2
using
System.IO;
3
using
System.IO.Ports;
4
using
System.Threading;
5
using
System.Threading.Tasks;
6
7
namespace
Dreamine.Communication.Serial.Streams
;
8
17
public
sealed
class
SerialPortStreamAdapter
18
{
27
private
readonly SerialPort
_serialPort
;
28
53
public
SerialPortStreamAdapter
(SerialPort serialPort)
54
{
55
_serialPort
= serialPort ??
throw
new
ArgumentNullException(nameof(serialPort));
56
}
57
66
public
Stream
BaseStream
=>
_serialPort
.BaseStream;
67
108
public
async Task
WriteAsync
(
109
byte
[] buffer,
110
CancellationToken cancellationToken =
default
)
111
{
112
ArgumentNullException.ThrowIfNull(buffer);
113
await
BaseStream
.WriteAsync(buffer, cancellationToken).ConfigureAwait(
false
);
114
await
BaseStream
.FlushAsync(cancellationToken).ConfigureAwait(
false
);
115
}
116
149
public
Task<int>
ReadAsync
(
150
Memory<byte> buffer,
151
CancellationToken cancellationToken =
default
)
152
{
153
return
BaseStream
.ReadAsync(buffer, cancellationToken).AsTask();
154
}
155
}
Dreamine.Communication.Serial.Streams
Definition
SerialPortStreamAdapter.cs:7
Dreamine.Communication.Serial.Streams.SerialPortStreamAdapter.BaseStream
Stream BaseStream
Definition
SerialPortStreamAdapter.cs:66
Dreamine.Communication.Serial.Streams.SerialPortStreamAdapter.WriteAsync
async Task WriteAsync(byte[] buffer, CancellationToken cancellationToken=default)
Definition
SerialPortStreamAdapter.cs:108
Dreamine.Communication.Serial.Streams.SerialPortStreamAdapter.SerialPortStreamAdapter
SerialPortStreamAdapter(SerialPort serialPort)
Definition
SerialPortStreamAdapter.cs:53
Dreamine.Communication.Serial.Streams.SerialPortStreamAdapter._serialPort
readonly SerialPort _serialPort
Definition
SerialPortStreamAdapter.cs:27
Dreamine.Communication.Serial.Streams.SerialPortStreamAdapter.ReadAsync
Task< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default)
Definition
SerialPortStreamAdapter.cs:149
Streams
SerialPortStreamAdapter.cs
다음에 의해 생성됨 :
1.17.0