<commit_before>#include "QsLog.h"
#include "Radio3DRSettings.h"
#include "qserialport.h"
#include "qserialportinfo.h"

#include <QMessageBox>
#include <QTimer>

Radio3DREeprom::Radio3DREeprom():
    m_radioFreqCode(0),
    m_version(0),
    m_eepromVersion(0),
    m_serialSpeed(0),
    m_airSpeed(0),
    m_netID(0),
    m_txPower(0),
    m_ecc(0),
    m_mavlink(0),
    m_oppResend(0),
    m_minFreq(0),
    m_maxFreq(0),
    m_numChannels(0),
    m_dutyCyle(0),
    m_lbtRssi(0),
    m_manchester(0),
    m_rtsCts(0),
    m_maxWindow(0)
{

}

bool Radio3DREeprom::setParameter(QString &parameterString)
{
     QLOG_DEBUG() << "Radio3DREeprom Param:" << parameterString;
     QStringList values = parameterString.split("=", QString::SkipEmptyParts);
     bool success = false;

     if(values.length() == 0){
         QLOG_ERROR() << "Parameter String has Zero Params";
         return false;
     } else {
        success = true;
     }

     if(values[0].contains("S0:")){
         m_eepromVersion = values[1].toInt();

     } else if(values[0].contains("S1:")){
         m_serialSpeed = values[1].toInt();

     } else if(values[0].contains("S2:")){
         m_airSpeed = values[1].toInt();

     } else if(values[0].contains("S3:")){
         m_netID = values[1].toInt();

     } else if(values[0].contains("S4:")){
         m_txPower = values[1].toInt();

     } else if(values[0].contains("S5:")){
         m_ecc = values[1].toInt();

     } else if(values[0].contains("S6:")){
         m_mavlink = values[1].toInt();

     } else if(values[0].contains("S7:")){
         m_oppResend = values[1].toInt();

     } else if(values[0].contains("S8:")){
         m_minFreq = values[1].toInt();

     } else if(values[0].contains("S9:")){
         m_maxFreq = values[1].toInt();

     } else if(values[0].contains("S10:")){
         m_numChannels = values[1].toInt();

     } else if(values[0].contains("S11:")){
         m_dutyCyle = values[1].toInt();

     } else if(values[0].contains("S12:")){
         m_lbtRssi = values[1].toInt();

     } else if(values[0].contains("S13:")){
         m_manchester = values[1].toInt();

     } else if(values[0].contains("S14:")){
         m_rtsCts = values[1].toInt();

     } else if(values[0].contains("S15:")){
         m_maxWindow = values[1].toInt();
     }
     return success;
}

