本文整理汇总了C++中Serial::readStringUntil方法的典型用法代码示例。如果您正苦于以下问题:C++ Serial::readStringUntil方法的具体用法?C++ Serial::readStringUntil怎么用?C++ Serial::readStringUntil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Serial
的用法示例。
在下文中一共展示了Serial::readStringUntil方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void SerialCommunicationApp::update()
{
if (serialInitiallized()){
if(serial.getNumBytesAvailable() > 0){
console() << "Bytes available: " << serial.getNumBytesAvailable() << std::endl;
try{
lastString = serial.readStringUntil('\n');
} catch(SerialTimeoutExc e) {
console() << "timeout" << endl;
}
console() << lastString << endl;
int16_t temp = lastString[0];
//OSC MESSAGE
osc::Message message;
message.addIntArg(temp);
message.setAddress("coinTrigger");
message.setRemoteEndpoint(host, port);
sender.sendMessage(message);
TextLayout simple;
simple.setFont( Font( "Arial Black", 54 ) );
simple.setColor( Color( .7, .7, .2 ) );
simple.addLine( lastString );
simple.setLeadingOffset( 0 );
mTexture = gl::Texture( simple.render( true, false ) );
bTextureComplete = true;
serial.flush();
}
}
serial.flush();
}
示例2: update
void SerialCommunicationApp::update()
{
// console() << "Bytes available: " << serial.getNumBytesAvailable() << std::endl;
double now = getElapsedSeconds();
double deltaTime = now - lastUpdate;
lastUpdate = now;
sinceLastRead += deltaTime;
if(sinceLastRead > READ_INTERVAL)
{
bSendSerialMessage = true;
sinceLastRead = 0.0;
}
if (bSendSerialMessage)
{
// request next chunk
serial.writeByte(ctr);
try{
// read until newline, to a maximum of BUFSIZE bytes
lastString = serial.readStringUntil('\n', BUFSIZE );
} catch(SerialTimeoutExc e) {
console() << "timeout" << endl;
}
bSendSerialMessage = false;
ctr+=8;
console() << lastString << endl;
TextLayout simple;
simple.setFont( Font( "Arial Black", 24 ) );
simple.setColor( Color( .7, .7, .2 ) );
simple.addLine( lastString );
simple.setLeadingOffset( 0 );
mTexture = gl::Texture( simple.render( true, false ) );
bTextureComplete = true;
serial.flush();
}
}