bool LX::ReceivePacketRetry(Port &port, Command command, void *data, size_t length, OperationEnvironment &env, unsigned first_timeout_ms, unsigned subsequent_timeout_ms, unsigned total_timeout_ms, unsigned n_retries) { assert(n_retries > 0); while (true) { if (ReceivePacket(port, command, data, length, env, first_timeout_ms, subsequent_timeout_ms, total_timeout_ms)) return true; if (n_retries-- == 0) return false; if (!CommandMode(port, env)) return false; port.Flush(); } }
bool LX::ReceivePacketRetry(Port &port, Command command, void *data, size_t length, OperationEnvironment &env, std::chrono::steady_clock::duration first_timeout, std::chrono::steady_clock::duration subsequent_timeout, std::chrono::steady_clock::duration total_timeout, unsigned n_retries) { assert(n_retries > 0); while (true) { if (ReceivePacket(port, command, data, length, env, first_timeout, subsequent_timeout, total_timeout)) return true; if (n_retries-- == 0) return false; if (!CommandMode(port, env)) return false; port.Flush(); } }
bool CAI302Device::ClearPilot(OperationEnvironment &env) { if (!CommandMode(env)) return false; return CAI302::ClearPilot(port, env); }
bool CAI302Device::SetVolume(unsigned volume, OperationEnvironment &env) { if (!CommandMode(env)) return false; return CAI302::SetVolume(port, volume, env); }
bool CAI302Device::StopLogging(OperationEnvironment &env) { if (!CommandMode(env)) return false; return CAI302::StopLogging(port, env); }
bool CAI302Device::PowerOff(OperationEnvironment &env) { if (!CommandMode(env)) return false; return CAI302::PowerOff(port, env); }
bool CAI302::SendCommandQuick(Port &port, const char *cmd, OperationEnvironment &env) { if (!CommandMode(port, env)) return false; port.Flush(); return WriteString(port, cmd, env); }
bool CAI302Device::SetBaudRate(unsigned baud_rate, OperationEnvironment &env) { if (!CommandMode(env) || !CAI302::SetBaudRate(port, baud_rate, env) || !port.Drain()) return false; /* the CAI302 needs some time to apply the new baud rate; if we switch too early, it'll cancel the command */ env.Sleep(500); return port.SetBaudrate(baud_rate) && CAI302::CommandMode(port, env); }