improve compilability
This commit is contained in:
@@ -886,7 +886,12 @@ result_t SerialDevice::open() {
|
||||
// create new settings
|
||||
memset(&newSettings, 0, sizeof(newSettings));
|
||||
|
||||
#ifdef HAVE_CFSETSPEED
|
||||
cfsetspeed(&newSettings, m_enhancedProto ? (m_enhancedHighSpeed ? B115200 : B9600) : B2400);
|
||||
#else
|
||||
cfsetispeed(&newSettings, m_enhancedProto ? (m_enhancedHighSpeed ? B115200 : B9600) : B2400);
|
||||
cfsetospeed(&newSettings, m_enhancedProto ? (m_enhancedHighSpeed ? B115200 : B9600) : B2400);
|
||||
#endif
|
||||
newSettings.c_cflag |= (CS8 | CLOCAL | CREAD);
|
||||
newSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // non-canonical mode
|
||||
newSettings.c_iflag |= IGNPAR; // ignore parity errors
|
||||
@@ -924,8 +929,8 @@ void SerialDevice::close() {
|
||||
}
|
||||
|
||||
void SerialDevice::checkDevice() {
|
||||
int port;
|
||||
if (ioctl(m_fd, TIOCMGET, &port) == -1) {
|
||||
int cnt;
|
||||
if (ioctl(m_fd, FIONREAD, &cnt) == -1) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +435,7 @@ bool HttpClient::request(const string& method, const string& uri, const string&
|
||||
string headers = result.substr(0, pos+2); // including final \r\n
|
||||
const char* hdrs = headers.c_str();
|
||||
*response = result.substr(pos+4);
|
||||
#ifdef HAVE_TIME_H
|
||||
if (time) {
|
||||
pos = headers.find("\r\nLast-Modified: ");
|
||||
if (pos != string::npos && headers.substr(pos+42, 4) == " GMT") {
|
||||
@@ -474,6 +475,7 @@ bool HttpClient::request(const string& method, const string& uri, const string&
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
pos = headers.find("\r\nContent-Length: ");
|
||||
if (pos == string::npos) {
|
||||
disconnect();
|
||||
|
||||
@@ -124,11 +124,6 @@ int tcpKeepAliveInterval) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef HAVE_PPOLL
|
||||
#ifndef HAVE_PSELECT
|
||||
timeout = 0;
|
||||
#endif
|
||||
#endif
|
||||
if (tcpConnectTimeout > 0 && fcntl(sfd, F_SETFL, O_NONBLOCK) < 0) { // set non-blocking
|
||||
close(sfd);
|
||||
return -1;
|
||||
@@ -140,9 +135,15 @@ int tcpKeepAliveInterval) {
|
||||
return -1;
|
||||
}
|
||||
if (tcpConnectTimeout > 0) {
|
||||
#if defined(HAVE_PPOLL) || defined(HAVE_PSELECT)
|
||||
struct timespec tdiff;
|
||||
tdiff.tv_sec = tcpConnectTimeout;
|
||||
tdiff.tv_nsec = 0;
|
||||
#else
|
||||
struct timeval tdiff;
|
||||
tdiff.tv_sec = tcpConnectTimeout;
|
||||
tdiff.tv_usec = 0;
|
||||
#endif
|
||||
#ifdef HAVE_PPOLL
|
||||
nfds_t nfds = 1;
|
||||
struct pollfd fds[nfds];
|
||||
@@ -159,7 +160,11 @@ int tcpKeepAliveInterval) {
|
||||
FD_ZERO(&writefds);
|
||||
FD_ZERO(&exceptfds);
|
||||
FD_SET(sfd, &readfds);
|
||||
#ifdef HAVE_PSELECT
|
||||
ret = pselect(sfd + 1, &readfds, &writefds, &exceptfds, &tdiff, nullptr);
|
||||
#else
|
||||
ret = select(sfd + 1, &readfds, &writefds, &exceptfds, &tdiff);
|
||||
#endif
|
||||
if (ret >= 1 && FD_ISSET(sfd, &exceptfds)) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user