From 89cd7441c184d37f90d4d5311b348e938119765f Mon Sep 17 00:00:00 2001
From: zxd <zxdvslxy@gmail.com>
Date: 星期六, 21 十月 2023 12:28:04 +0800
Subject: [PATCH] 修改最后一个单元格不会被读取的问题

---
 MTerm2/HvSerialPort.h |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/MTerm2/HvSerialPort.h b/MTerm2/HvSerialPort.h
index 7d71d47..c515eb5 100644
--- a/MTerm2/HvSerialPort.h
+++ b/MTerm2/HvSerialPort.h
@@ -2,7 +2,7 @@
 class HvSerialPort
 {
 public:
-	double GetTimeMs()
+	double GetTimemS()
 	{
 		LARGE_INTEGER perfreq;
 		LARGE_INTEGER percounter1;
@@ -30,12 +30,14 @@
 	volatile bool MyThreadProc1Running;
 
 	volatile int RecvBufDataLen = 0;
-	unsigned char * RecvBuf[2048];
+	unsigned char * RecvBuf[4096];
+	volatile int RecvBufPos = 0;
 
+	unsigned char * RecvBuf2[4096];
 	DWORD m_dwError;
 	CString m_strResult;
 	int m_nCountToTry = 5;
-	int m_nCountToWait = 0;
+	int m_nCountToWait = 1;
 
 	volatile	DWORD TotalSendBytes, TotalRecvBytes;
 	volatile	DWORD SendBytes, RecvBytes;
@@ -64,6 +66,7 @@
 	};
 	~HvSerialPort()
 	{
+		MyThreadProc1ToRun = 0;
 		if (this->m_bOpened) { this->Close(); }
 		this->hCom1 = INVALID_HANDLE_VALUE;
 
@@ -73,10 +76,6 @@
 
 public:
 	int SetParams(int nPortNum, int BaudRate, CString Settings);
-	int PurgeComBuf()
-	{
-		return	PurgeComm(hCom1, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXCLEAR);
-	}
 
 	int Open();
 	int ClearStatData();
@@ -85,8 +84,19 @@
 	int Close();
 	int SetRecvDoneCallBack(pRecvDone);
 
+	int ClearBuf();
+
 	int Send(void * pBuf, int len1);
 	int Recv(void * pBuf, int len1);
+	int RecvFromCom(void * pBuf, int len1);
+	int RecvFromBuf(void * pBuf, int len1);
+
+protected:
+	int PurgeComBuf()
+	{
+		return	PurgeComm(hCom1, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXCLEAR);
+	}
+
 
 	static UINT MyJumper1(LPVOID pParam);
 	DWORD WINAPI MyThreadProc1(LPVOID pParam);

--
Gitblit v1.9.1