Fixed long sleep, over 1s.

This commit is contained in:
Lucas Hartmann
2021-09-11 23:07:02 -03:00
parent eb3e22d810
commit a7ba2d3faf
3 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -62,11 +62,12 @@ void glueVars()
void updateTime()
{
__CURRENT_TIME.tv_nsec += common_ticktime__;
__CURRENT_TIME.tv_sec += common_ticktime__ / 1000000000;
__CURRENT_TIME.tv_nsec += common_ticktime__ % 1000000000;
if (__CURRENT_TIME.tv_nsec >= 1000000000)
{
__CURRENT_TIME.tv_nsec -= 1000000000;
__CURRENT_TIME.tv_sec += 1;
}
}
}
+1 -1
View File
@@ -111,7 +111,7 @@ extern int ignored_int_inputs[];
extern int ignored_int_outputs[];
//main.cpp
void sleep_until(struct timespec *ts, int delay);
void sleep_until(struct timespec *ts, long long delay);
void sleepms(int milliseconds);
void log(unsigned char *logmsg);
bool pinNotPresent(int *ignored_vector, int vector_size, int pinNumber);
+3 -2
View File
@@ -53,9 +53,10 @@ int log_counter = 0;
// Helper function - Makes the running thread sleep for the ammount of time
// in milliseconds
//-----------------------------------------------------------------------------
void sleep_until(struct timespec *ts, int delay)
void sleep_until(struct timespec *ts, long long delay)
{
ts->tv_nsec += delay;
ts->tv_sec += delay / (1000*1000*1000);
ts->tv_nsec += delay % (1000*1000*1000);
if(ts->tv_nsec >= 1000*1000*1000)
{
ts->tv_nsec -= 1000*1000*1000;