Fix high CPU usage issue
This commit is contained in:
parent
894cde50c6
commit
987954d21a
|
@ -158,6 +158,7 @@ int waitForClient_interactive(int socket_fd)
|
||||||
SetSocketBlockingEnabled(client_fd, true);
|
SetSocketBlockingEnabled(client_fd, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sleepms(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
return client_fd;
|
return client_fd;
|
||||||
|
|
|
@ -104,6 +104,7 @@ extern int ignored_int_outputs[];
|
||||||
|
|
||||||
//main.cpp
|
//main.cpp
|
||||||
void sleep_until(struct timespec *ts, int delay);
|
void sleep_until(struct timespec *ts, int delay);
|
||||||
|
void sleepms(int milliseconds);
|
||||||
void log(unsigned char *logmsg);
|
void log(unsigned char *logmsg);
|
||||||
bool pinNotPresent(int *ignored_vector, int vector_size, int pinNumber);
|
bool pinNotPresent(int *ignored_vector, int vector_size, int pinNumber);
|
||||||
extern uint8_t run_openplc;
|
extern uint8_t run_openplc;
|
||||||
|
|
|
@ -62,6 +62,18 @@ void sleep_until(struct timespec *ts, int delay)
|
||||||
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ts, NULL);
|
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, ts, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Helper function - Makes the running thread sleep for the ammount of time
|
||||||
|
// in milliseconds
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void sleepms(int milliseconds)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = milliseconds / 1000;
|
||||||
|
ts.tv_nsec = (milliseconds % 1000) * 1000000;
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Helper function - Logs messages and print them on the console
|
// Helper function - Logs messages and print them on the console
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -150,6 +150,7 @@ int waitForClient(int socket_fd)
|
||||||
SetSocketBlockingEnabled(client_fd, true);
|
SetSocketBlockingEnabled(client_fd, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
sleepms(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
return client_fd;
|
return client_fd;
|
||||||
|
|
Loading…
Reference in New Issue