git-svn-id: svn://db.shs.com.ru/pip@699 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -677,7 +677,7 @@ int PIEthernet::readDevice(void * read_to, int max_size) {
|
||||
s = accept(sock, (sockaddr * )&client_addr, &slen);
|
||||
if (s == -1) {
|
||||
//piCoutObj << "Can`t accept new connection, " << ethErrorString();
|
||||
msleep(1);
|
||||
msleep(PIP_MIN_MSLEEP);
|
||||
return -1;
|
||||
}
|
||||
rs = ethRecv(s, read_to, max_size);
|
||||
@@ -787,7 +787,7 @@ int PIEthernet::writeDevice(const void * data, int max_size) {
|
||||
//piCoutObj << "connect SingleTCP" << ip_s << ":" << port_s << "...";
|
||||
if (::connect(sock, (sockaddr * )&PRIVATE->addr_, sizeof(PRIVATE->addr_)) != 0) {
|
||||
//piCoutObj << "Can`t connect to " << ip_s << ":" << port_s << ", " << ethErrorString();
|
||||
msleep(1);
|
||||
msleep(PIP_MIN_MSLEEP);
|
||||
return -1;
|
||||
}
|
||||
//piCoutObj << "ok, write SingleTCP" << int(data) << max_size << "bytes ...";
|
||||
|
||||
@@ -199,7 +199,7 @@ void PIIODevice::write_func() {
|
||||
int ret = write(item.first);
|
||||
threadedWriteEvent(item.second, ret);
|
||||
}
|
||||
msleep(1);
|
||||
msleep(PIP_MIN_MSLEEP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ PIByteArray PIIODevice::readForTime(double timeout_ms) {
|
||||
tm.reset();
|
||||
while (tm.elapsed_m() < timeout_ms) {
|
||||
ret = read(td, threadedReadBufferSize());
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else str.append(td, ret);
|
||||
}
|
||||
delete[] td;
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
void start() {startThreadedRead(); startThreadedWrite();}
|
||||
|
||||
//! Stop both threaded read and threaded write and if "wait" block until both threads are stop
|
||||
void stop(bool wait = false) {stopThreadedRead(); stopThreadedWrite(); if (wait) while (write_thread.isRunning() || isRunning()) msleep(1);}
|
||||
void stop(bool wait = false) {stopThreadedRead(); stopThreadedWrite(); if (wait) while (write_thread.isRunning() || isRunning()) msleep(PIP_MIN_MSLEEP);}
|
||||
|
||||
|
||||
//! Read from device maximum "max_size" bytes to "read_to"
|
||||
|
||||
@@ -372,7 +372,7 @@ bool PISerial::read(void * data, int size, double timeout_ms) {
|
||||
while (all < size && tm_.elapsed_m() < timeout_ms) {
|
||||
ret = readDevice(&((uchar * )data)[all], size - all);
|
||||
if (ret > 0) all += ret;
|
||||
else msleep(1);
|
||||
else msleep(PIP_MIN_MSLEEP);
|
||||
}
|
||||
setOption(BlockingRead, br);
|
||||
received(data, all);
|
||||
@@ -411,13 +411,13 @@ PIString PISerial::read(int size, double timeout_ms) {
|
||||
if (size <= 0) {
|
||||
while (tm_.elapsed_m() < timeout_ms) {
|
||||
ret = readDevice(td, 1024);
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else str << PIString((char*)td, ret);
|
||||
}
|
||||
} else {
|
||||
while (all < size && tm_.elapsed_m() < timeout_ms) {
|
||||
ret = readDevice(td, size - all);
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else {
|
||||
str << PIString((char*)td, ret);
|
||||
all += ret;
|
||||
@@ -431,7 +431,7 @@ PIString PISerial::read(int size, double timeout_ms) {
|
||||
str << PIString((char*)td, all);
|
||||
while (all < size) {
|
||||
ret = readDevice(td, size - all);
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else {
|
||||
str << PIString((char*)td, ret);
|
||||
all += ret;
|
||||
@@ -463,13 +463,13 @@ PIByteArray PISerial::readData(int size, double timeout_ms) {
|
||||
if (size <= 0) {
|
||||
while (tm_.elapsed_m() < timeout_ms) {
|
||||
ret = readDevice(td, 1024);
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else str.append(td, ret);
|
||||
}
|
||||
} else {
|
||||
while (all < size && tm_.elapsed_m() < timeout_ms) {
|
||||
ret = readDevice(td, size - all);
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else {
|
||||
str.append(td, ret);
|
||||
all += ret;
|
||||
@@ -483,7 +483,7 @@ PIByteArray PISerial::readData(int size, double timeout_ms) {
|
||||
str.append(td, all);
|
||||
while (all < size) {
|
||||
ret = readDevice(td, size - all);
|
||||
if (ret <= 0) msleep(1);
|
||||
if (ret <= 0) msleep(PIP_MIN_MSLEEP);
|
||||
else {
|
||||
str.append(td, ret);
|
||||
all += ret;
|
||||
|
||||
Reference in New Issue
Block a user