|
|
@@ -174,7 +174,13 @@ char *serial_get_log_prefix(const void *hSerial)
|
|
|
int serial_send_data(const void *hSerial, const unsigned char *data, int len)
|
|
|
{
|
|
|
struct serial_t *pSerial = (struct serial_t *)hSerial;
|
|
|
- if(pSerial && pSerial->fd != -1) return write(pSerial->fd, data, len);
|
|
|
+ if(pSerial && pSerial->fd != -1)
|
|
|
+ {
|
|
|
+ int ret = write(pSerial->fd, data, len);
|
|
|
+ if(ret < 0) sw_log_error("write error(ret=%d, errno=%d, %s), \"%s\" serial port send failed!!",
|
|
|
+ ret, errno, strerror(errno), pSerial->name);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
else return -1;
|
|
|
}
|
|
|
|
|
|
@@ -293,7 +299,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_error("read one byte error(ret=%d, errno=%d), \"%s\" serial port receiving thread abort!!",
|
|
|
nRet, errno, pSerial->name);
|
|
|
return -1;
|
|
|
}
|
|
|
@@ -308,7 +314,7 @@ NoneP:
|
|
|
}
|
|
|
else if(nRet < 0 && errno != EINTR)
|
|
|
{ // 有错误发生
|
|
|
- sw_log_fatal("select error(%s), \"%s\" serial port receiving thread abort!!!", strerror(errno), pSerial->name);
|
|
|
+ sw_log_error("select error(%s), \"%s\" serial port receiving thread abort!!", strerror(errno), pSerial->name);
|
|
|
return -1;
|
|
|
}
|
|
|
else nInterval = 1; // 不满足上述组合判断条件时
|