diff --git a/cmake/Thirdparty.cmake b/cmake/Thirdparty.cmake index 8d2cce95..c81cc90e 100755 --- a/cmake/Thirdparty.cmake +++ b/cmake/Thirdparty.cmake @@ -54,7 +54,7 @@ if(WIN32) DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download PREFIX ${CMAKE_BINARY_DIR} INSTALL_DIR ${CMAKE_SOURCE_DIR} - CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/curl + CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/curl -DBUILD_TESTING=OFF SOURCE_DIR ${CMAKE_BINARY_DIR}/src/curl-lib BUILD_IN_SOURCE 1 BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release -- /maxcpucount:4 diff --git a/unit-test/util/test_tc_serialport.cpp b/unit-test/util/test_tc_serialport.cpp index abfc5b0b..e7f52b7a 100644 --- a/unit-test/util/test_tc_serialport.cpp +++ b/unit-test/util/test_tc_serialport.cpp @@ -99,7 +99,7 @@ TEST_F(UtilSerialPortTest, test) TC_SerialPort::Options options; // options.portName = "/dev/tty.usbmodem00000000050C1"; - options.portName = "COM3"; + options.portName = "//./COM14"; options.baudRate = 9600; options.stopBits = 0; diff --git a/util/src/tc_serialport.cpp b/util/src/tc_serialport.cpp index cc9bc3f3..31893330 100644 --- a/util/src/tc_serialport.cpp +++ b/util/src/tc_serialport.cpp @@ -419,6 +419,7 @@ void TC_SerialPort::initialize() { callback->onOpen(); } + } void TC_SerialPort::setParserCallback(const onparser_callback & onparser) @@ -829,8 +830,9 @@ int TC_SerialPort::send(const void *buf, uint32_t len) { int nerr = TC_Exception::getSystemCode(); string err = "send error, errno:" + TC_Common::tostr(nerr) + "," + TC_Exception::parseError(nerr); + HANDLE fd = _serialFd; close(); - throw TC_SerialPortException("TC_SerialPort::send, fd:" + TC_Common::tostr(_serialFd) + ", error:" + err); + throw TC_SerialPortException("TC_SerialPort::send, fd:" + TC_Common::tostr(fd) + ", error:" + err); } return dwBytesWritten; @@ -841,8 +843,9 @@ int TC_SerialPort::send(const void *buf, uint32_t len) { int nerr = TC_Exception::getSystemCode(); string err = "send error, errno:" + TC_Common::tostr(nerr) + "," + TC_Exception::parseError(nerr); + int fd = _serialFd; close(); - throw TC_SerialPortException("TC_SerialPort::send, fd:" + TC_Common::tostr(_serialFd) + ", error:" + err); + throw TC_SerialPortException("TC_SerialPort::send, fd:" + TC_Common::tostr(fd) + ", error:" + err); } return iRet; @@ -877,8 +880,9 @@ int TC_SerialPort::recv() { int nerr = TC_Exception::getSystemCode(); string err = "recv error, errno:" + TC_Common::tostr(nerr) + "," + TC_Exception::parseError(nerr); + HANDLE fd = _serialFd; close(); - throw TC_SerialPortException("TC_SerialPort::recv, fd:" + TC_Common::tostr(_serialFd) + ", error:" + err); + throw TC_SerialPortException("TC_SerialPort::recv, fd:" + TC_Common::tostr(fd) + ", error:" + err); } if(dwBytesRead > 0){ @@ -898,8 +902,9 @@ int TC_SerialPort::recv(void *buf, uint32_t len) { int nerr = TC_Exception::getSystemCode(); string err = "recv error, errno:" + TC_Common::tostr(nerr) + "," + TC_Exception::parseError(nerr); + int fd = _serialFd; close(); - throw TC_SerialPortException("TC_SerialPort::recv, fd:" + TC_Common::tostr(_serialFd) + ", error:" + err); + throw TC_SerialPortException("TC_SerialPort::recv, fd:" + TC_Common::tostr(fd) + ", error:" + err); } return iRet; } diff --git a/util/src/tc_socket.cpp b/util/src/tc_socket.cpp index af5b58c6..293e5401 100755 --- a/util/src/tc_socket.cpp +++ b/util/src/tc_socket.cpp @@ -1022,7 +1022,7 @@ vector TC_Socket::getLocalHosts(int domain, bool withLoopIp) bool TC_Socket::isPending() { #if TARGET_PLATFORM_WINDOWS - return TC_Exception::getSystemCode() == WSAEWOULDBLOCK; + return TC_Exception::getSystemCode() == WSAEWOULDBLOCK || TC_Exception::getSystemCode() == ERROR_IO_PENDING; #else return TC_Exception::getSystemCode() == EAGAIN; #endif @@ -1031,7 +1031,7 @@ bool TC_Socket::isPending() bool TC_Socket::isInProgress() { #if TARGET_PLATFORM_WINDOWS - return TC_Exception::getSystemCode() == WSAEWOULDBLOCK; + return TC_Exception::getSystemCode() == WSAEWOULDBLOCK || TC_Exception::getSystemCode() == ERROR_IO_PENDING; #else return TC_Exception::getSystemCode() == EINPROGRESS; #endif