本文整理汇总了C++中UARTClass::startCommunicate方法的典型用法代码示例。如果您正苦于以下问题:C++ UARTClass::startCommunicate方法的具体用法?C++ UARTClass::startCommunicate怎么用?C++ UARTClass::startCommunicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UARTClass
的用法示例。
在下文中一共展示了UARTClass::startCommunicate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendToWeb
// UART DATA To Raspberry
// Raspberry To Web
void SendToWeb() {
UARTClass * uart = UARTClass::getInstance();
uart->setup();
uart->startCommunicate();
while (true) {
try {
ClientSocket client("218.150.181.154", 10000);
while (true) {
try {
client << uart->getMsg(); // 웹으로 메세지 보내기
//cout << uart->getMsg() << endl;
uart->clear();
}
catch (SocketException& e) {
cout << "Exception was caught: " << e.description() << "\n";
}
delay(1000); // 10sec
}
}
catch (SocketException& e) {
cout << "ClientSocket Constructor Exception" << e.description() << endl;
}
delay(100);
}
}
示例2: main
int main() {
UARTClass * uart = UARTClass::getInstance();
AltitudeController *altiCon = AltitudeController::getInstance();
UltrasonicClass *sonar = UltrasonicClass::getInstance();
DroneController *drone = DroneController::getInstance();
uart->setup();
uart->startCommunicate();
// *************** ( ^_^ )*****************
thread serverTh([&]() { RecvFromWeb(); });
serverTh.detach();
//thread clientTh([&]() { SendToWeb(); });
//clientTh.detach();
// *****************************************
delay(3000);
while (1) {
uart->SendSerial(drone->get_pwm_string());
cout << "throttle : " << drone->get_pwm(droneControlType::throttle) << endl;
if (is_takeoff) {
altiCon->calculate();
}
delay(100);
}
return 0;
}