本文整理汇总了C++中Port::SetBaudrate方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::SetBaudrate方法的具体用法?C++ Port::SetBaudrate怎么用?C++ Port::SetBaudrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::SetBaudrate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendCommand
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;
}
示例2: DeclareInner
bool
EWDevice::Declare(const struct Declaration &declaration,
OperationEnvironment &env)
{
lLastBaudrate = port->SetBaudrate(9600L); // change to IO Mode baudrate
port->SetRxTimeout(500); // set RX timeout to 500[ms]
bool success = DeclareInner(declaration, env);
port->Write("NMEA\r\n"); // switch to NMEA mode
port->SetBaudrate(lLastBaudrate); // restore baudrate
return success;
}
示例3: if
/**
* Cancel pass-through mode on the LX1600. This command was provided
* by Crtomir Rojnik (LX Navigation) in an email. It must always be
* sent at 4800 baud. After this command has been sent, we switch
* back to the "real" baud rate.
*/
static bool
ModeLX1600(Port &port, OperationEnvironment &env)
{
unsigned old_baud_rate = port.GetBaudrate();
if (old_baud_rate == 4800)
old_baud_rate = 0;
else if (!port.SetBaudrate(4800))
return false;
const bool success = PortWriteNMEA(port, "PFLX0,LX1600", env);
if (old_baud_rate != 0)
port.SetBaudrate(old_baud_rate);
return success;
}
示例4: GetBaudRateIndex
bool
Volkslogger::SendCommandSwitchBaudRate(Port &port, OperationEnvironment &env,
Command cmd, uint8_t param1,
unsigned baud_rate)
{
int baud_rate_index = GetBaudRateIndex(baud_rate);
if (baud_rate_index < 0)
return false;
if (!SendCommand(port, env, cmd, param1, baud_rate_index))
return false;
return port.SetBaudrate(baud_rate);
}