bool Radio3DREeprom::setVersion(const QString &versionString)
{
    QLOG_DEBUG() << "Radio3DREeprom Ver:" << versionString;
    QStringList values = versionString.split(" ", QString::SkipEmptyParts);
    if(values[0].contains("SiK")){
//        QRegExp versionEx("\\d\\*.\\d+");
//        int pos = versionEx.indexIn(versionString);
//        if (pos > -1) {
//            m_version = versionEx.cap(1).toFloat();
//        }
        QString majorMinorVersion(values[1]);
        majorMinorVersion.truncate(3); // [TODO] retrun x.n as the version for now
                                       // but this doesn't work for 1.10 and greater
                                       // Need to fix the above RegExp code to match
                                       // xx.nn (it should but doesn't
        m_version = majorMinorVersion.toFloat();

        // The number of params should be worked out from the returned ATI5 message
        // Or by using a lookup table of version to num of params.
        if (m_version < SIK_LOWLATENCY_MIN_VERSION){
            m_numberOfParams = 14;
            m_endParam = "S14";
        } else {
            m_numberOfParams = 15;
            m_endParam = "S15";<commit_msg>Fix crash when Version Parse failed with zero elements<commit_after>#include "QsLog.h"
#include "Radio3DRSettings.h"
#include "qserialport.h"
#include "qserialportinfo.h"

#include <QMessageBox>
#include <QTimer>

Radio3DREeprom::Radio3DREeprom():
    m_radioFreqCode(0),
    m_version(0),
    m_eepromVersion(0),
    m_serialSpeed(0),
    m_airSpeed(0),
    m_netID(0),
    m_txPower(0),
    m_ecc(0),
    m_mavlink(0),
    m_oppResend(0),
    m_minFreq(0),
    m_maxFreq(0),
    m_numChannels(0),
    m_dutyCyle(0),
    m_lbtRssi(0),
    m_manchester(0),
    m_rtsCts(0),
    m_maxWindow(0)
{

}

bool Radio3DREeprom::setParameter(QString &parameterString)
{
     QLOG_DEBUG() << "Radio3DREeprom Param:" << parameterString;
     QStringList values = parameterString.split("=", QString::SkipEmptyParts);
     bool success = false;

     if(values.length() == 0){
         QLOG_ERROR() << "Parameter String has Zero Params";
         return false;
     } else {
        success = true;
     }

     if(values[0].contains("S0:")){
         m_eepromVersion = values[1].toInt();

     } else if(values[0].contains("S1:")){
         m_serialSpeed = values[1].toInt();

     } else if(values[0].contains("S2:")){
         m_airSpeed = values[1].toInt();

     } else if(values[0].contains("S3:")){
         m_netID = values[1].toInt();

     } else if(values[0].contains("S4:")){
         m_txPower = values[1].toInt();

     } else if(values[0].contains("S5:")){
         m_ecc = values[1].toInt();

     } else if(values[0].contains("S6:")){
         m_mavlink = values[1].toInt();

     } else if(values[0].contains("S7:")){
         m_oppResend = values[1].toInt();

     } else if(values[0].contains("S8:")){
         m_minFreq = values[1].toInt();

     } else if(values[0].contains("S9:")){
         m_maxFreq = values[1].toInt();

     } else if(values[0].contains("S10:")){
         m_numChannels = values[1].toInt();

     } else if(values[0].contains("S11:")){
         m_dutyCyle = values[1].toInt();

     } else if(values[0].contains("S12:")){
         m_lbtRssi = values[1].toInt();

     } else if(values[0].contains("S13:")){
         m_manchester = values[1].toInt();

     } else if(values[0].contains("S14:")){
         m_rtsCts = values[1].toInt();

     } else if(values[0].contains("S15:")){
         m_maxWindow = values[1].toInt();
     }
     return success;
}

bool Radio3DREeprom::setVersion(const QString &versionString)
{
    QLOG_DEBUG() << "Radio3DREeprom Ver:" << versionString;
    QStringList values = versionString.split(" ", QString::SkipEmptyParts);

    if(values.count()>0 && values[0].contains("SiK")){
//        QRegExp versionEx("\\d\\*.\\d+");
//        int pos = versionEx.indexIn(versionString);
//        if (pos > -1) {
//            m_version = versionEx.cap(1).toFloat();
//        }
        QString majorMinorVersion(values[1]);
        majorMinorVersion.truncate(3); // [TODO] retrun x.n as the version for now
                                       // but this doesn't work for 1.10 and greater
                                       // Need to fix the above RegExp code to match
                                       // xx.nn (it should but doesn't
        m_version = majorMinorVersion.toFloat();

        // The number of params should be worked out from the returned ATI5 message
        // Or by using a lookup table of version to num of params.
        if (m_version < SIK_LOWLATENCY_MIN_VERSION){
            m_numberOfParams = 14;
            m_endParam = "S14";
        } else {
            m_numberOfParams = 15;
            m_endParam = "S15";
{'fraction_non_alphanumeric': 0.1612541993281075, 'fraction_numerical': 0.027295632698768196, 'mean_word_length': 2.4533591106814887, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5095158', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2447, 'n_words': 444}