本文整理汇总了C++中serial::Serial::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ Serial::flush方法的具体用法?C++ Serial::flush怎么用?C++ Serial::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类serial::Serial
的用法示例。
在下文中一共展示了Serial::flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
bool open() {
bool device_opened = false;
if (is_open()) {
if (debug)
std::cout << "serial already opened" << std::endl;
} else {
m_serial.setPort(m_device_port);
m_serial.setBaudrate(115200);
//serial::Timeout t(1000, 1000);
m_serial.setTimeout(serial::Timeout::simpleTimeout(2000));
m_serial.open();
// Open port
if (m_serial.isOpen()) {
m_serial.flush();
// Check if the device is well a Wattsup
if (identify()) {
m_serial.flush();
device_opened = true;
} else {
m_serial.close();
}
}
}
return device_opened;
}
示例2: handshake
bool Move::handshake(){
int counter = 0;
while(ros::ok()){
syncboard.flush();
syncboard.write("v");
std::string result = syncboard.readline();
if (result.length() > 0){
ROS_INFO("Connected to syncboard.");
return true;
}
if(counter++ > 50){
ROS_WARN_ONCE("Connecting to syncboard is taking longer than expected.");
}
ros::Rate(10).sleep();
}
ROS_WARN("Syncboard handshake failed.");
return false;
}
示例3: close
void close() {
if (m_closing) return;
m_closing = true;
if (is_open()) {
// Internal logging 600s
Packet p;
WattsupCommand::SetupInternalLogging600s(p);
write(p);
m_serial.flush();
}
m_serial.close();
m_buf_len = 0;
m_commands.clear();
m_closing = false;
//this->fileLog("Device closed ! [" + m_device_port + "]");
}