FirmwarePlugin.cc 3.9 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*=====================================================================
 
 QGroundControl Open Source Ground Control Station
 
 (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 
 This file is part of the QGROUNDCONTROL project
 
 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
 
 ======================================================================*/

24
#include "FirmwarePlugin.h"
Don Gagne's avatar
Don Gagne committed
25 26 27

#include <QDebug>

28
QList<VehicleComponent*> FirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle)
Don Gagne's avatar
Don Gagne committed
29 30 31 32 33 34
{
    Q_UNUSED(vehicle);
    
    return QList<VehicleComponent*>();
}

35
QString FirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode)
Don Gagne's avatar
Don Gagne committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
{
    QString flightMode;
    
    struct Bit2Name {
        uint8_t     baseModeBit;
        const char* name;
    };
    static const struct Bit2Name rgBit2Name[] = {
        { MAV_MODE_FLAG_MANUAL_INPUT_ENABLED,   "Manual" },
        { MAV_MODE_FLAG_STABILIZE_ENABLED,      "Stabilize" },
        { MAV_MODE_FLAG_GUIDED_ENABLED,         "Guided" },
        { MAV_MODE_FLAG_AUTO_ENABLED,           "Auto" },
        { MAV_MODE_FLAG_TEST_ENABLED,           "Test" },
    };
    
    Q_UNUSED(custom_mode);
    
    if (base_mode == 0) {
        flightMode = "PreFlight";
    } else if (base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) {
        flightMode = QString("Custom:0x%1").arg(custom_mode, 0, 16);
    } else {
        for (size_t i=0; i<sizeof(rgBit2Name)/sizeof(rgBit2Name[0]); i++) {
            if (base_mode & rgBit2Name[i].baseModeBit) {
                if (i != 0) {
                    flightMode += " ";
                }
                flightMode += rgBit2Name[i].name;
            }
        }
    }
    
    return flightMode;
}

71
bool FirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode)
Don Gagne's avatar
Don Gagne committed
72 73 74 75 76
{
    Q_UNUSED(flightMode);
    Q_UNUSED(base_mode);
    Q_UNUSED(custom_mode);
    
77
    qWarning() << "FirmwarePlugin::setFlightMode called on base class, not supported";
Don Gagne's avatar
Don Gagne committed
78 79 80
    
    return false;
}
81

82
int FirmwarePlugin::manualControlReservedButtonCount(void)
83 84 85 86 87
{
    // We don't know whether the firmware is going to used any of these buttons.
    // So reserve them all.
    return -1;
}
Don Gagne's avatar
Don Gagne committed
88

89
void FirmwarePlugin::adjustMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message)
Don Gagne's avatar
Don Gagne committed
90
{
91
    Q_UNUSED(vehicle);
Don Gagne's avatar
Don Gagne committed
92 93 94 95
    Q_UNUSED(message);
    
    // Generic plugin does no message adjustment
}
96

97
void FirmwarePlugin::initializeVehicle(Vehicle* vehicle)
98 99 100 101 102
{
    Q_UNUSED(vehicle);
    
    // Generic Flight Stack is by definition "generic", so no extra work
}
103

104
bool FirmwarePlugin::sendHomePositionToVehicle(void)
105 106 107 108 109 110
{
    // Generic stack does not want home position sent in the first position.
    // Subsequent sequence numbers must be adjusted.
    // This is the mavlink spec default.
    return false;
}
111

112
QList<MAV_CMD> FirmwarePlugin::supportedMissionCommands(void)
Don Gagne's avatar
Don Gagne committed
113 114 115 116
{
    // Generic supports all commands
    return QList<MAV_CMD>();
}
117

118
void FirmwarePlugin::missionCommandOverrides(QString& commonJsonFilename, QString& fixedWingJsonFilename, QString& multiRotorJsonFilename) const
119 120 121 122 123 124
{
    // No overrides
    commonJsonFilename.clear();
    fixedWingJsonFilename.clear();
    multiRotorJsonFilename.clear();
}
125 126 127 128 129 130 131

void FirmwarePlugin::getParameterMetaDataVersionInfo(const QString& metaDataFile, int& majorVersion, int& minorVersion)
{
    Q_UNUSED(metaDataFile);
    majorVersion = -1;
    minorVersion = -1;
}