|
|
@@ -41,7 +41,7 @@ struct serial_t
|
|
|
static int serial_data_recv_proc(unsigned long wParam, unsigned long lParam);
|
|
|
|
|
|
/* 打开串口(8个数据位1个停止位), NULL失败, NOT NULL成功 */
|
|
|
-void *serial_open(const char *serialName, int baudrate, const char *parityCheck /* "odd"-奇校检; "even"-偶校检; NULL或其它无效值-无校检 */, \
|
|
|
+void *serial_open(const char *serialName, int baudrate, const char *parityCheck /* "odd"-奇校检; "even"-偶校检; NULL或其它无效值-无校检 */,
|
|
|
PSerialRecvHandler pRecvHandler, PSerialIdleHandler pIdleHandler, void *pUserData)
|
|
|
{
|
|
|
struct serial_t *pSerial;
|
|
|
@@ -212,7 +212,7 @@ void serial_printf_recv_buffer(const void *hSerial, int logLevel)
|
|
|
if(pSerial)
|
|
|
{
|
|
|
pSerial->pLogRecvBuf[0] = '\0'; // 复位日志缓存
|
|
|
- sprintf(pSerial->pLogRecvBuf, "%s the received buffer has %d bytes (hex)", \
|
|
|
+ sprintf(pSerial->pLogRecvBuf, "%s the received buffer has %d bytes (hex)",
|
|
|
pSerial->log_prefix, pSerial->nRecvBytes);
|
|
|
if(pSerial->nRecvBytes > 0) { strcat(pSerial->pLogRecvBuf, ":\n");
|
|
|
xstrfromhex(pSerial->recvBuf, pSerial->nRecvBytes, pSerial->pLogRecvBuf, NULL, NULL); }
|
|
|
@@ -282,7 +282,7 @@ NoneP:
|
|
|
{ // 串口有数据
|
|
|
if(pSerial->nRecvBytes >= nRecvBufSize)
|
|
|
{ // 判断接收缓存是否溢出
|
|
|
- sw_log_warn("\"%s\" serial port receiving buffer overflow, the earliest one byte(%02x) will discard!", \
|
|
|
+ sw_log_warn("\"%s\" serial port receiving buffer overflow, the earliest one byte(%02x) will discard!",
|
|
|
pSerial->name, pSerial->recvBuf[0]);
|
|
|
memmove(pSerial->recvBuf, pSerial->recvBuf+1, nRecvBufSize-1); // 丢弃最早的一个字节
|
|
|
pSerial->nRecvBytes = nRecvBufSize-1; // 新的已接收字节数
|
|
|
@@ -293,7 +293,7 @@ NoneP:
|
|
|
else if(nRet == 0 && errno == ETIMEDOUT) goto NoneP; // 读数据超时
|
|
|
else
|
|
|
{ // 读一个字节错误
|
|
|
- sw_log_fatal("read one byte error(ret=%d, errno=%d), \"%s\" serial port receiving thread abort!!!", \
|
|
|
+ sw_log_fatal("read one byte error(ret=%d, errno=%d), \"%s\" serial port receiving thread abort!!!",
|
|
|
nRet, errno, pSerial->name);
|
|
|
return -1;
|
|
|
}
|