diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 8185d21e6daccf3fa4362f521522201d2c1fe9af..2dee93140b8f79b5eae01c7d86bda73d7dee9b24 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -661,10 +661,20 @@ void UAS::requestParameters() sendMessage(msg); } -void UAS::writeParameters() +void UAS::writeParametersToStorage() { - //mavlink_message_t msg; - qDebug() << __FILE__ << __LINE__ << __func__ << "IS NOT IMPLEMENTED!"; + mavlink_message_t msg; + // TODO Replace MG System ID with static function call and allow to change ID in GUI + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(),MAV_COMP_ID_IMU, (uint8_t)MAV_ACTION_STORAGE_WRITE); + sendMessage(msg); +} + +void UAS::readParametersFromStorage() +{ + mavlink_message_t msg; + // TODO Replace MG System ID with static function call and allow to change ID in GUI + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU,(uint8_t)MAV_ACTION_STORAGE_READ); + sendMessage(msg); } void UAS::enableAllDataTransmission(bool enabled) @@ -929,7 +939,7 @@ void UAS::launch() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(),(uint8_t)MAV_ACTION_LAUNCH); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (uint8_t)MAV_ACTION_LAUNCH); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -943,7 +953,7 @@ void UAS::enable_motors() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(),(uint8_t)MAV_ACTION_MOTORS_START); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (uint8_t)MAV_ACTION_MOTORS_START); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -957,7 +967,7 @@ void UAS::disable_motors() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(),(uint8_t)MAV_ACTION_MOTORS_STOP); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (uint8_t)MAV_ACTION_MOTORS_STOP); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -1069,7 +1079,7 @@ void UAS::halt() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), (int)MAV_ACTION_HALT); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_HALT); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -1079,7 +1089,7 @@ void UAS::go() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), (int)MAV_ACTION_CONTINUE); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_CONTINUE); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -1090,7 +1100,7 @@ void UAS::home() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), (int)MAV_ACTION_RETURN); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_RETURN); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -1104,7 +1114,7 @@ void UAS::emergencySTOP() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), (int)MAV_ACTION_EMCY_LAND); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_EMCY_LAND); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -1135,7 +1145,7 @@ bool UAS::emergencyKILL() { mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), (int)MAV_ACTION_EMCY_KILL); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_EMCY_KILL); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); @@ -1164,7 +1174,7 @@ void UAS::shutdown() // If the active UAS is set, execute command mavlink_message_t msg; // TODO Replace MG System ID with static function call and allow to change ID in GUI - mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), (int)MAV_ACTION_SHUTDOWN); + mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU,(int)MAV_ACTION_SHUTDOWN); // Send message twice to increase chance of reception sendMessage(msg); sendMessage(msg); diff --git a/src/uas/UAS.h b/src/uas/UAS.h index 88cb4027b1709a413eb1784bc58d01d270c14b9a..37e82e1173ad5a34531f387b895874e2799f0cd7 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -200,7 +200,9 @@ public slots: void setParameter(int component, QString id, float value); /** @brief Write parameters to permanent storage */ - void writeParameters(); + void writeParametersToStorage(); + /** @brief Read parameters from permanent storage */ + void readParametersFromStorage(); void enableAllDataTransmission(bool enabled); void enableRawSensorDataTransmission(bool enabled); diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index a21c4ee4d8934595b8bb4f7e19d7a74c67b201a4..3662f6b93171bfa26eaef969e72b14f7bbcc9ca2 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -173,7 +173,9 @@ public slots: /** @brief Request all onboard parameters of all components */ virtual void requestParameters() = 0; /** @brief Write parameter to permanent storage */ - virtual void writeParameters() = 0; + virtual void writeParametersToStorage() = 0; + /** @brief Read parameter from permanent storage */ + virtual void readParametersFromStorage() = 0; /** @brief Set a system parameter * @param component ID of the system component to write the parameter to * @param id String identifying the parameter diff --git a/src/ui/QGCParamWidget.cc b/src/ui/QGCParamWidget.cc index 2975442500bcefedce231136fc88ee692f21fa4e..aaf08d03a33e48689eab26432e04156ef0e0dadd 100644 --- a/src/ui/QGCParamWidget.cc +++ b/src/ui/QGCParamWidget.cc @@ -64,18 +64,22 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) : horizontalLayout->setSizeConstraint(QLayout::SetMinimumSize); horizontalLayout->addWidget(tree, 0, 0, 1, 3); - QPushButton* readButton = new QPushButton(tr("Read")); - connect(readButton, SIGNAL(clicked()), this, SLOT(requestParameterList())); - horizontalLayout->addWidget(readButton, 1, 0); + QPushButton* refreshButton = new QPushButton(tr("Refresh")); + connect(refreshButton, SIGNAL(clicked()), this, SLOT(requestParameterList())); + horizontalLayout->addWidget(refreshButton, 1, 0); - QPushButton* setButton = new QPushButton(tr("Set (RAM)")); + QPushButton* setButton = new QPushButton(tr("Transmit")); connect(setButton, SIGNAL(clicked()), this, SLOT(setParameters())); horizontalLayout->addWidget(setButton, 1, 1); - QPushButton* writeButton = new QPushButton(tr("Write (Disk)")); + QPushButton* writeButton = new QPushButton(tr("Write (ROM)")); connect(writeButton, SIGNAL(clicked()), this, SLOT(writeParameters())); horizontalLayout->addWidget(writeButton, 1, 2); + QPushButton* readButton = new QPushButton(tr("Read (ROM)")); + connect(readButton, SIGNAL(clicked()), this, SLOT(readParameters())); + horizontalLayout->addWidget(readButton, 2, 2); + QPushButton* loadFileButton = new QPushButton(tr("Load File")); connect(loadFileButton, SIGNAL(clicked()), this, SLOT(loadParameters())); horizontalLayout->addWidget(loadFileButton, 2, 0); @@ -432,7 +436,12 @@ void QGCParamWidget::setParameters() */ void QGCParamWidget::writeParameters() { - mav->writeParameters(); + mav->writeParametersToStorage(); +} + +void QGCParamWidget::readParameters() +{ + mav->readParametersFromStorage(); } /** diff --git a/src/ui/QGCParamWidget.h b/src/ui/QGCParamWidget.h index 871a987a627b3376998461a8bd6a20b208ca51d8..c688216e60b2aa52ca14b6d9866045dac3edd44e 100644 --- a/src/ui/QGCParamWidget.h +++ b/src/ui/QGCParamWidget.h @@ -65,6 +65,8 @@ public slots: void setParameters(); /** @brief Write the current parameters to permanent storage (EEPROM/HDD) */ void writeParameters(); + /** @brief Read the parameters from permanent storage to RAM */ + void readParameters(); /** @brief Clear the parameter list */ void clear(); /** @brief Update when user changes parameters */