|
|
|
@ -72,6 +72,9 @@ int main(int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
|
|
// Start MAVSDK Server and connect to it.
|
|
|
|
// Start MAVSDK Server and connect to it.
|
|
|
|
Mavsdk mavsdk;
|
|
|
|
Mavsdk mavsdk;
|
|
|
|
|
|
|
|
// Set this MAVLINK service has system id 197, component id 254, NOT send heartbeat
|
|
|
|
|
|
|
|
mavsdk::Mavsdk::Configuration mavserver_configuration(197,254,false);
|
|
|
|
|
|
|
|
mavsdk.set_configuration(mavserver_configuration);
|
|
|
|
ConnectionResult connection_result = mavsdk.add_any_connection(initSetting.connectPort);
|
|
|
|
ConnectionResult connection_result = mavsdk.add_any_connection(initSetting.connectPort);
|
|
|
|
if (connection_result != ConnectionResult::Success) {
|
|
|
|
if (connection_result != ConnectionResult::Success) {
|
|
|
|
std::cerr << "(mavone.cpp:main) Connection failed: " << connection_result << '\n';
|
|
|
|
std::cerr << "(mavone.cpp:main) Connection failed: " << connection_result << '\n';
|
|
|
|
@ -251,6 +254,10 @@ int main(int argc, char** argv)
|
|
|
|
// 更新 mavsys_connect_status 欄位
|
|
|
|
// 更新 mavsys_connect_status 欄位
|
|
|
|
sqlString = "UPDATE NodeRed_one SET mavsys_connect_status = 'Disconnected' WHERE SerialNO = " + std::to_string(handlerInfo.mysqlSN) + ";";
|
|
|
|
sqlString = "UPDATE NodeRed_one SET mavsys_connect_status = 'Disconnected' WHERE SerialNO = " + std::to_string(handlerInfo.mysqlSN) + ";";
|
|
|
|
stmt->execute(sqlString);
|
|
|
|
stmt->execute(sqlString);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 變更狀態
|
|
|
|
|
|
|
|
handlerInfo.handlerState = systemHandlerState::Terminate;
|
|
|
|
|
|
|
|
|
|
|
|
// reset = true; //debug
|
|
|
|
// reset = true; //debug
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -259,7 +266,7 @@ int main(int argc, char** argv)
|
|
|
|
|
|
|
|
|
|
|
|
// 刪除 Disconnected 的 handlerInfo
|
|
|
|
// 刪除 Disconnected 的 handlerInfo
|
|
|
|
for (auto it = systemHandlerInfos.begin(); it != systemHandlerInfos.end(); /* no increment here */) {
|
|
|
|
for (auto it = systemHandlerInfos.begin(); it != systemHandlerInfos.end(); /* no increment here */) {
|
|
|
|
if (it->handlerState == systemHandlerState::Disconnected) {
|
|
|
|
if (it->handlerState == systemHandlerState::Terminate) {
|
|
|
|
// 這個 if 如果不加 則副程序在結束以前就會被主程序放生 執行時會出現 SIGABRT 錯誤
|
|
|
|
// 這個 if 如果不加 則副程序在結束以前就會被主程序放生 執行時會出現 SIGABRT 錯誤
|
|
|
|
if (it->systemThread.joinable()) {
|
|
|
|
if (it->systemThread.joinable()) {
|
|
|
|
it->systemThread.join();
|
|
|
|
it->systemThread.join();
|
|
|
|
|