抛弃GdCpp*.dll/pdb历史重新建库。libhv和Sqlite的dll保留
This commit is contained in:
40
staticOnly/KsMFC/ComPortTools.h
Normal file
40
staticOnly/KsMFC/ComPortTools.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
// ----- 串口常用函数 -----------
|
||||
struct sComPort{
|
||||
int port=0; // 串口编号
|
||||
std::wstring portName; // 串口名称
|
||||
|
||||
// 默认构造函数
|
||||
sComPort() = default;
|
||||
// 复制构造函数
|
||||
sComPort(const sComPort& other)
|
||||
: port(other.port), portName(other.portName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
/// 查找串口列表,返回串口号列表
|
||||
/// @param name 串口名字必须包含的字符串,例如:CH340。如果为nullptr或""则返回所有串口
|
||||
void COM_InitPortList(std::vector<sComPort> &ports, const wchar_t * name);
|
||||
|
||||
#ifdef _AFXDLL
|
||||
// 搜索所有串口,名称添加到ComboBox,整形串口号绑定到每一个选项的data里。
|
||||
// 如果列表不为空,且defaultCom在列表中,则自动选中,否则选择第一项
|
||||
void COM_PortListToCombo(const std::vector<sComPort>& ports, CComboBox* Box, int defaultCom);
|
||||
|
||||
// 刷新串口列表。
|
||||
// 如果之前选中的串口还在,自动选择
|
||||
// 如果之前选中的串口不在了,自动选择第一项
|
||||
void COM_RefreshPortList (const wchar_t* name, CComboBox* Box);
|
||||
|
||||
int COM_GetSelectedPort (CComboBox* Box);
|
||||
void COM_InitBaudList (const int* List, int Num, int default_val, CComboBox* Box);
|
||||
void COM_InitBaudList(const std::vector<uint32_t>& List, int default_val, CComboBox* Box);
|
||||
#endif
|
||||
Reference in New Issue
Block a user