mFrame
載入中...
搜尋中...
無符合項目
SerialPort.h
1
7#ifndef MFRAME_6C0D897F_A9B6_4BE3_B3C0_796AF2C77F10
8#define MFRAME_6C0D897F_A9B6_4BE3_B3C0_796AF2C77F10
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../../hal/serial/UART.h"
16#include "./../io/Closeable.h"
17#include "./../io/SimpleInputStream.h"
18#include "./../io/SimpleOutputStream.h"
19#include "./../lang/Object.h"
20
21//----------------------------------------------------------------------------------------
22
23/* ***************************************************************************************
24 * Namespace
25 */
26namespace ufm::io {
27 class SerialPort;
28} // namespace ufm::io
29
30/* ***************************************************************************************
31 * Class/Interface/Struct/Enum
32 */
33
43 /* *************************************************************************************
44 * Class
45 */
46 public:
57 /* ***********************************************************************************
58 * Variable
59 */
60
61 private:
62 hal::serial::UART& vBase;
63
64 /* ***********************************************************************************
65 * Abstract Method
66 */
67
68 /* ***********************************************************************************
69 * Construct Method
70 */
71 public:
78
82 virtual ~InputStream(void) override;
83
84 /* ***********************************************************************************
85 * Operator Method
86 */
87
88 /* ***********************************************************************************
89 * Override - ufm::io::SimpleInputStream
90 */
91 public:
98 virtual bool abortRead(void) override;
99
111 virtual bool read(ufm::lang::Appendable& appendable,
112 void* attachment,
113 ufm::io::CompletionHandler<int>* handler) override;
114
115 /* ***********************************************************************************
116 * Override - hal::serial::UARTEventReceiver
117 */
118 public:
126 virtual bool onReceiver(const uint8 data) override;
127
128 /* ***********************************************************************************
129 * Public Method
130 */
131
132 /* ***********************************************************************************
133 * Protected Method
134 */
135
136 /* ***********************************************************************************
137 * Private Method
138 */
139
140 /* ***********************************************************************************
141 * Static Variable
142 */
143
144 /* ***********************************************************************************
145 * Static Method
146 */
147 };
148
149 /* *************************************************************************************
150 * Class
151 */
152 public:
163 /* ***********************************************************************************
164 * Variable
165 */
166 private:
167 hal::serial::UART& vBase;
168
169 /* ***********************************************************************************
170 * Abstract Method
171 */
172
173 /* ***********************************************************************************
174 * Construct Method
175 */
176 public:
183
187 virtual ~OutputStream(void) override;
188
189 /* ***********************************************************************************
190 * Operator Method
191 */
192
193 /* ***********************************************************************************
194 * Override - ufm::io::OutputStream
195 */
196 public:
203 virtual bool abortWrite(void) override;
204
216 virtual bool write(ufm::lang::Readable& readable,
217 void* attachment,
218 ufm::io::CompletionHandler<int>* handler) override;
219
220 /* ***********************************************************************************
221 * Override - hal::serial::UARTEventTransfer
222 */
223 public:
231 virtual bool onTransfer(uint8& data) override;
232
233 /* ***********************************************************************************
234 * Public Method
235 */
236
237 /* ***********************************************************************************
238 * Protected Method
239 */
240
241 /* ***********************************************************************************
242 * Private Method
243 */
244
245 /* ***********************************************************************************
246 * Static Variable
247 */
248
249 /* ***********************************************************************************
250 * Static Method
251 */
252 };
253
254 /* *************************************************************************************
255 * Variable
256 */
257
258 private:
259 hal::serial::UART& vBase;
262
263 /* *************************************************************************************
264 * Abstract Method
265 */
266
267 /* *************************************************************************************
268 * Construct Method
269 */
270 public:
277
281 virtual ~SerialPort(void) override;
282
283 /* *************************************************************************************
284 * Operator Method
285 */
286
293 return this->vInputStream;
294 }
295
302 return this->vOutputStream;
303 }
304
305 /* *************************************************************************************
306 * Override Method - ufm::lang::Closeable
307 */
308 public:
309 virtual void close(void) override;
310
311 virtual bool isOpen(void) override;
312
313 /* *************************************************************************************
314 * Public Method
315 */
316 public:
323 virtual bool open(void);
324
331 virtual uint32 setBaudrate(uint32 baudrate);
332
338 virtual uint32 getBaudrate(void);
339
346
353
354 /* *************************************************************************************
355 * Protected Method
356 */
357
358 /* *************************************************************************************
359 * Private Method
360 */
361
362 /* *************************************************************************************
363 * Static Variable
364 */
365
366 /* *************************************************************************************
367 * Static Method
368 */
369};
370
371/* ***************************************************************************************
372 * End of file
373 */
374
375#endif /* MFRAME_6C0D897F_A9B6_4BE3_B3C0_796AF2C77F10 */
序列埠輸入串流類別
Definition SerialPort.h:56
virtual bool abortRead(void) override
中止當前進行中的讀取操作
virtual bool read(ufm::lang::Appendable &appendable, void *attachment, ufm::io::CompletionHandler< int > *handler) override
非同步讀取資料到指定的可附加物件
virtual ~InputStream(void) override
解構序列埠輸入串流
virtual bool onReceiver(const uint8 data) override
處理UART接收到的數據
InputStream(hal::serial::UART &base)
建構序列埠輸入串流
序列埠輸出串流類別
Definition SerialPort.h:162
OutputStream(hal::serial::UART &base)
建構序列埠輸出串流
virtual ~OutputStream(void) override
解構序列埠輸出串流
virtual bool write(ufm::lang::Readable &readable, void *attachment, ufm::io::CompletionHandler< int > *handler) override
非同步寫入資料到輸出目標
virtual bool abortWrite(void) override
中止當前進行中的寫入操作
virtual bool onTransfer(uint8 &data) override
當需要傳輸資料時調用此方法
序列埠通訊類別
Definition SerialPort.h:42
SerialPort(hal::serial::UART &base)
建構序列埠物件
virtual ~SerialPort(void) override
解構序列埠物件
virtual bool open(void)
開啟通道
virtual uint32 setBaudrate(uint32 baudrate)
設定串列埠傳輸速率
virtual ufm::io::OutputStream & getOutputStream(void)
取得輸出資料流
virtual uint32 getBaudrate(void)
取得當前串列埠傳輸速率
virtual void close(void) override
關閉通道
virtual bool isOpen(void) override
通道是否被開啟
virtual ufm::io::InputStream & getInputStream(void)
取得輸入資料流
簡易輸入串流實現,支援非同步讀取操作
Definition SimpleInputStream.h:42
簡易輸出串流實現,支援非同步寫入操作
Definition SimpleOutputStream.h:41
物件基底類別
Definition Object.h:63
Definition Buffer.h:24
UART接收事件監聽器介面
Definition UART.h:113
[Interface] UART傳輸事件處理器
Definition UART.h:136
UART硬體抽象層介面
Definition UART.h:38
提供關閉和檢查通道狀態的方法。
Definition io/Closeable.h:36
[Interface] 非同步操作完成事件處理器模板介面
Definition CompletionHandler.h:42
[Interface] 定義了輸入流的基本操作
Definition InputStream.h:37
[Interface] 提供輸出串流的基本操作方法
Definition OutputStream.h:37
資料附加介面 (Appendable)
Definition Appendable.h:43
[Interface] 定義資料讀取介面
Definition Readable.h:46