代码拉取完成,页面将自动刷新
同步操作将从 jiangxiaogang/SerialTool 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "stdafx.h"
#include "UART.h"
HANDLE UART_Open(LPTSTR pzName)
{
HANDLE hUART;
COMMTIMEOUTS timeout;
char szPortName[32];
sprintf(szPortName,"\\\\.\\%s",pzName);
hUART = CreateFile(szPortName,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if((hUART==INVALID_HANDLE_VALUE)||(hUART==NULL))
{
return NULL;
}
GetCommTimeouts(hUART, &timeout);
timeout.ReadIntervalTimeout = MAXDWORD;
timeout.ReadTotalTimeoutMultiplier = 0;
timeout.ReadTotalTimeoutConstant = 0;
timeout.WriteTotalTimeoutConstant = 0;
timeout.WriteTotalTimeoutMultiplier = 0;
SetCommTimeouts(hUART,&timeout);
SetupComm(hUART, 64*1024, 0);
PurgeComm(hUART, PURGE_RXCLEAR | PURGE_TXCLEAR);
return hUART;
}
void UART_Close(HANDLE hUART)
{
CloseHandle(hUART);
}
void UART_Setup(HANDLE hUART, DWORD dwBaudRate, BYTE biDataBits, BYTE biStopBits, BYTE biParity)
{
DCB dcb;
GetCommState(hUART, &dcb);
dcb.BaudRate = dwBaudRate;
dcb.Parity = biParity;
dcb.ByteSize = biDataBits;
dcb.StopBits = biStopBits;
SetCommState(hUART, &dcb);
}
DWORD UART_Read(HANDLE hUART, void *pData, DWORD dwLen)
{
BOOL biRet;
DWORD dwRead = 0;
biRet = ReadFile(hUART,pData,dwLen,&dwRead,NULL);
return biRet?dwRead:0;
}
DWORD UART_Write(HANDLE hUART, void *pData, DWORD dwLen)
{
BOOL biRet;
DWORD dwWrite;
biRet = WriteFile(hUART,pData,dwLen,&dwWrite,NULL);
return biRet?dwWrite:0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。