Skip to content

Releases: itas109/CSerialPort

CSerialPort V3.0.3

21 Jun 14:03
Compare
Choose a tag to compare

1.增加信号与槽机制传输数据 add sigslot.h to send data
2.修复handle初始化问题,全部初始化为INVALID_HANDLE_VALUE modify handle init INVALID_HANDLE_VALUE
3.修复串口打开失败,再次成功打开串口后,不能正常读写问题 fix can not read and write when the port open failed

CSerialPort V3.0.2

15 Jun 02:42
Compare
Choose a tag to compare

修复availablePorts函数不能枚举所有串口问题 fix function availablePorts can not enum all port error

CSerialPort V3.0.1

25 Feb 12:38
Compare
Choose a tag to compare

1.★修复不能连续发送的问题 ★ fix can not continue send error
2.★一次性写入尽可能多的数据到串口 ★ try best to send mutil data once in WriteChar funtion
3.修复BYTE内存设置的问题 fix BYTE memset error
4.在构造函数中初始化和释放临界区 initialize and delete critical section in Constructor
5.精简代码

CSerialPort V2.4

12 Mar 12:03
Compare
Choose a tag to compare

1.增加宏定义_AFX,用于处理MFC的必要函数Hkey2ComboBox
2.进一步去除MFC依赖,修改AfxMessageBox函数
3.增加Win32的程序,用于验证非MFC程序的适用性

CSerialPort V2.3

14 Feb 04:51
Compare
Choose a tag to compare

1.兼容ASCII和UNICODE编码
2.ReceiveStr函数中发送函数SendMessage的第二个参数采用结构体形式,包括portNr串口号和bytesRead读取的字节数,可以处理16进制的时候0x00截断问题
3.精简不必要的函数SendData和RecvData
4.尽量的取消对 MFC 的依赖,Hkey2ComboBox函数暂时保留
5.其他小问题修改

CSerialPort V2.2

10 Aug 06:23
Compare
Choose a tag to compare

改进ReceiveStr方法,comstat.cbInQue = 0xcccccccc的情况(如串口异常断开),会导致RXBuff初始化失败

CSerialPort V2.1

10 Aug 01:35
Compare
Choose a tag to compare

1) 改进IsOpen方法,m_hComm增加INVALID_HANDLE_VALUE的情况,因为CreateFile方法失败返回的是INVALID_HANDLE_VALUE,不是NULL
2) 改进ClosePort方法:增加串口句柄无效的判断(防止关闭死锁);m_hWriteEvent不使用CloseHandle关闭
3) 改进CommThread、ReceiveChar、ReceiveStr和WriteChar方法中异常处理的判断,增加三种判断:串口打开失败(error code:ERROR_INVALID_HANDLE)、连接过程中非法断开(error code:ERROR_BAD_COMMAND)和拒绝访问(error code:ERROR_ACCESS_DENIED)
4) 采用安全函数sprintf_s和strcpy_s函数替换掉sprintf和strcpy
5) 改进QueryKey方法,用于查询注册表的可用串口值,可以搜索到任意的可用串口
6) 改进InitPort方法,串口打开失败,增加提示信息:串口不存在(error code:ERROR_FILE_NOT_FOUND)和串口拒绝访问(error code:ERROR_ACCESS_DENIED)
7) 加入viruscamp 取消对 MFC 的依赖
8) 改进InitPort方法,如果上次串口是打开,再次调用InitPort方法,关闭串口需要做一定的延时,否则有几率导致ERROR_ACCESS_DENIED拒绝访问,也就是串口占用问题
9) 初始化默认波特率修改为9600
10)修复一些释放的BUG
11)规范了一些错误信息,参考winerror.h -- error code definitions for the Win32 API functions
12)删除SendData和RecvData方法

CSerialPort V2.0

10 Aug 01:24
Compare
Choose a tag to compare

1) 增加ReceiveStr方法,用于接收字符串(接收缓冲区有多少字符就接收多少字符)。
解决ReceiveChar只能接收单个字符的问题。
2) 解决RestartMonitoring方法和StopMonitoring方法命令不准确引起的歧义,根据实际作用。
将RestartMonitoring更改为ResumeMonitoring,将StopMonitoring更改为SuspendMonitoring。
3)增加IsThreadSuspend方法,用于判断线程是否挂起。
4) 改进ClosePort方法,增加线程挂起判断,解决由于线程挂起导致串口关闭死锁的问题。
5)增加IsReceiveString宏定义,用于接收时采用单字节接收还是多字节接收

CSerialPort V1.0

10 Aug 01:17
Compare
Choose a tag to compare
  1. 修复每次打开串口发送一次,当串口无应答时,需要关闭再打开或者接收完数据才能发送的问题。
    解决办法:在m_hEventArray中调整m_hWriteEvent的优先级高于读的优先级。CommThread(LPVOID pParam)函数中读写的位置也调换。
    参考:http://zhidao.baidu.com/link?url=RSrbPcfTZRULFFd2ziHZPBwnoXv1iCSu_Nmycb_yEw1mklT8gkoNZAkWpl3UDhk8L35DtRPo5VV5kEGpOx-Gea
  2. 修复停止位在头文件中定义成1导致SetCommState报错的问题,应为1对应的停止位是1.5。UINT stopsbits = ONESTOPBIT
  3. switch(stopbits)和switch(parity)增加默认情况,增强程序健壮性