Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Parameters (get/set) #64

Open
DangerD1024 opened this issue Aug 27, 2024 · 6 comments
Open

CLI Parameters (get/set) #64

DangerD1024 opened this issue Aug 27, 2024 · 6 comments

Comments

@DangerD1024
Copy link

After staring i need first to check parameters if they are correct:
get serial_update_rate_hz if it's not 2000, set it:

set serial_update_rate_hz=2000
save

Can i achieve that somehow?

@GeorgXIII
Copy link

Hi there!

Take a look at these messages:

    MSP2_COMMON_SETTING          = 0x1003,  // in/out message, returns setting
    MSP2_COMMON_SET_SETTING      = 0x1004,  // in message, sets a setting value

@DangerD1024
Copy link
Author

Hi there!

Take a look at these messages:

    MSP2_COMMON_SETTING          = 0x1003,  // in/out message, returns setting
    MSP2_COMMON_SET_SETTING      = 0x1004,  // in message, sets a setting value

Can you point me on how can I use that?

@GeorgXIII
Copy link

I implemented it this way (for INAV 6.1 iirc):

using FlightControllerSetting = std::variant<std::string, uint8_t, int8_t, uint16_t, int16_t, uint32_t, float>;

FlightControllerSetting FlightController::getSetting(const std::string& name, msp::msg::DATA_TYPE type) const
{
    msp::msg::CommonSetting setting(m_firmwareVariant);
    setting.setting_name = name;
    setting.expected_data_type = type;
    if (!m_client->sendMessage(setting)) {
        // TODO: error handling
    }
    switch (setting.expected_data_type) {
    case msp::msg::DATA_TYPE::STRING:
        return setting.string_val;
        break;
    case msp::msg::DATA_TYPE::UINT8:
        return setting.uint8_val;
        break;
    case msp::msg::DATA_TYPE::INT8:
        return setting.int8_val;
        break;
    case msp::msg::DATA_TYPE::UINT16:
        return setting.uint16_val;
        break;
    case msp::msg::DATA_TYPE::INT16:
        return setting.int16_val;
        break;
    case msp::msg::DATA_TYPE::UINT32:
        return setting.uint32_val;
        break;
    case msp::msg::DATA_TYPE::FLOAT:
        return setting.float_val;
        break;
    }
    // TODO: error handling here
}

void FlightController::setSetting(const std::string& name, const FlightControllerSetting& value) const
{
    msp::msg::CommonSetSetting setting(m_firmwareVariant);
    setting.setting_name = name;
    if (const std::string* pval = std::get_if<std::string>(&value)) {
        setting.string_val = *pval;
    } else if (const uint8_t* pval = std::get_if<uint8_t>(&value)) {
        setting.uint8_val = *pval;
    } else if (const int8_t* pval = std::get_if<int8_t>(&value)) {
        setting.int8_val = *pval;
    } else if (const uint16_t* pval = std::get_if<uint16_t>(&value)) {
        setting.uint16_val = *pval;
    } else if (const int16_t* pval = std::get_if<int16_t>(&value)) {
        setting.int16_val = *pval;
    } else if (const uint32_t* pval = std::get_if<uint32_t>(&value)) {
        setting.uint8_val = *pval;
    } else if (const float* pval = std::get_if<float>(&value)) {
        setting.uint8_val = *pval;
    }

    if (!m_client->sendMessage(setting)) {
        // TODO: error handling here
    }
}

@DangerD1024
Copy link
Author

DangerD1024 commented Sep 20, 2024

setSetting("roll_srate",67);
How can i set "aux 1 1 1 1300 2100 0 0" ?

saveSettings();

@GeorgXIII
Copy link

If you want to set Mode range and channel, I think you should use MSP_SET_MODE_RANGE message

@DangerD1024
Copy link
Author

Betaflight 4.5 - Cannot get BoxNames! error on connect... investigating...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants