stable v0.42
mavone.cpp
- 修正 status 管理 bug : 還未改變資料庫狀態 就被程式的管理列表刪除
- 新增 指定本服務於 MAVLink 上的 sysid=197, compid=254 (應該是不會特別去動態調整所以硬寫在裡面)
This commit is contained in:
+8
-1
@@ -72,6 +72,9 @@ int main(int argc, char** argv)
|
||||
|
||||
// Start MAVSDK Server and connect to it.
|
||||
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);
|
||||
if (connection_result != ConnectionResult::Success) {
|
||||
std::cerr << "(mavone.cpp:main) Connection failed: " << connection_result << '\n';
|
||||
@@ -251,6 +254,10 @@ int main(int argc, char** argv)
|
||||
// 更新 mavsys_connect_status 欄位
|
||||
sqlString = "UPDATE NodeRed_one SET mavsys_connect_status = 'Disconnected' WHERE SerialNO = " + std::to_string(handlerInfo.mysqlSN) + ";";
|
||||
stmt->execute(sqlString);
|
||||
|
||||
// 變更狀態
|
||||
handlerInfo.handlerState = systemHandlerState::Terminate;
|
||||
|
||||
// reset = true; //debug
|
||||
break;
|
||||
}
|
||||
@@ -259,7 +266,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// 刪除 Disconnected 的 handlerInfo
|
||||
for (auto it = systemHandlerInfos.begin(); it != systemHandlerInfos.end(); /* no increment here */) {
|
||||
if (it->handlerState == systemHandlerState::Disconnected) {
|
||||
if (it->handlerState == systemHandlerState::Terminate) {
|
||||
// 這個 if 如果不加 則副程序在結束以前就會被主程序放生 執行時會出現 SIGABRT 錯誤
|
||||
if (it->systemThread.joinable()) {
|
||||
it->systemThread.join();
|
||||
|
||||
@@ -47,6 +47,7 @@ enum class systemHandlerState {
|
||||
Prologue, // 建立了 mysql row 並取得 serialNo
|
||||
Ready, // 收到第一筆並放到 telemetryInfo 後
|
||||
Disconnected, // mavsdk 判斷該系統斷線了
|
||||
Terminate, // 準備要從管理列表中刪除
|
||||
// Void
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user