diff --git a/libs/qtandroidserialport/src/qserialportinfo_android.cpp b/libs/qtandroidserialport/src/qserialportinfo_android.cpp index 569be0c24f46ecff6de98405d84a6ec7e740407d..63fbcb3c44eced37068597b54a4ca17f72b77166 100644 --- a/libs/qtandroidserialport/src/qserialportinfo_android.cpp +++ b/libs/qtandroidserialport/src/qserialportinfo_android.cpp @@ -50,6 +50,8 @@ static const char V_TAG[] {"QGC_QSerialPortInfo"}; extern void cleanJavaException(); +static int gErrorCount = 0; + QList availablePortsByFiltersOfDevices(bool &ok) { QList serialPortInfoList; @@ -61,9 +63,15 @@ QList availablePortsByFiltersOfDevices(bool &ok) "()[Ljava/lang/String;"); if (!resultL.isValid()) { - __android_log_print(ANDROID_LOG_ERROR, V_TAG, "Error from availableDevicesInfo"); + //-- If 5 consecutive errors, ignore it. + if(gErrorCount < 5) { + gErrorCount++; + __android_log_print(ANDROID_LOG_ERROR, V_TAG, "Error from availableDevicesInfo"); + } ok = false; return serialPortInfoList; + } else { + gErrorCount = 0; } QAndroidJniEnvironment envL;