添加项目文件。
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "link.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace ts660b
|
||||
{
|
||||
// 基于 Win32 通信 API 的串口链路。
|
||||
// 参数与 Tdg7ChlDriver 保持一致:8N1、无流控、DTR/RTS 关闭。
|
||||
class Win32ByteLink : public IByteLink
|
||||
{
|
||||
public:
|
||||
Win32ByteLink() = default;
|
||||
~Win32ByteLink() override { Close(); }
|
||||
|
||||
bool Open(const wchar_t* portName, int baudRate) override;
|
||||
void Close() override;
|
||||
bool IsOpen() const override { return handle_ != INVALID_HANDLE_VALUE; }
|
||||
|
||||
bool Write(const char* data, int length) override;
|
||||
int Read(char* buffer, int capacity, int timeoutMs) override;
|
||||
void Purge() override;
|
||||
|
||||
private:
|
||||
HANDLE handle_ = INVALID_HANDLE_VALUE;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user