本文整理汇总了C++中SerialStream::good方法的典型用法代码示例。如果您正苦于以下问题:C++ SerialStream::good方法的具体用法?C++ SerialStream::good怎么用?C++ SerialStream::good使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerialStream
的用法示例。
在下文中一共展示了SerialStream::good方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serial_Open_Port
void Serial_Open_Port(string comPort)
{
serial_port.Open( comPort ) ;
if(! serial_port.good())
{
std::cerr<<"Error: could not open serial port"<<std::endl;
exit(1);
}
serial_port.SetBaudRate( SerialStreamBuf::BAUD_9600) ;
serial_port.SetCharSize( SerialStreamBuf::CHAR_SIZE_8 ) ;
serial_port.SetNumOfStopBits(1) ;
serial_port.SetParity( SerialStreamBuf::PARITY_EVEN ) ;
serial_port.SetFlowControl( SerialStreamBuf::FLOW_CONTROL_NONE ) ;
}
示例2: QObject
Server::Server(DomParser* _parser): QObject(0)
{
parser = _parser;
connect(&server, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
serial_port.Open(ARDUINO) ;
if ( ! serial_port.good() )
{
std::cerr << "[" << __FILE__ << ":" << __LINE__ << "] "
<< "Error: Could not open serial port."
<< std::endl ;
exit(1) ;
}
//
// Set the baud rate of the serial port.
//
serial_port.SetBaudRate( SerialStreamBuf::BAUD_9600 ) ;
if ( ! serial_port.good() )
{
std::cerr << "Error: Could not set the baud rate." <<
std::endl ;
exit(1) ;
}
//
// Set the number of data bits.
//
serial_port.SetCharSize( SerialStreamBuf::CHAR_SIZE_8 ) ;
if ( ! serial_port.good() )
{
std::cerr << "Error: Could not set the character size." <<
std::endl ;
exit(1) ;
}
//
// Disable parity.
//
serial_port.SetParity( SerialStreamBuf::PARITY_NONE ) ;
if ( ! serial_port.good() )
{
std::cerr << "Error: Could not disable the parity." <<
std::endl ;
exit(1) ;
}
//
// Set the number of stop bits.
//
serial_port.SetNumOfStopBits( 1 ) ;
if ( ! serial_port.good() )
{
std::cerr << "Error: Could not set the number of stop bits."
<< std::endl ;
exit(1) ;
}
//
// Turn off hardware flow control.
//
serial_port.SetFlowControl( SerialStreamBuf::FLOW_CONTROL_NONE ) ;
if ( ! serial_port.good() )
{
std::cerr << "Error: Could not use hardware flow control."
<< std::endl ;
exit(1) ;
}
server.listen(QHostAddress::Any, 8888);
}