本文整理汇总了C++中Port::GetBaudrate方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::GetBaudrate方法的具体用法?C++ Port::GetBaudrate怎么用?C++ Port::GetBaudrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::GetBaudrate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: memset
bool
IMI::Connect(Port &port, OperationEnvironment &env)
{
if (_connected)
return true;
memset(&_info, 0, sizeof(_info));
_serialNumber = 0;
MessageParser::Reset();
// check connectivity
if (!Send(port, env, MSG_CFG_HELLO) || env.IsCancelled())
return false;
const TMsg *msg = Receive(port, env, 100, 0);
if (!msg || msg->msgID != MSG_CFG_HELLO || env.IsCancelled())
return false;
_serialNumber = msg->sn;
// configure baudrate
unsigned baudRate = port.GetBaudrate();
if (baudRate == 0)
return false;
if (!Send(port, env,
MSG_CFG_STARTCONFIG, 0, 0, IMICOMM_BIGPARAM1(baudRate),
IMICOMM_BIGPARAM2(baudRate)) || env.IsCancelled())
return false;
// get device info
for (unsigned i = 0; i < 4; i++) {
if (!Send(port, env, MSG_CFG_DEVICEINFO))
continue;
if (env.IsCancelled())
return false;
const TMsg *msg = Receive(port, env, 300, sizeof(TDeviceInfo));
if (!msg || env.IsCancelled())
return false;
if (msg->msgID != MSG_CFG_DEVICEINFO)
continue;
if (msg->payloadSize == sizeof(TDeviceInfo)) {
memcpy(&_info, msg->payload, sizeof(TDeviceInfo));
} else if (msg->payloadSize == 16) {
// old version of the structure
memset(&_info, 0, sizeof(TDeviceInfo));
memcpy(&_info, msg->payload, 16);
} else {
return false;
}
_connected = true;
return true;
}
return false;
}