Permalink
Browse files

reduced CPU load for WINX86 interface utilizing TrhoughSerial strategy

  • Loading branch information...
Girgitt committed Jul 2, 2017
1 parent 7a61550 commit bfe935c68413c1a1ef4d5f986f03895fb45b5c1c
Showing with 4 additions and 2 deletions.
  1. +1 −1 interfaces/WINX86/PJON_WINX86_Interface.h
  2. +3 −1 strategies/ThroughSerial/ThroughSerial.h
@@ -67,7 +67,7 @@
std::chrono::high_resolution_clock::now() - begin_ts
).count();
if(elapsed_usec >= delay_value) break;
std::this_thread::sleep_for(std::chrono::microseconds(1));
std::this_thread::sleep_for(std::chrono::microseconds(50));
}
};
@@ -85,12 +85,14 @@ class ThroughSerial {
uint16_t receive_byte(uint32_t time_out = TS_BYTE_TIME_OUT) {
uint32_t time = PJON_MICROS();
while((uint32_t)(PJON_MICROS() - time) < time_out)
while((uint32_t)(PJON_MICROS() - time) < time_out) {
if(PJON_SERIAL_AVAILABLE(serial)) {
_last_reception_time = PJON_MICROS();
uint16_t read = (uint8_t)PJON_SERIAL_READ(serial);
if(read >= 0) return read;
}
delayMicroseconds(time_out / 10);
}
return PJON_FAIL;
};

0 comments on commit bfe935c

Please sign in to comment.