int Volkslogger::SendCommandReadBulk(Port &port, unsigned baud_rate, OperationEnvironment &env, Command cmd, uint8_t param1, void *buffer, size_t max_length, const unsigned timeout_firstchar_ms) { unsigned old_baud_rate = port.GetBaudrate(); if (old_baud_rate != 0) { if (!SendCommandSwitchBaudRate(port, env, cmd, param1, baud_rate)) return -1; /* after switching baud rates, this sleep time is necessary; it has been verified experimentally */ env.Sleep(300); } else { /* port does not support baud rate switching, use plain SendCommand() without new baud rate */ if (!SendCommand(port, env, cmd, param1)) return -1; } int nbytes = ReadBulk(port, env, buffer, max_length, timeout_firstchar_ms); if (old_baud_rate != 0) port.SetBaudrate(old_baud_rate); return nbytes; }
int Volkslogger::SendCommandReadBulk(Port &port, OperationEnvironment &env, Command cmd, void *buffer, size_t max_length, const unsigned timeout_firstchar_ms) { return SendCommand(port, env, cmd) ? ReadBulk(port, env, buffer, max_length, timeout_firstchar_ms) : -1; }
int Volkslogger::SendCommandReadBulk(Port &port, OperationEnvironment &env, Command cmd, void *buffer, size_t max_length, std::chrono::steady_clock::duration timeout_firstchar) { return SendCommand(port, env, cmd) ? ReadBulk(port, env, buffer, max_length, timeout_firstchar) : -1; }