Skip to content

Commit

Permalink
main: Reduce ping interval to 250ms
Browse files Browse the repository at this point in the history
This is important for autobauding to work properly, since it expects a constant stream of data to guess the baud rate. The previous value of 5000ms was too high and caused the autobauding to fail.

Fixes #1

Co-authored-by: assada <[email protected]>
  • Loading branch information
PixelyIon and assada committed Sep 13, 2024
1 parent 4e47d87 commit efa02a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ class ElrsManager {
SetThreadName("ELRS TX");

std::chrono::time_point<std::chrono::steady_clock> wakeTime{std::chrono::steady_clock::now()}, pingTime{wakeTime};
constexpr std::chrono::milliseconds WakeInterval{100}, PingInterval{5000};
constexpr std::chrono::milliseconds WakeInterval{100}, PingInterval{250};

bool recurringException{};
while (!stopToken.stop_requested()) {
std::unique_lock lock{stateMutex};
stateCV.wait_until(lock, wakeTime > pingTime ? wakeTime : pingTime);

try {
if (pingsSinceLastRx >= 2) {
fmt::print("No packets received after two pings, resetting device\n");
if (pingsSinceLastRx >= 8) {
fmt::print("No packets received after {} pings, resetting device\n", pingsSinceLastRx);
crsfInterface.ResetDevice();
pingsSinceLastRx = 0;
earlyPing = true;
Expand Down

0 comments on commit efa02a6

Please sign in to comment.