From: SnickerSun Date: Fri, 28 Nov 2025 16:22:40 +0000 (+0800) Subject: 测试流程除了gpio都可以执行下去。 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=c3e54418509c950138c3151ab84a3a29b372bdfd;p=mirrors%2Ffactory_tool.git 测试流程除了gpio都可以执行下去。 --- diff --git a/HiBTMacWriteTool.pro b/HiBTMacWriteTool.pro index 8b97794..d209f58 100644 --- a/HiBTMacWriteTool.pro +++ b/HiBTMacWriteTool.pro @@ -21,7 +21,8 @@ SOURCES += main.cpp\ sqldbmanager.cpp \ settings.cpp \ dialogsettings.cpp \ - test_port_controller.cpp + test_port_controller.cpp \ + json_settings.cpp HEADERS += mainwindow.h \ mythread.h \ @@ -32,7 +33,8 @@ HEADERS += mainwindow.h \ sqldbmanager.h \ settings.h \ dialogsettings.h \ - test_port_controller.h + test_port_controller.h \ + json_settings.h #HEADERS += ui_mac_settings.h \ # ui_mainwindow.h diff --git a/build/CMakeFiles/3.30.2/CMakeRCCompiler.cmake b/build/CMakeFiles/3.30.2/CMakeRCCompiler.cmake new file mode 100644 index 0000000..f7f4557 --- /dev/null +++ b/build/CMakeFiles/3.30.2/CMakeRCCompiler.cmake @@ -0,0 +1,6 @@ +set(CMAKE_RC_COMPILER "D:/mingw64/bin/windres.exe") +set(CMAKE_RC_COMPILER_ARG1 "") +set(CMAKE_RC_COMPILER_LOADED 1) +set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC) +set(CMAKE_RC_OUTPUT_EXTENSION .obj) +set(CMAKE_RC_COMPILER_ENV_VAR "RC") diff --git a/build/CMakeFiles/3.30.2/CMakeSystem.cmake b/build/CMakeFiles/3.30.2/CMakeSystem.cmake new file mode 100644 index 0000000..306e632 --- /dev/null +++ b/build/CMakeFiles/3.30.2/CMakeSystem.cmake @@ -0,0 +1,15 @@ +set(CMAKE_HOST_SYSTEM "Windows-10.0.22631") +set(CMAKE_HOST_SYSTEM_NAME "Windows") +set(CMAKE_HOST_SYSTEM_VERSION "10.0.22631") +set(CMAKE_HOST_SYSTEM_PROCESSOR "AMD64") + + + +set(CMAKE_SYSTEM "Windows-10.0.22631") +set(CMAKE_SYSTEM_NAME "Windows") +set(CMAKE_SYSTEM_VERSION "10.0.22631") +set(CMAKE_SYSTEM_PROCESSOR "AMD64") + +set(CMAKE_CROSSCOMPILING "FALSE") + +set(CMAKE_SYSTEM_LOADED 1) diff --git a/build/CMakeFiles/3.30.2/CompilerIdCXX/CMakeCXXCompilerId.cpp b/build/CMakeFiles/3.30.2/CompilerIdCXX/CMakeCXXCompilerId.cpp new file mode 100644 index 0000000..bfb90d1 --- /dev/null +++ b/build/CMakeFiles/3.30.2/CompilerIdCXX/CMakeCXXCompilerId.cpp @@ -0,0 +1,919 @@ +/* This source file must have a .cpp extension so that all C++ compilers + recognize the extension without flags. Borland does not know .cxx for + example. */ +#ifndef __cplusplus +# error "A C compiler has been selected for C++." +#endif + +#if !defined(__has_include) +/* If the compiler does not have __has_include, pretend the answer is + always no. */ +# define __has_include(x) 0 +#endif + + +/* Version number components: V=Version, R=Revision, P=Patch + Version date components: YYYY=Year, MM=Month, DD=Day */ + +#if defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# if defined(__GNUC__) +# define SIMULATE_ID "GNU" +# endif + /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, + except that a few beta releases use the old format with V=2021. */ +# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif +# else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) + /* The third version component from --version is an update index, + but no macro is provided for it. */ +# define COMPILER_VERSION_PATCH DEC(0) +# endif +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) +# endif +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER) +# define COMPILER_ID "IntelLLVM" +#if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +#endif +#if defined(__GNUC__) +# define SIMULATE_ID "GNU" +#endif +/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and + * later. Look for 6 digit vs. 8 digit version number to decide encoding. + * VVVV is no smaller than the current year when a version is released. + */ +#if __INTEL_LLVM_COMPILER < 1000000L +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10) +#else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) +#endif +#if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +#endif +#if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +#elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +#endif +#if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +#endif +#if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +#endif + +#elif defined(__PATHCC__) +# define COMPILER_ID "PathScale" +# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) +# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) +# endif + +#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) +# define COMPILER_ID "Embarcadero" +# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) +# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) +# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + /* __BORLANDC__ = 0xVRR */ +# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) +# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) + +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__WATCOMC__) +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__SUNPRO_CC) +# define COMPILER_ID "SunPro" +# if __SUNPRO_CC >= 0x5100 + /* __SUNPRO_CC = 0xVRRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) +# endif + +#elif defined(__HP_aCC) +# define COMPILER_ID "HP" + /* __HP_aCC = VVRRPP */ +# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) +# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) + +#elif defined(__DECCXX) +# define COMPILER_ID "Compaq" + /* __DECCXX_VER = VVRRTPPPP */ +# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) +# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) +# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) + +#elif defined(__IBMCPP__) && defined(__COMPILER_VER__) +# define COMPILER_ID "zOS" + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) + +#elif defined(__open_xl__) && defined(__clang__) +# define COMPILER_ID "IBMClang" +# define COMPILER_VERSION_MAJOR DEC(__open_xl_version__) +# define COMPILER_VERSION_MINOR DEC(__open_xl_release__) +# define COMPILER_VERSION_PATCH DEC(__open_xl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__) + + +#elif defined(__ibmxl__) && defined(__clang__) +# define COMPILER_ID "XLClang" +# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) +# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) +# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) + + +#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 +# define COMPILER_ID "XL" + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) + +#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 +# define COMPILER_ID "VisualAge" + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) + +#elif defined(__NVCOMPILER) +# define COMPILER_ID "NVHPC" +# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__) +# if defined(__NVCOMPILER_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__) +# endif + +#elif defined(__PGI) +# define COMPILER_ID "PGI" +# define COMPILER_VERSION_MAJOR DEC(__PGIC__) +# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) +# endif + +#elif defined(__clang__) && defined(__cray__) +# define COMPILER_ID "CrayClang" +# define COMPILER_VERSION_MAJOR DEC(__cray_major__) +# define COMPILER_VERSION_MINOR DEC(__cray_minor__) +# define COMPILER_VERSION_PATCH DEC(__cray_patchlevel__) +# define COMPILER_VERSION_INTERNAL_STR __clang_version__ + + +#elif defined(_CRAYC) +# define COMPILER_ID "Cray" +# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) +# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) + +#elif defined(__TI_COMPILER_VERSION__) +# define COMPILER_ID "TI" + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) +# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) +# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) + +#elif defined(__CLANG_FUJITSU) +# define COMPILER_ID "FujitsuClang" +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# define COMPILER_VERSION_INTERNAL_STR __clang_version__ + + +#elif defined(__FUJITSU) +# define COMPILER_ID "Fujitsu" +# if defined(__FCC_version__) +# define COMPILER_VERSION __FCC_version__ +# elif defined(__FCC_major__) +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# endif +# if defined(__fcc_version) +# define COMPILER_VERSION_INTERNAL DEC(__fcc_version) +# elif defined(__FCC_VERSION) +# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION) +# endif + + +#elif defined(__ghs__) +# define COMPILER_ID "GHS" +/* __GHS_VERSION_NUMBER = VVVVRP */ +# ifdef __GHS_VERSION_NUMBER +# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) +# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) +# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) +# endif + +#elif defined(__TASKING__) +# define COMPILER_ID "Tasking" + # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000) + # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100) +# define COMPILER_VERSION_INTERNAL DEC(__VERSION__) + +#elif defined(__ORANGEC__) +# define COMPILER_ID "OrangeC" +# define COMPILER_VERSION_MAJOR DEC(__ORANGEC_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__ORANGEC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__ORANGEC_PATCHLEVEL__) + +#elif defined(__SCO_VERSION__) +# define COMPILER_ID "SCO" + +#elif defined(__ARMCC_VERSION) && !defined(__clang__) +# define COMPILER_ID "ARMCC" +#if __ARMCC_VERSION >= 1000000 + /* __ARMCC_VERSION = VRRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#else + /* __ARMCC_VERSION = VRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#endif + + +#elif defined(__clang__) && defined(__apple_build_version__) +# define COMPILER_ID "AppleClang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) + +#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) +# define COMPILER_ID "ARMClang" + # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100) +# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) + +#elif defined(__clang__) && defined(__ti__) +# define COMPILER_ID "TIClang" + # define COMPILER_VERSION_MAJOR DEC(__ti_major__) + # define COMPILER_VERSION_MINOR DEC(__ti_minor__) + # define COMPILER_VERSION_PATCH DEC(__ti_patchlevel__) +# define COMPILER_VERSION_INTERNAL DEC(__ti_version__) + +#elif defined(__clang__) +# define COMPILER_ID "Clang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif + +#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__)) +# define COMPILER_ID "LCC" +# define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100) +# define COMPILER_VERSION_MINOR DEC(__LCC__ % 100) +# if defined(__LCC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__) +# endif +# if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define SIMULATE_ID "GNU" +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif +# endif + +#elif defined(__GNUC__) || defined(__GNUG__) +# define COMPILER_ID "GNU" +# if defined(__GNUC__) +# define COMPILER_VERSION_MAJOR DEC(__GNUC__) +# else +# define COMPILER_VERSION_MAJOR DEC(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + /* _MSC_VER = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) +# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) +# endif + +#elif defined(_ADI_COMPILER) +# define COMPILER_ID "ADSP" +#if defined(__VERSIONNUM__) + /* __VERSIONNUM__ = 0xVVRRPPTT */ +# define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF) +# define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF) +# define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF) +# define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF) +#endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# define COMPILER_ID "IAR" +# if defined(__VER__) && defined(__ICCARM__) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) +# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) +# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__)) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) +# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) +# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# endif + + +/* These compilers are either not known or too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; +#ifdef SIMULATE_ID +char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; +#endif + +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto[]"; +#endif + +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) +char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; +#endif + +#define STRINGIFY_HELPER(X) #X +#define STRINGIFY(X) STRINGIFY_HELPER(X) + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__MSYS__) +# define PLATFORM_ID "MSYS" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU__) +# define PLATFORM_ID "Haiku" + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#elif defined(__WATCOMC__) +# if defined(__LINUX__) +# define PLATFORM_ID "Linux" + +# elif defined(__DOS__) +# define PLATFORM_ID "DOS" + +# elif defined(__OS2__) +# define PLATFORM_ID "OS2" + +# elif defined(__WINDOWS__) +# define PLATFORM_ID "Windows3x" + +# elif defined(__VXWORKS__) +# define PLATFORM_ID "VxWorks" + +# else /* unknown platform */ +# define PLATFORM_ID +# endif + +#elif defined(__INTEGRITY) +# if defined(INT_178B) +# define PLATFORM_ID "Integrity178" + +# else /* regular Integrity */ +# define PLATFORM_ID "Integrity" +# endif + +# elif defined(_ADI_COMPILER) +# define PLATFORM_ID "ADSP" + +#else /* unknown platform */ +# define PLATFORM_ID + +#endif + +/* For windows compilers MSVC and Intel we can determine + the architecture of the compiler being used. This is because + the compilers do not have flags that can change the architecture, + but rather depend on which compiler is being used +*/ +#if defined(_WIN32) && defined(_MSC_VER) +# if defined(_M_IA64) +# define ARCHITECTURE_ID "IA64" + +# elif defined(_M_ARM64EC) +# define ARCHITECTURE_ID "ARM64EC" + +# elif defined(_M_X64) || defined(_M_AMD64) +# define ARCHITECTURE_ID "x64" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# elif defined(_M_ARM64) +# define ARCHITECTURE_ID "ARM64" + +# elif defined(_M_ARM) +# if _M_ARM == 4 +# define ARCHITECTURE_ID "ARMV4I" +# elif _M_ARM == 5 +# define ARCHITECTURE_ID "ARMV5I" +# else +# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) +# endif + +# elif defined(_M_MIPS) +# define ARCHITECTURE_ID "MIPS" + +# elif defined(_M_SH) +# define ARCHITECTURE_ID "SHx" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__WATCOMC__) +# if defined(_M_I86) +# define ARCHITECTURE_ID "I86" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# if defined(__ICCARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__ICCRX__) +# define ARCHITECTURE_ID "RX" + +# elif defined(__ICCRH850__) +# define ARCHITECTURE_ID "RH850" + +# elif defined(__ICCRL78__) +# define ARCHITECTURE_ID "RL78" + +# elif defined(__ICCRISCV__) +# define ARCHITECTURE_ID "RISCV" + +# elif defined(__ICCAVR__) +# define ARCHITECTURE_ID "AVR" + +# elif defined(__ICC430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__ICCV850__) +# define ARCHITECTURE_ID "V850" + +# elif defined(__ICC8051__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__ICCSTM8__) +# define ARCHITECTURE_ID "STM8" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__ghs__) +# if defined(__PPC64__) +# define ARCHITECTURE_ID "PPC64" + +# elif defined(__ppc__) +# define ARCHITECTURE_ID "PPC" + +# elif defined(__ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__x86_64__) +# define ARCHITECTURE_ID "x64" + +# elif defined(__i386__) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__clang__) && defined(__ti__) +# if defined(__ARM_ARCH) +# define ARCHITECTURE_ID "Arm" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__TI_COMPILER_VERSION__) +# if defined(__TI_ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__MSP430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__TMS320C28XX__) +# define ARCHITECTURE_ID "TMS320C28x" + +# elif defined(__TMS320C6X__) || defined(_TMS320C6X) +# define ARCHITECTURE_ID "TMS320C6x" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +# elif defined(__ADSPSHARC__) +# define ARCHITECTURE_ID "SHARC" + +# elif defined(__ADSPBLACKFIN__) +# define ARCHITECTURE_ID "Blackfin" + +#elif defined(__TASKING__) + +# if defined(__CTC__) || defined(__CPTC__) +# define ARCHITECTURE_ID "TriCore" + +# elif defined(__CMCS__) +# define ARCHITECTURE_ID "MCS" + +# elif defined(__CARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__CARC__) +# define ARCHITECTURE_ID "ARC" + +# elif defined(__C51__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__CPCP__) +# define ARCHITECTURE_ID "PCP" + +# else +# define ARCHITECTURE_ID "" +# endif + +#else +# define ARCHITECTURE_ID +#endif + +/* Convert integer to decimal digit literals. */ +#define DEC(n) \ + ('0' + (((n) / 10000000)%10)), \ + ('0' + (((n) / 1000000)%10)), \ + ('0' + (((n) / 100000)%10)), \ + ('0' + (((n) / 10000)%10)), \ + ('0' + (((n) / 1000)%10)), \ + ('0' + (((n) / 100)%10)), \ + ('0' + (((n) / 10)%10)), \ + ('0' + ((n) % 10)) + +/* Convert integer to hex digit literals. */ +#define HEX(n) \ + ('0' + ((n)>>28 & 0xF)), \ + ('0' + ((n)>>24 & 0xF)), \ + ('0' + ((n)>>20 & 0xF)), \ + ('0' + ((n)>>16 & 0xF)), \ + ('0' + ((n)>>12 & 0xF)), \ + ('0' + ((n)>>8 & 0xF)), \ + ('0' + ((n)>>4 & 0xF)), \ + ('0' + ((n) & 0xF)) + +/* Construct a string literal encoding the version number. */ +#ifdef COMPILER_VERSION +char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; + +/* Construct a string literal encoding the version number components. */ +#elif defined(COMPILER_VERSION_MAJOR) +char const info_version[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', + COMPILER_VERSION_MAJOR, +# ifdef COMPILER_VERSION_MINOR + '.', COMPILER_VERSION_MINOR, +# ifdef COMPILER_VERSION_PATCH + '.', COMPILER_VERSION_PATCH, +# ifdef COMPILER_VERSION_TWEAK + '.', COMPILER_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct a string literal encoding the internal version number. */ +#ifdef COMPILER_VERSION_INTERNAL +char const info_version_internal[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', + 'i','n','t','e','r','n','a','l','[', + COMPILER_VERSION_INTERNAL,']','\0'}; +#elif defined(COMPILER_VERSION_INTERNAL_STR) +char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; +#endif + +/* Construct a string literal encoding the version number components. */ +#ifdef SIMULATE_VERSION_MAJOR +char const info_simulate_version[] = { + 'I', 'N', 'F', 'O', ':', + 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', + SIMULATE_VERSION_MAJOR, +# ifdef SIMULATE_VERSION_MINOR + '.', SIMULATE_VERSION_MINOR, +# ifdef SIMULATE_VERSION_PATCH + '.', SIMULATE_VERSION_PATCH, +# ifdef SIMULATE_VERSION_TWEAK + '.', SIMULATE_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; +char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; + + + +#define CXX_STD_98 199711L +#define CXX_STD_11 201103L +#define CXX_STD_14 201402L +#define CXX_STD_17 201703L +#define CXX_STD_20 202002L +#define CXX_STD_23 202302L + +#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) +# if _MSVC_LANG > CXX_STD_17 +# define CXX_STD _MSVC_LANG +# elif _MSVC_LANG == CXX_STD_17 && defined(__cpp_aggregate_paren_init) +# define CXX_STD CXX_STD_20 +# elif _MSVC_LANG > CXX_STD_14 && __cplusplus > CXX_STD_17 +# define CXX_STD CXX_STD_20 +# elif _MSVC_LANG > CXX_STD_14 +# define CXX_STD CXX_STD_17 +# elif defined(__INTEL_CXX11_MODE__) && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# elif defined(__INTEL_CXX11_MODE__) +# define CXX_STD CXX_STD_11 +# else +# define CXX_STD CXX_STD_98 +# endif +#elif defined(_MSC_VER) && defined(_MSVC_LANG) +# if _MSVC_LANG > __cplusplus +# define CXX_STD _MSVC_LANG +# else +# define CXX_STD __cplusplus +# endif +#elif defined(__NVCOMPILER) +# if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) +# define CXX_STD CXX_STD_20 +# else +# define CXX_STD __cplusplus +# endif +#elif defined(__INTEL_COMPILER) || defined(__PGI) +# if __cplusplus == CXX_STD_11 && defined(__cpp_namespace_attributes) +# define CXX_STD CXX_STD_17 +# elif __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# else +# define CXX_STD __cplusplus +# endif +#elif (defined(__IBMCPP__) || defined(__ibmxl__)) && defined(__linux__) +# if __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# else +# define CXX_STD __cplusplus +# endif +#elif __cplusplus == 1 && defined(__GXX_EXPERIMENTAL_CXX0X__) +# define CXX_STD CXX_STD_11 +#else +# define CXX_STD __cplusplus +#endif + +const char* info_language_standard_default = "INFO" ":" "standard_default[" +#if CXX_STD > CXX_STD_23 + "26" +#elif CXX_STD > CXX_STD_20 + "23" +#elif CXX_STD > CXX_STD_17 + "20" +#elif CXX_STD > CXX_STD_14 + "17" +#elif CXX_STD > CXX_STD_11 + "14" +#elif CXX_STD >= CXX_STD_11 + "11" +#else + "98" +#endif +"]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif +#ifdef COMPILER_VERSION_INTERNAL + require += info_version_internal[argc]; +#endif +#ifdef SIMULATE_ID + require += info_simulate[argc]; +#endif +#ifdef SIMULATE_VERSION_MAJOR + require += info_simulate_version[argc]; +#endif +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) + require += info_cray[argc]; +#endif + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; + (void)argv; + return require; +} diff --git a/build/CMakeFiles/3.30.2/CompilerIdCXX/a.out b/build/CMakeFiles/3.30.2/CompilerIdCXX/a.out new file mode 100644 index 0000000..d7c1609 Binary files /dev/null and b/build/CMakeFiles/3.30.2/CompilerIdCXX/a.out differ diff --git a/build/CMakeFiles/CMakeConfigureLog.yaml b/build/CMakeFiles/CMakeConfigureLog.yaml new file mode 100644 index 0000000..0f033ba --- /dev/null +++ b/build/CMakeFiles/CMakeConfigureLog.yaml @@ -0,0 +1,133 @@ + +--- +events: + - + kind: "message-v1" + backtrace: + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeDetermineSystem.cmake:205 (message)" + - "CMakeLists.txt:3 (project)" + message: | + The system is: Windows - 10.0.22631 - AMD64 + - + kind: "message-v1" + backtrace: + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeDetermineCompilerId.cmake:17 (message)" + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeDetermineCompilerId.cmake:64 (__determine_compiler_id_test)" + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeDetermineCXXCompiler.cmake:126 (CMAKE_DETERMINE_COMPILER_ID)" + - "CMakeLists.txt:3 (project)" + message: | + Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. + Compiler: D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/clang++.exe + Build flags: + Id flags: + + The output was: + 0 + + + Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" + + The CXX compiler identification is Clang, found in: + D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/3.30.2/CompilerIdCXX/a.out + + - + kind: "try_compile-v1" + backtrace: + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeDetermineCompilerABI.cmake:74 (try_compile)" + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)" + - "CMakeLists.txt:3 (project)" + checks: + - "Detecting CXX compiler ABI info" + directories: + source: "D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-j5rkd9" + binary: "D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-j5rkd9" + cmakeVariables: + CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS: "CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND" + CMAKE_CXX_FLAGS: "" + CMAKE_CXX_SCAN_FOR_MODULES: "OFF" + CMAKE_EXE_LINKER_FLAGS: "" + buildResult: + variable: "CMAKE_CXX_ABI_COMPILED" + cached: true + stdout: | + Change Dir: 'D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-j5rkd9' + + Run Build Command(s): D:/esp32-tools/tools/ninja/1.12.1/ninja.exe -v cmTC_86c92 + [1/2] D:\\esp32-tools\\tools\\esp-clang\\esp-19.1.2_20250312\\esp-clang\\bin\\clang++.exe -v -MD -MT CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj -MF CMakeFiles\\cmTC_86c92.dir\\CMakeCXXCompilerABI.cpp.obj.d -o CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj -c D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeCXXCompilerABI.cpp + clang version 19.1.2 (https://github.com/espressif/llvm-project.git esp-19.1.2_20250312) + Target: riscv32-esp-unknown-elf + Thread model: posix + InstalledDir: D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin + (in-process) + "D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/clang++.exe" -cc1 -triple riscv32-esp-unknown-elf -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -nostdsysteminc -target-cpu generic-rv32 -target-feature +m -target-feature +a -target-feature +c -target-feature +zmmul -target-feature -b -target-feature -d -target-feature -e -target-feature -f -target-feature -h -target-feature -shcounterenw -target-feature -shgatpa -target-feature -shtvala -target-feature -shvsatpa -target-feature -shvstvala -target-feature -shvstvecd -target-feature -smaia -target-feature -smcdeleg -target-feature -smcsrind -target-feature -smepmp -target-feature -smstateen -target-feature -ssaia -target-feature -ssccfg -target-feature -ssccptr -target-feature -sscofpmf -target-feature -sscounterenw -target-feature -sscsrind -target-feature -ssstateen -target-feature -ssstrict -target-feature -sstc -target-feature -sstvala -target-feature -sstvecd -target-feature -ssu64xl -target-feature -svade -target-feature -svadu -target-feature -svbare -target-feature -svinval -target-feature -svnapot -target-feature -svpbmt -target-feature -v -target-feature -xcvalu -target-feature -xcvbi -target-feature -xcvbitmanip -target-feature -xcvelw -target-feature -xcvmac -target-feature -xcvmem -target-feature -xcvsimd -target-feature -xesppie -target-feature -xsfcease -target-feature -xsfvcp -target-feature -xsfvfnrclipxfqf -target-feature -xsfvfwmaccqqq -target-feature -xsfvqmaccdod -target-feature -xsfvqmaccqoq -target-feature -xsifivecdiscarddlone -target-feature -xsifivecflushdlone -target-feature -xtheadba -target-feature -xtheadbb -target-feature -xtheadbs -target-feature -xtheadcmo -target-feature -xtheadcondmov -target-feature -xtheadfmemidx -target-feature -xtheadmac -target-feature -xtheadmemidx -target-feature -xtheadmempair -target-feature -xtheadsync -target-feature -xtheadvdot -target-feature -xventanacondops -target-feature -xwchc -target-feature -za128rs -target-feature -za64rs -target-feature -zaamo -target-feature -zabha -target-feature -zalrsc -target-feature -zama16b -target-feature -zawrs -target-feature -zba -target-feature -zbb -target-feature -zbc -target-feature -zbkb -target-feature -zbkc -target-feature -zbkx -target-feature -zbs -target-feature -zca -target-feature -zcb -target-feature -zcd -target-feature -zce -target-feature -zcf -target-feature -zcmop -target-feature -zcmp -target-feature -zcmt -target-feature -zdinx -target-feature -zfa -target-feature -zfbfmin -target-feature -zfh -target-feature -zfhmin -target-feature -zfinx -target-feature -zhinx -target-feature -zhinxmin -target-feature -zic64b -target-feature -zicbom -target-feature -zicbop -target-feature -zicboz -target-feature -ziccamoa -target-feature -ziccif -target-feature -zicclsm -target-feature -ziccrse -target-feature -zicntr -target-feature -zicond -target-feature -zicsr -target-feature -zifencei -target-feature -zihintntl -target-feature -zihintpause -target-feature -zihpm -target-feature -zimop -target-feature -zk -target-feature -zkn -target-feature -zknd -target-feature -zkne -target-feature -zknh -target-feature -zkr -target-feature -zks -target-feature -zksed -target-feature -zksh -target-feature -zkt -target-feature -ztso -target-feature -zvbb -target-feature -zvbc -target-feature -zve32f -target-feature -zve32x -target-feature -zve64d -target-feature -zve64f -target-feature -zve64x -target-feature -zvfbfmin -target-feature -zvfbfwma -target-feature -zvfh -target-feature -zvfhmin -target-feature -zvkb -target-feature -zvkg -target-feature -zvkn -target-feature -zvknc -target-feature -zvkned -target-feature -zvkng -target-feature -zvknha -target-feature -zvknhb -target-feature -zvks -target-feature -zvksc -target-feature -zvksed -target-feature -zvksg -target-feature -zvksh -target-feature -zvkt -target-feature -zvl1024b -target-feature -zvl128b -target-feature -zvl16384b -target-feature -zvl2048b -target-feature -zvl256b -target-feature -zvl32768b -target-feature -zvl32b -target-feature -zvl4096b -target-feature -zvl512b -target-feature -zvl64b -target-feature -zvl65536b -target-feature -zvl8192b -target-feature -experimental-smmpm -target-feature -experimental-smnpm -target-feature -experimental-ssnpm -target-feature -experimental-sspm -target-feature -experimental-ssqosid -target-feature -experimental-supm -target-feature -experimental-zacas -target-feature -experimental-zalasr -target-feature -experimental-zicfilp -target-feature -experimental-zicfiss -target-feature +relax -target-abi ilp32 -msmall-data-limit 8 -debugger-tuning=gdb -fdebug-compilation-dir=D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-j5rkd9 -v -fcoverage-compilation-dir=D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-j5rkd9 -resource-dir D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/lib/clang/19 -dependency-file "CMakeFiles\\\\cmTC_86c92.dir\\\\CMakeCXXCompilerABI.cpp.obj.d" -MT CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj -sys-header-deps -internal-isystem D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/include/c++/14.2.0 -internal-isystem D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/include/c++/14.2.0 -internal-isystem D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/lib/clang/19/include -internal-isystem D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/include -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj -x c++ D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeCXXCompilerABI.cpp + clang -cc1 version 19.1.2 based upon LLVM 19.1.2 default target riscv32-esp-elf + ignoring duplicate directory "D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/lib/clang/19/include" + #include "..." search starts here: + #include <...> search starts here: + D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/include/c++/14.2.0 + D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/include/c++/14.2.0 + D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/lib/clang/19/include + D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/include\x0d + End of search list.\x0d + [2/2] C:\\windows\\system32\\cmd.exe /C "cd . && D:\\esp32-tools\\tools\\esp-clang\\esp-19.1.2_20250312\\esp-clang\\bin\\clang++.exe -v -Wl,-v CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_86c92.exe -Wl,--out-implib,libcmTC_86c92.dll.a -Wl,--major-image-version,0,--minor-image-version,0 && cd ." + FAILED: cmTC_86c92.exe + C:\\windows\\system32\\cmd.exe /C "cd . && D:\\esp32-tools\\tools\\esp-clang\\esp-19.1.2_20250312\\esp-clang\\bin\\clang++.exe -v -Wl,-v CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj -o cmTC_86c92.exe -Wl,--out-implib,libcmTC_86c92.dll.a -Wl,--major-image-version,0,--minor-image-version,0 && cd ." + clang version 19.1.2 (https://github.com/espressif/llvm-project.git esp-19.1.2_20250312) + Target: riscv32-esp-unknown-elf + Thread model: posix + InstalledDir: D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin + "D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/ld.lld" -m elf32lriscv -o cmTC_86c92.exe -X D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/lib/crt0.o -v CMakeFiles/cmTC_86c92.dir/CMakeCXXCompilerABI.cpp.obj --out-implib libcmTC_86c92.dll.a --major-image-version 0 --minor-image-version 0 -LD:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/lib -lstdc++ -lm --start-group -lc -lgloss -lnosys --end-group D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/../lib/clang-runtimes/riscv32-esp-unknown-elf/rv32imac-zicsr-zifencei_ilp32/lib/libclang_rt.builtins.a + ld.lld: error: unknown argument '--major-image-version' + ld.lld: error: unknown argument '--minor-image-version' + LLD 19.1.2 (compatible with GNU linkers) + ld.lld: error: cannot open 0: No such file or directory + ld.lld: error: cannot open 0: No such file or directory\x0d + clang++: error: ld command failed with exit code 1 (use -v to see invocation)\x0d + ninja: build stopped: subcommand failed. + + exitCode: 1 + - + kind: "try_compile-v1" + backtrace: + - "D:/esp32-tools/tools/cmake/3.30.2/share/cmake-3.30/Modules/CMakeTestCXXCompiler.cmake:56 (try_compile)" + - "CMakeLists.txt:3 (project)" + checks: + - "Check for working CXX compiler: D:/esp32-tools/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/clang++.exe" + directories: + source: "D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-dsu2ax" + binary: "D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-dsu2ax" + cmakeVariables: + CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS: "CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND" + CMAKE_CXX_FLAGS: "" + CMAKE_CXX_SCAN_FOR_MODULES: "OFF" + CMAKE_EXE_LINKER_FLAGS: "" + buildResult: + variable: "CMAKE_CXX_COMPILER_WORKS" + cached: true + stdout: | + Change Dir: 'D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-dsu2ax' + + Run Build Command(s): D:/esp32-tools/tools/ninja/1.12.1/ninja.exe -v cmTC_110d2 + [1/2] D:\\esp32-tools\\tools\\esp-clang\\esp-19.1.2_20250312\\esp-clang\\bin\\clang++.exe -MD -MT CMakeFiles/cmTC_110d2.dir/testCXXCompiler.cxx.obj -MF CMakeFiles\\cmTC_110d2.dir\\testCXXCompiler.cxx.obj.d -o CMakeFiles/cmTC_110d2.dir/testCXXCompiler.cxx.obj -c D:/workspace/fd230_source_win/HiBTMacWriteTool/build/CMakeFiles/CMakeScratch/TryCompile-dsu2ax/testCXXCompiler.cxx + [2/2] C:\\windows\\system32\\cmd.exe /C "cd . && D:\\esp32-tools\\tools\\esp-clang\\esp-19.1.2_20250312\\esp-clang\\bin\\clang++.exe CMakeFiles/cmTC_110d2.dir/testCXXCompiler.cxx.obj -o cmTC_110d2.exe -Wl,--out-implib,libcmTC_110d2.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." + FAILED: cmTC_110d2.exe + C:\\windows\\system32\\cmd.exe /C "cd . && D:\\esp32-tools\\tools\\esp-clang\\esp-19.1.2_20250312\\esp-clang\\bin\\clang++.exe CMakeFiles/cmTC_110d2.dir/testCXXCompiler.cxx.obj -o cmTC_110d2.exe -Wl,--out-implib,libcmTC_110d2.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." + ld.lld: error: unknown argument '--major-image-version' + ld.lld: error: unknown argument '--minor-image-version' + ld.lld: error: cannot open 0: No such file or directory + ld.lld: error: cannot open 0: No such file or directory + ld.lld: error: unable to find library -lkernel32 + ld.lld: error: unable to find library -luser32 + ld.lld: error: unable to find library -lgdi32 + ld.lld: error: unable to find library -lwinspool + ld.lld: error: unable to find library -lshell32 + ld.lld: error: unable to find library -lole32 + ld.lld: error: unable to find library -loleaut32 + ld.lld: error: unable to find library -luuid + ld.lld: error: unable to find library -lcomdlg32\x0d + ld.lld: error: unable to find library -ladvapi32\x0d + clang++: error: ld command failed with exit code 1 (use -v to see invocation)\x0d + ninja: build stopped: subcommand failed. + + exitCode: 1 +... diff --git a/build/CMakeFiles/cmake.check_cache b/build/CMakeFiles/cmake.check_cache new file mode 100644 index 0000000..56c437b --- /dev/null +++ b/build/CMakeFiles/cmake.check_cache @@ -0,0 +1 @@ +# This file is generated by cmake for dependency checking of the CMakeCache.txt file diff --git a/json_settings.cpp b/json_settings.cpp new file mode 100644 index 0000000..e278ff9 --- /dev/null +++ b/json_settings.cpp @@ -0,0 +1,400 @@ +#include "json_settings.h" +#include +#include +#include +#include +#include + +JsonSettings* JsonSettings::instance = nullptr; + +JsonSettings& JsonSettings::getInstance() +{ + if (nullptr == instance) { + instance = new JsonSettings(); + } + return *instance; +} + +void JsonSettings::release() +{ + if (instance != nullptr) { + delete instance; + instance = nullptr; + } +} + +JsonSettings::JsonSettings(QObject *parent) + : QObject(parent) + , m_config_file_path("settings.json") + , m_dut_baud_rate(115200) + , m_dut_baud_index(11) + , m_log_output_path("./logs") + , m_boot_verify_log(true) +{ + // 初始化4个串口配置 + for (int i = 0; i < 4; i++) { + SerialPortConfig config; + config.port_index = i; + config.com_name = "None"; + config.rgb_com_name = "None"; + m_serial_port_configs.append(config); + } + + // 加载配置 + loadSettings(); +} + +JsonSettings::~JsonSettings() +{ + // 保存配置 + saveSettings(); +} + +QString JsonSettings::getConfigFilePath() const +{ + // 返回应用程序工作目录下的配置文件路径 + QString appDir = QCoreApplication::applicationDirPath(); + return QDir(appDir).filePath(m_config_file_path); +} + +bool JsonSettings::loadSettings() +{ + QString filePath = getConfigFilePath(); + QFile file(filePath); + + if (!file.exists()) { + qDebug() << tr("配置文件不存在,创建默认配置:") << filePath; + // 创建默认配置 + QJsonObject defaultConfig = createDefaultConfig(); + QJsonDocument doc(defaultConfig); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + file.write(doc.toJson(QJsonDocument::Indented)); + file.close(); + } + readFromJson(defaultConfig); + return true; + } + + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << tr("无法打开配置文件:") << filePath; + return false; + } + + QByteArray data = file.readAll(); + file.close(); + + QJsonParseError error; + QJsonDocument doc = QJsonDocument::fromJson(data, &error); + + if (error.error != QJsonParseError::NoError) { + qDebug() << tr("JSON解析错误:") << error.errorString(); + return false; + } + + if (!doc.isObject()) { + qDebug() << tr("配置文件格式错误,不是有效的JSON对象"); + return false; + } + + readFromJson(doc.object()); + qDebug() << tr("成功加载配置文件:") << filePath; + return true; +} + +bool JsonSettings::saveSettings() +{ + QString filePath = getConfigFilePath(); + QFile file(filePath); + + // 确保目录存在 + QDir dir = QFileInfo(filePath).absoluteDir(); + if (!dir.exists()) { + dir.mkpath("."); + } + + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qDebug() << tr("无法写入配置文件:") << filePath; + return false; + } + + QJsonObject json = writeToJson(); + QJsonDocument doc(json); + file.write(doc.toJson(QJsonDocument::Indented)); + file.close(); + + qDebug() << tr("成功保存配置文件:") << filePath; + return true; +} + +void JsonSettings::readFromJson(const QJsonObject& json) +{ + // 读取串口配置 + if (json.contains("serial_ports") && json["serial_ports"].isObject()) { + QJsonObject serialPorts = json["serial_ports"].toObject(); + + // 读取DUT波特率 + if (serialPorts.contains("dut_baud_rate")) { + m_dut_baud_rate = serialPorts["dut_baud_rate"].toInt(115200); + } + if (serialPorts.contains("dut_baud_index")) { + m_dut_baud_index = serialPorts["dut_baud_index"].toInt(11); + } + + // 读取串口配置 + if (serialPorts.contains("dut_ports") && serialPorts["dut_ports"].isArray()) { + QJsonArray portsArray = serialPorts["dut_ports"].toArray(); + m_serial_port_configs.clear(); + + for (int i = 0; i < portsArray.size() && i < 4; i++) { + QJsonObject portObj = portsArray[i].toObject(); + SerialPortConfig config; + config.port_index = portObj["port_index"].toInt(i); + config.com_name = portObj["com_name"].toString("None"); + config.rgb_com_name = portObj["rgb_com_name"].toString("None"); + m_serial_port_configs.append(config); + } + } + } + + // 读取日志配置 + if (json.contains("logging") && json["logging"].isObject()) { + QJsonObject logging = json["logging"].toObject(); + if (logging.contains("log_output_path")) { + m_log_output_path = logging["log_output_path"].toString("./logs"); + } + if (logging.contains("boot_verify_log")) { + m_boot_verify_log = logging["boot_verify_log"].toBool(true); + } + } + + // 读取测试指令集 + if (json.contains("test_commands") && json["test_commands"].isObject()) { + QJsonObject testCommands = json["test_commands"].toObject(); + if (testCommands.contains("command_sets") && testCommands["command_sets"].isArray()) { + QJsonArray setsArray = testCommands["command_sets"].toArray(); + m_test_command_sets.clear(); + + for (const QJsonValue& value : setsArray) { + if (value.isObject()) { + QJsonObject setObj = value.toObject(); + TestCommandSet commandSet; + commandSet.name = setObj["name"].toString(); + + if (setObj.contains("commands") && setObj["commands"].isArray()) { + QJsonArray commandsArray = setObj["commands"].toArray(); + for (const QJsonValue& cmdValue : commandsArray) { + if (cmdValue.isObject()) { + QJsonObject cmdObj = cmdValue.toObject(); + TestCommand cmd; + cmd.cmd = cmdObj["cmd"].toString(); + cmd.keylog = cmdObj["keylog"].toString(); + commandSet.commands.append(cmd); + } + } + } + m_test_command_sets.append(commandSet); + } + } + } + } +} + +QJsonObject JsonSettings::writeToJson() const +{ + QJsonObject json; + json["version"] = "1.0"; + + // 串口配置 + QJsonObject serialPorts; + serialPorts["dut_baud_rate"] = m_dut_baud_rate; + serialPorts["dut_baud_index"] = m_dut_baud_index; + + QJsonArray portsArray; + for (const SerialPortConfig& config : m_serial_port_configs) { + QJsonObject portObj; + portObj["port_index"] = config.port_index; + portObj["com_name"] = config.com_name; + portObj["rgb_com_name"] = config.rgb_com_name; + portsArray.append(portObj); + } + serialPorts["dut_ports"] = portsArray; + json["serial_ports"] = serialPorts; + + // 日志配置 + QJsonObject logging; + logging["log_output_path"] = m_log_output_path; + logging["boot_verify_log"] = m_boot_verify_log; + json["logging"] = logging; + + // 测试指令集 + QJsonObject testCommands; + QJsonArray setsArray; + for (const TestCommandSet& commandSet : m_test_command_sets) { + QJsonObject setObj; + setObj["name"] = commandSet.name; + + QJsonArray commandsArray; + for (const TestCommand& cmd : commandSet.commands) { + QJsonObject cmdObj; + cmdObj["cmd"] = cmd.cmd; + cmdObj["keylog"] = cmd.keylog; + commandsArray.append(cmdObj); + } + setObj["commands"] = commandsArray; + setsArray.append(setObj); + } + testCommands["command_sets"] = setsArray; + json["test_commands"] = testCommands; + + return json; +} + +QJsonObject JsonSettings::createDefaultConfig() const +{ + QJsonObject json; + json["version"] = "1.0"; + + // 默认串口配置 + QJsonObject serialPorts; + serialPorts["dut_baud_rate"] = 115200; + serialPorts["dut_baud_index"] = 11; + + QJsonArray portsArray; + for (int i = 0; i < 4; i++) { + QJsonObject portObj; + portObj["port_index"] = i; + portObj["com_name"] = "None"; + portObj["rgb_com_name"] = "None"; + portsArray.append(portObj); + } + serialPorts["dut_ports"] = portsArray; + json["serial_ports"] = serialPorts; + + // 默认日志配置 + QJsonObject logging; + logging["log_output_path"] = "./logs"; + logging["boot_verify_log"] = true; + json["logging"] = logging; + + // 默认测试指令集 + QJsonObject testCommands; + QJsonArray setsArray; + + QJsonObject defaultSet; + defaultSet["name"] = "default"; + QJsonArray commandsArray; + + // 添加默认AT命令 + QJsonObject cmd1; + cmd1["cmd"] = "ATCMD_ADD_VOTE"; + cmd1["keylog"] = "MCU WAKEUP SUCCESS"; + commandsArray.append(cmd1); + + QJsonObject cmd2; + cmd2["cmd"] = "ATCMD_GET_MAC"; + cmd2["keylog"] = "MAC:"; + commandsArray.append(cmd2); + + QJsonObject cmd3; + cmd3["cmd"] = "ATCMD_SET_MAC"; + cmd3["keylog"] = "OK"; + commandsArray.append(cmd3); + + QJsonObject cmd4; + cmd4["cmd"] = "ATCMD_GET_CPUID"; + cmd4["keylog"] = "CPUID:"; + commandsArray.append(cmd4); + + QJsonObject cmd5; + cmd5["cmd"] = "ATCMD_POWEROFF"; + cmd5["keylog"] = "power off"; + commandsArray.append(cmd5); + + defaultSet["commands"] = commandsArray; + setsArray.append(defaultSet); + testCommands["command_sets"] = setsArray; + json["test_commands"] = testCommands; + + return json; +} + +SerialPortConfig JsonSettings::getSerialPortConfig(int port_index) const +{ + if (port_index >= 0 && port_index < m_serial_port_configs.size()) { + return m_serial_port_configs[port_index]; + } + SerialPortConfig config; + config.port_index = port_index; + config.com_name = "None"; + config.rgb_com_name = "None"; + return config; +} + +void JsonSettings::setSerialPortConfig(int port_index, const QString& dut_com, const QString& rgb_com) +{ + if (port_index >= 0 && port_index < m_serial_port_configs.size()) { + m_serial_port_configs[port_index].com_name = dut_com; + m_serial_port_configs[port_index].rgb_com_name = rgb_com; + } +} + +int JsonSettings::getDutBaudRate() const +{ + return m_dut_baud_rate; +} + +int JsonSettings::getDutBaudIndex() const +{ + return m_dut_baud_index; +} + +void JsonSettings::setDutBaudRate(int baud_rate) +{ + m_dut_baud_rate = baud_rate; +} + +void JsonSettings::setDutBaudIndex(int baud_index) +{ + m_dut_baud_index = baud_index; +} + +QString JsonSettings::getLogOutputPath() const +{ + return m_log_output_path; +} + +void JsonSettings::setLogOutputPath(const QString& path) +{ + m_log_output_path = path; +} + +bool JsonSettings::getBootVerifyLog() const +{ + return m_boot_verify_log; +} + +void JsonSettings::setBootVerifyLog(bool enabled) +{ + m_boot_verify_log = enabled; +} + +QList JsonSettings::getTestCommandSets() const +{ + return m_test_command_sets; +} + +TestCommandSet JsonSettings::getTestCommandSet(const QString& name) const +{ + for (const TestCommandSet& set : m_test_command_sets) { + if (set.name == name) { + return set; + } + } + return TestCommandSet(); // 返回空的指令集 +} + +void JsonSettings::setTestCommandSets(const QList& command_sets) +{ + m_test_command_sets = command_sets; +} + diff --git a/json_settings.h b/json_settings.h new file mode 100644 index 0000000..972d3b2 --- /dev/null +++ b/json_settings.h @@ -0,0 +1,96 @@ +#ifndef JSON_SETTINGS_H +#define JSON_SETTINGS_H + +#include +#include +#include +#include +#include +#include + +// 串口配置结构 +struct SerialPortConfig { + int port_index; + QString com_name; // DUT串口名称 + QString rgb_com_name; // RGB串口名称 +}; + +// 测试指令配置结构 +struct TestCommand { + QString cmd; // AT命令 + QString keylog; // 关键日志/响应标识 +}; + +struct TestCommandSet { + QString name; // 指令集名称 + QList commands; // 指令列表 +}; + +// JSON配置管理类 +class JsonSettings : public QObject +{ + Q_OBJECT + +public: + static JsonSettings& getInstance(); + static void release(); + + // 加载和保存配置 + bool loadSettings(); + bool saveSettings(); + + // 串口配置 + SerialPortConfig getSerialPortConfig(int port_index) const; + void setSerialPortConfig(int port_index, const QString& dut_com, const QString& rgb_com); + + // DUT波特率配置 + int getDutBaudRate() const; + int getDutBaudIndex() const; + void setDutBaudRate(int baud_rate); + void setDutBaudIndex(int baud_index); + + // 日志配置 + QString getLogOutputPath() const; + void setLogOutputPath(const QString& path); + bool getBootVerifyLog() const; + void setBootVerifyLog(bool enabled); + + // 测试指令集 + QList getTestCommandSets() const; + TestCommandSet getTestCommandSet(const QString& name) const; + void setTestCommandSets(const QList& command_sets); + + // 获取配置文件的完整路径 + QString getConfigFilePath() const; + +private: + JsonSettings(QObject *parent = nullptr); + ~JsonSettings(); + + // 禁止拷贝 + JsonSettings(const JsonSettings&) = delete; + JsonSettings& operator=(const JsonSettings&) = delete; + + // 从JSON对象读取配置 + void readFromJson(const QJsonObject& json); + + // 写入配置到JSON对象 + QJsonObject writeToJson() const; + + // 创建默认配置 + QJsonObject createDefaultConfig() const; + + static JsonSettings* instance; + QString m_config_file_path; + + // 配置数据 + QList m_serial_port_configs; + int m_dut_baud_rate; + int m_dut_baud_index; + QString m_log_output_path; + bool m_boot_verify_log; + QList m_test_command_sets; +}; + +#endif // JSON_SETTINGS_H + diff --git a/mainwindow.cpp b/mainwindow.cpp index c01b1a9..d41dd39 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,6 +8,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi { ui->setupUi(this); + // 设置布局比例:4个测试窗口各占2份,控制面板占1份 (8:1) + // horizontalLayout_main包含两个item:splitter(索引0)和verticalLayout_2(索引1) + ui->horizontalLayout_main->setStretch(0, 8); // splitter占8份 + ui->horizontalLayout_main->setStretch(1, 1); // verticalLayout_2占1份 + // 创建测试端口控制器实例 port_controller1 = new TestPortController(0, this); port_controller2 = new TestPortController(1, this); @@ -297,42 +302,81 @@ void MainWindow::ui_save_windows() QTextStream out(&file); //分行写入文件 out << ui->txtb_dispaly->toPlainText(); //这里的File_edit就是之前声明的Textedit控件的名字 } -// 存储config配置文件 +// 存储config配置文件(使用JSON格式) void MainWindow::ui_setting_save() { - QSettings *settings = new QSettings("Setting.ini", QSettings::IniFormat); - - // 写入第一组数据 - settings->beginGroup("Uart_setting"); - settings->setValue("uart_com", ui->cbox_uart_com_select_1->currentText()); - settings->setValue("uart_baud", ui->cbox_uart_baud_select->currentIndex()); -// settings->setValue("spp_addr", ui->ledit_spp_addr->text()); - settings->sync(); - settings->endGroup(); - delete settings; - settings = nullptr; + JsonSettings& jsonSettings = JsonSettings::getInstance(); + + // 保存所有4个端口的串口配置 + for (int i = 0; i < MAX_SERIAL_PORTS; i++) { + UIPortWidgets widgets = getUIPortWidgets(i); + QString dut_com = widgets.cbox_uart_com_select ? widgets.cbox_uart_com_select->currentText() : "None"; + QString rgb_com = widgets.cbox_uart_com_select_rgb ? widgets.cbox_uart_com_select_rgb->currentText() : "None"; + jsonSettings.setSerialPortConfig(i, dut_com, rgb_com); + } + + // 保存DUT波特率配置 + int baud_index = ui->cbox_uart_baud_select->currentIndex(); + jsonSettings.setDutBaudIndex(baud_index); + + // 获取波特率数值(从索引转换为实际波特率) + QString baud_text = ui->cbox_uart_baud_select->currentText(); + int baud_rate = baud_text.toInt(); + jsonSettings.setDutBaudRate(baud_rate); + + // 保存配置到文件 + jsonSettings.saveSettings(); + + qDebug() << tr("配置已保存到 settings.json"); } -// 读取config配置 +// 读取config配置(使用JSON格式) void MainWindow::ui_setting_read() { // 先更新所有串口选择框(包含最新串口列表和None选项) uart_com_select(); - QSettings *msettings = new QSettings("Setting.ini", QSettings::IniFormat); - QString saved_com = msettings->value("Uart_setting/uart_com").toString(); + JsonSettings& jsonSettings = JsonSettings::getInstance(); + + // 加载JSON配置 + jsonSettings.loadSettings(); - // 如果保存的串口存在,则设置为当前选择;否则保持为None - if (!saved_com.isEmpty() && saved_com != tr("None") && saved_com != "None") { - int index = ui->cbox_uart_com_select_1->findText(saved_com); - if (index >= 0) { - ui->cbox_uart_com_select_1->setCurrentIndex(index); + // 读取所有4个端口的串口配置 + for (int i = 0; i < MAX_SERIAL_PORTS; i++) { + SerialPortConfig config = jsonSettings.getSerialPortConfig(i); + UIPortWidgets widgets = getUIPortWidgets(i); + + // 设置DUT串口 + if (widgets.cbox_uart_com_select) { + if (!config.com_name.isEmpty() && config.com_name != tr("None") && config.com_name != "None") { + int index = widgets.cbox_uart_com_select->findText(config.com_name); + if (index >= 0) { + widgets.cbox_uart_com_select->setCurrentIndex(index); + } + } + } + + // 设置RGB串口 + if (widgets.cbox_uart_com_select_rgb) { + if (!config.rgb_com_name.isEmpty() && config.rgb_com_name != tr("None") && config.rgb_com_name != "None") { + int index = widgets.cbox_uart_com_select_rgb->findText(config.rgb_com_name); + if (index >= 0) { + widgets.cbox_uart_com_select_rgb->setCurrentIndex(index); + } + } } } - ui->cbox_uart_baud_select->setCurrentIndex(msettings->value("Uart_setting/uart_baud").toInt()); + // 读取DUT波特率配置 + int baud_index = jsonSettings.getDutBaudIndex(); + if (baud_index >= 0 && baud_index < ui->cbox_uart_baud_select->count()) { + ui->cbox_uart_baud_select->setCurrentIndex(baud_index); + } + // 加载MAC地址设置(保持原有功能) settings::getInstance().load_settings(); - ui->textBrowser_result->setText(settings::getInstance().getmacStatusFull()); + ui->textBrowser_result->setText(settings::getInstance().getmacStatusFull()); + + qDebug() << tr("配置已从 settings.json 加载"); } diff --git a/mainwindow.h b/mainwindow.h index eb10c3a..2d86878 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -20,6 +20,7 @@ #include "settings.h" #include "test_port_controller.h" +#include "json_settings.h" #include #include #include diff --git a/mainwindow.ui b/mainwindow.ui index b51b7a9..05c3e4e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -49,15 +49,15 @@ - - Qt::Horizontal - Arial 14 + + Qt::Horizontal + @@ -68,15 +68,77 @@ + + + + DUT + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + - - - DUT - - + + + + + RGB + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + - + + + true + 0 @@ -91,168 +153,168 @@ false - - - COM1 - - - - - - - - - - - RGB + 开始测试 + + + false - - - - 0 - 0 - - + Arial 14 - 50 - false - - - COM1 - - - - - - - - - - true - - - - 0 - 0 - - - - - Arial - 14 - 50 - false - - - - 开始测试 - - - false - - - - - - - - Arial - 14 - - - - true - - - QTextBrowser{background-color:rgb(26, 26, 26); - color:rgb(127, 255, 0)} - - - 1 - - - Qt::ScrollBarAlwaysOn - - - Qt::TextBrowserInteraction - - - - - - - - - false + + true - color:rgb(0, 170, 0); -font: 75 18pt "Agra"; + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} - 0 + 1 - - 成功0 + + Qt::ScrollBarAlwaysOn + + + Qt::TextBrowserInteraction - - - false - - - color:rgb(170, 0, 0); + + + + + false + + + color:rgb(0, 170, 0); font: 75 18pt "Agra"; - - - 0 - + + + 0 + + + 成功0 + + + + + + + false + + + color:rgb(170, 0, 0); +font: 75 18pt "Agra"; + + + 0 + + + 失败0 + + + + + + + - 失败0 + 已停止测试... - - - - - 已停止测试... - - - - - - - Arial - 14 - - - - - + + + Arial + 14 + + + - - - DUT - - + + + + + DUT + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + + + + RGB + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + - + + + true + 0 @@ -267,165 +329,165 @@ font: 75 18pt "Agra"; false - - - COM1 - - - - - - - - - - - RGB + 开始测试 + + + false - - - - 0 - 0 - - + Arial 14 - 50 - false - - - COM1 - - - - - - - - - - true - - - - 0 - 0 - - - - - Arial - 14 - 50 - false - - - - 开始测试 - - - false - - - - - - - - Arial - 14 - - - - true - - - QTextBrowser{background-color:rgb(26, 26, 26); - color:rgb(127, 255, 0)} - - - Qt::ScrollBarAlwaysOn - - - Qt::TextBrowserInteraction - - - - - - - - - false + + true - color:rgb(0, 170, 0); -font: 75 18pt "Agra"; + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} - - 0 + + Qt::ScrollBarAlwaysOn - - 成功0 + + Qt::TextBrowserInteraction - - - false - - - color:rgb(170, 0, 0); + + + + + false + + + color:rgb(0, 170, 0); font: 75 18pt "Agra"; - - - 0 - + + + 0 + + + 成功0 + + + + + + + false + + + color:rgb(170, 0, 0); +font: 75 18pt "Agra"; + + + 0 + + + 失败0 + + + + + + + - 失败0 + 已停止测试... - - - - - 已停止测试... - - - - - - - Arial - 14 - - - - - + + + Arial + 14 + + + - - - DUT - - + + + + + DUT + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + + + + RGB + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + - + + + true + 0 @@ -440,165 +502,165 @@ font: 75 18pt "Agra"; false - - - COM1 - - - - - - - - - - - RGB + 开始测试 + + + false - - - - 0 - 0 - - + Arial 14 - 50 - false - - - COM1 - - - - - - - - - - true - - - - 0 - 0 - - - - - Arial - 14 - 50 - false - - - - 开始测试 - - - false - - - - - - - - Arial - 14 - - - - true - - - QTextBrowser{background-color:rgb(26, 26, 26); - color:rgb(127, 255, 0)} - - - Qt::ScrollBarAlwaysOn - - - Qt::TextBrowserInteraction - - - - - - - - - false + + true - color:rgb(0, 170, 0); -font: 75 18pt "Agra"; + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} - - 0 + + Qt::ScrollBarAlwaysOn - - 成功0 + + Qt::TextBrowserInteraction - - - false - - - color:rgb(170, 0, 0); + + + + + false + + + color:rgb(0, 170, 0); font: 75 18pt "Agra"; - - - 0 - + + + 0 + + + 成功0 + + + + + + + false + + + color:rgb(170, 0, 0); +font: 75 18pt "Agra"; + + + 0 + + + 失败0 + + + + + + + - 失败0 + 已停止测试... - - - - - 已停止测试... - - - - - - - Arial - 14 - - - - - + + + Arial + 14 + + + - - - DUT - - + + + + + DUT + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + + + + + + + + RGB + + + + + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + + COM1 + + + + + - + + + true + 0 @@ -613,54 +675,93 @@ font: 75 18pt "Agra"; false - - - COM1 - - - - - - - - - - - RGB + 开始测试 + + + false - - - - 0 - 0 - - + Arial 14 - 50 - false + + true + + + QTextBrowser{background-color:rgb(26, 26, 26); + color:rgb(127, 255, 0)} + + + Qt::ScrollBarAlwaysOn + + + Qt::TextBrowserInteraction + + + + + - - COM1 - + + + false + + + color:rgb(0, 170, 0); +font: 75 18pt "Agra"; + + + 0 + + + 成功0 + + + + + + false + + + color:rgb(170, 0, 0); +font: 75 18pt "Agra"; + + + 0 + + + 失败0 + + + + + + + + + 已停止测试... + - + + + + + + + 4 + - - - true - + 0 @@ -675,277 +776,177 @@ font: 75 18pt "Agra"; false - - 开始测试 + + ArrowCursor - + false - - - - - - - Arial - 14 - - - - true + + 500000 - - QTextBrowser{background-color:rgb(26, 26, 26); - color:rgb(127, 255, 0)} - - - Qt::ScrollBarAlwaysOn + + 11 - - Qt::TextBrowserInteraction + + true - - - - - - - false - - - color:rgb(0, 170, 0); -font: 75 18pt "Agra"; - - - 0 - - - 成功0 - - + + 4800 + - - - false - - - color:rgb(170, 0, 0); -font: 75 18pt "Agra"; - - - 0 - - - 失败0 - - + + 9600 + - - - - - - 已停止测试... - - - - - - - - - - - - - - - 0 - 0 - + + + 14400 - - - Arial - 14 - 50 - false - + + + + 19200 - - ArrowCursor + + + + 38400 - - false + + + + 57600 - - 500000 + + + + 115200 - - 11 + + + + 128000 - - true + + + + 230400 - - - 4800 - - - - - 9600 - - - - - 14400 - - - - - 19200 - - - - - 38400 - - - - - 57600 - - - - - 115200 - - - - - 128000 - - - - - 230400 - - - - - 256000 - - - - - 460800 - - - - - 500000 - - - - - 512000 - - - - - 600000 - - - - - 750000 - - - - - 921600 - - - - - 1000000 - - - - - 1500000 - - - - - 2000000 - - - - - - - - true + + + + 256000 - - - 0 - 0 - + + + + 460800 - - - Arial - 14 - 50 - false - + + + + 500000 + + - 全部开始测试 + 512000 - - false + + + + 600000 - - - - - - - Arial - 14 - + + + + 750000 - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Arial','Arial','黑体'; font-size:14pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">已测试xxx设备</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">xxx成功,xxx失败。</p></body></html> + + + + 921600 - - - - - - - Arial - 14 - + + + + 1000000 + + - 打开日志路径 + 1500000 - - - - + + + + 2000000 + + + + + + + + true + + + + 0 + 0 + + + + + Arial + 14 + 50 + false + + + + 全部开始测试 + + + false + + + + + + + + Arial + 14 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial','黑体'; font-size:14pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial','Arial','黑体';">已测试xxx设备</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial','Arial','黑体';">xxx成功,xxx失败。</span></p></body></html> + + + + + + + + Arial + 14 + + + + 打开日志路径 + + + + diff --git a/settings.h b/settings.h index 20bc4fd..299f287 100644 --- a/settings.h +++ b/settings.h @@ -68,6 +68,13 @@ OK~ « fac:^^^^ BTMAC=28:11:06:4D:29:EF ^^^^ CyweeChipInfo=HS11g9LHov9p97100C5C20 OK~ + + +» AT^GETBTMAC +« get nv local_addr : ******4f71f0 +fac:^^^^ BTMAC=28:11:06:4F:71:F0 ^^^^ CyweeChipInfo= + + */ #define BOOT_UP_MSG "yaffs filesystem init start" #define TIME_FOR_CMD "bt enable_bt_stack ret" diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..b1ae922 --- /dev/null +++ b/settings.json @@ -0,0 +1,63 @@ +{ + "version": "1.0", + "serial_ports": { + "dut_ports": [ + { + "port_index": 0, + "com_name": "None", + "rgb_com_name": "None" + }, + { + "port_index": 1, + "com_name": "None", + "rgb_com_name": "None" + }, + { + "port_index": 2, + "com_name": "None", + "rgb_com_name": "None" + }, + { + "port_index": 3, + "com_name": "None", + "rgb_com_name": "None" + } + ], + "dut_baud_rate": 500000, + "dut_baud_index": 11 + }, + "logging": { + "log_output_path": "./logs", + "boot_verify_log": true + }, + "test_commands": { + "command_sets": [ + { + "name": "default", + "commands": [ + { + "cmd": "ATCMD_ADD_VOTE", + "keylog": "MCU WAKEUP SUCCESS" + }, + { + "cmd": "ATCMD_GET_MAC", + "keylog": "MAC:" + }, + { + "cmd": "ATCMD_SET_MAC", + "keylog": "OK" + }, + { + "cmd": "ATCMD_GET_CPUID", + "keylog": "CPUID:" + }, + { + "cmd": "ATCMD_POWEROFF", + "keylog": "power off" + } + ] + } + ] + } +} + diff --git a/test_port_controller.cpp b/test_port_controller.cpp index 9f41cca..8c2779b 100644 --- a/test_port_controller.cpp +++ b/test_port_controller.cpp @@ -22,9 +22,24 @@ TestPortController::TestPortController(int port_index, QObject *parent) , m_uart_rx_Ignoring_display(false) , m_write_success_count(0) , m_write_fail_count(0) + , m_test_state(TEST_STATE_IDLE) + , m_vote_retry_count(0) + , m_color_check_timer(new QTimer(this)) + , m_audio_timeout_timer(new QTimer(this)) + , m_gpio_timeout_timer(new QTimer(this)) + , m_blue_color_detected(false) + , m_last_audio_level("") + , m_audio_level_count(0) + , m_gpio_result_detected(false) { // 连接定时器信号 connect(m_spp_timer_handle, &QTimer::timeout, this, &TestPortController::onTimerTimeout); + connect(m_color_check_timer, &QTimer::timeout, this, &TestPortController::onColorCheckTimer); + connect(m_audio_timeout_timer, &QTimer::timeout, this, &TestPortController::onAudioTimeoutTimer); + connect(m_gpio_timeout_timer, &QTimer::timeout, this, &TestPortController::onGpioTimeoutTimer); + m_color_check_timer->setSingleShot(true); + m_audio_timeout_timer->setSingleShot(true); + m_gpio_timeout_timer->setSingleShot(true); // 连接DUT串口信号 connect(m_dut_serial, &QSerialPort::readyRead, this, &TestPortController::onReadyRead); @@ -41,10 +56,17 @@ TestPortController::TestPortController(int port_index, QObject *parent) // 连接RGBC数据解析信号(带颜色名称) connect(m_rgb_reader, &RgbSerialReader::rgbcDataParsedWithColor, this, [this](int port_index, quint16 red, quint16 green, quint16 blue, quint16 clear, const QString& colorName) { - // 只显示颜色名称(颜色变化时才更新) - QString colorInfo = tr("颜色: %1\r\n").arg(colorName); - emit displayMessage(colorInfo, true); + // 不在窗口中显示颜色,只在控制台打印用于调试 qDebug() << tr("端口%1 检测到颜色: %2").arg(m_port_index + 1).arg(colorName); + + // 新测试流程:检测到蓝色后,进入投票阶段 + if (m_test_state == TEST_STATE_CHECK_BLUE_COLOR && colorName.contains(tr("蓝色"))) { + m_blue_color_detected = true; + emit displayMessage(tr("LCD颜色检测通过(蓝色)\r\n"), true); + transitionToState(TEST_STATE_SEND_VOTE); + m_vote_retry_count = 0; // 重置投票重试计数 + sendNextTestCommand(); + } }); connect(m_rgb_reader, &RgbSerialReader::errorOccurred, this, [this](const QString& error) { @@ -125,6 +147,21 @@ void TestPortController::connectPort(const QString& com_name, int baud_rate) emit failCountChanged(m_write_fail_count); emit buttonTextChanged(tr("停止写地址")); emit statusChanged(tr("等待手表开机")); + + // 初始化新测试流程状态 + m_test_state = TEST_STATE_WAIT_NAND_ID; + m_vote_retry_count = 0; + m_blue_color_detected = false; + m_last_audio_level.clear(); + m_audio_level_count = 0; + m_gpio_result_detected = false; + m_test_result_summary.clear(); + + // 清空窗口,显示等待设备启动 + emit clearDisplay(); + emit displayMessage(tr("等待设备启动...\r\n"), true); + + qDebug() << tr("端口%1初始化新测试流程,状态: %2").arg(m_port_index + 1).arg(getStateName(m_test_state)); } void TestPortController::disconnectPort() @@ -201,8 +238,17 @@ void TestPortController::readData() { const QByteArray data = m_dut_serial->readAll(); + if (data.isEmpty()) { + return; + } + + // 控制台打印:接收到的原始数据(用于调试) + qDebug() << tr("端口%1 DUT串口接收到数据,长度:%2").arg(m_port_index + 1).arg(data.length()); + QString dataStr = QString::fromUtf8(data); + qDebug() << tr("端口%1 DUT串口数据内容: %2").arg(m_port_index + 1).arg(dataStr); + if (m_uart_rx_flag) { - qDebug() << tr("端口%1接收数据:").arg(m_port_index) << data; + qDebug() << tr("端口%1接收数据(AT命令响应):").arg(m_port_index) << data; } if (!m_working_state) { @@ -213,74 +259,159 @@ void TestPortController::readData() // 将新数据添加到开机检测缓存中 m_boot_detect_buffer.append(data); - // 保持缓存大小合理 - if (m_boot_detect_buffer.length() > 8192) { - m_boot_detect_buffer = m_boot_detect_buffer.right(8192); + // 调试:当接收到包含flash关键字的数据时,打印缓冲区信息 + QString newDataStr = QString::fromUtf8(data); + if (newDataStr.contains("find nand flash chip id", Qt::CaseInsensitive)) { + qDebug() << tr("端口%1 [关键数据] 接收到包含flash id的数据,长度=%2,当前缓冲区长度=%3") + .arg(m_port_index + 1) + .arg(data.length()) + .arg(m_boot_detect_buffer.length()); + } + + // 保持缓存大小合理(在检测之前先检查,避免截断关键信息) + // 直接在QByteArray上搜索,避免UTF-8转换问题 + QByteArray lowerBuffer = m_boot_detect_buffer.toLower(); + bool hasFlashInfo = lowerBuffer.contains("find nand flash chip id") || lowerBuffer.contains("nand flash chip id"); + + if (m_boot_detect_buffer.length() > 16384) { // 增加到16KB,确保不会截断关键信息 + // 如果包含flash信息,尝试保留包含该信息的部分 + if (hasFlashInfo) { + int flashPos = lowerBuffer.indexOf("find nand flash chip id"); + if (flashPos < 0) { + flashPos = lowerBuffer.indexOf("nand flash chip id"); + } + if (flashPos >= 0) { + // 保留flash信息前后各4096字节 + int startPos = qMax(0, flashPos - 4096); + m_boot_detect_buffer = m_boot_detect_buffer.mid(startPos); + qDebug() << tr("端口%1 缓冲区包含flash信息,保留从位置%2开始的数据,新长度=%3") + .arg(m_port_index + 1) + .arg(startPos) + .arg(m_boot_detect_buffer.length()); + } else { + m_boot_detect_buffer = m_boot_detect_buffer.right(16384); + } + } else { + m_boot_detect_buffer = m_boot_detect_buffer.right(16384); + } static bool buffer_limit_warned[4] = {false, false, false, false}; if (!buffer_limit_warned[m_port_index]) { - qDebug() << tr("端口%1开机检测缓存过大,保留最近8192字节").arg(m_port_index); + qDebug() << tr("端口%1开机检测缓存过大,保留最近16384字节").arg(m_port_index); buffer_limit_warned[m_port_index] = true; } } - // 检测开机信号 - if (m_boot_detect_buffer.indexOf(BOOT_UP_MSG) >= 0) { - emit statusChanged(tr("发现新设备")); - m_waiting_cmd = true; - m_cmd_index = 0; - QString avalible_mac = settings::getInstance().getAvalibleMac(); - setMacAddress(avalible_mac); - emit clearDisplay(); - m_boot_detect_buffer.clear(); - qDebug() << tr("端口%1检测到开机信号,清理缓存").arg(m_port_index); - } + // 新测试流程:检测启动日志 + // 直接在QByteArray上搜索,避免UTF-8转换问题 - // 检测MAC地址信息 - if (m_working_state && !m_waiting_cmd) { - QRegExp macRegex("BTMAC=([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})"); - int macPos = macRegex.indexIn(m_boot_detect_buffer); - if (macPos >= 0) { - QString foundMac = macRegex.cap(1); - QString macWithoutColon = foundMac.replace(":", "").toUpper(); + // 检测nand flash id(直接在QByteArray上搜索,不区分大小写) + // 检测到flash表示新一轮检测开始,清空窗口数据 + if (m_test_state == TEST_STATE_IDLE || m_test_state == TEST_STATE_WAIT_NAND_ID) { + int findPos = lowerBuffer.indexOf("find nand flash chip id"); + int nandPos = lowerBuffer.indexOf("nand flash chip id"); + + if (findPos >= 0 || nandPos >= 0) { + // 找到包含flash id的位置,尝试提取ID + int searchStart = (findPos >= 0) ? findPos : nandPos; + // 在找到的位置附近搜索 "0x" 和后续的4位十六进制数 + QByteArray snippet = m_boot_detect_buffer.mid(qMax(0, searchStart - 20), 100); + QString snippetStr = QString::fromLatin1(snippet); // 使用fromLatin1更宽松 - bool mac_used = settings::getInstance().getMacUsed(macWithoutColon); + // 尝试多种正则表达式匹配 + QRegExp idRegex1("find\\s+nand\\s+flash\\s+chip\\s+id[\\s:]*0x([0-9A-Fa-f]+)", Qt::CaseInsensitive); + QRegExp idRegex2("nand\\s+flash\\s+chip\\s+id[\\s:]*0x([0-9A-Fa-f]+)", Qt::CaseInsensitive); - if (mac_used) { - emit displayMessage(tr("手表地址") + macWithoutColon + tr("已占用\r\n"), false); - emit showResult(tr("Mac地址已占用"), false); + QString nandId; + if (idRegex1.indexIn(snippetStr) >= 0) { + nandId = idRegex1.cap(1); + qDebug() << tr("端口%1 使用正则1匹配到nand id: 0x%2").arg(m_port_index + 1).arg(nandId); + } else if (idRegex2.indexIn(snippetStr) >= 0) { + nandId = idRegex2.cap(1); + qDebug() << tr("端口%1 使用正则2匹配到nand id: 0x%2").arg(m_port_index + 1).arg(nandId); } else { - emit displayMessage(tr("手表当前地址") + macWithoutColon + tr(" 可用!\r\n"), true); + // 使用简单匹配:在snippet中查找 "0x" 后跟4位十六进制 + int hexPos = snippet.indexOf("0x"); + if (hexPos >= 0 && hexPos + 6 <= snippet.length()) { + QByteArray hexPart = snippet.mid(hexPos + 2, 4); + bool isHex = true; + for (int i = 0; i < hexPart.length(); i++) { + char c = hexPart[i]; + if (!((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))) { + isHex = false; + break; + } + } + if (isHex) { + nandId = QString::fromLatin1(hexPart).toUpper(); + qDebug() << tr("端口%1 使用简单匹配找到nand id: 0x%2").arg(m_port_index + 1).arg(nandId); + } + } + } + + if (!nandId.isEmpty()) { + // 新一轮检测开始,清空窗口数据 + emit clearDisplay(); + + // 显示解析后的数据到窗口 + emit displayMessage(tr("=== 新一轮检测开始 ===\r\n"), true); + emit displayMessage(tr("✓ 检测到nand flash id: 0x%1\r\n").arg(nandId), true); + + transitionToState(TEST_STATE_WAIT_NAND_MODEL); + qDebug() << tr("端口%1 ✓ 检测到nand flash id: 0x%2,清空窗口,开始新一轮检测").arg(m_port_index + 1).arg(nandId); + } else { + qDebug() << tr("端口%1 检测到包含'find nand flash chip id'的文本,但未能提取ID").arg(m_port_index + 1); } } } - // 检测命令时机信号 - if (m_waiting_cmd && m_boot_detect_buffer.indexOf(TIME_FOR_CMD) >= 0) { - uart_send_data(ATCMD_ADD_VOTE); - m_boot_detect_buffer.clear(); - qDebug() << tr("端口%1检测到命令时机信号,清理缓存").arg(m_port_index); - } - - // 检测启动完成信号 - if (m_waiting_cmd && !m_startup_complete_detected && - m_boot_detect_buffer.indexOf(STARTUP_POST_INIT) >= 0 && - m_boot_detect_buffer.indexOf(STARTUP_POST_INIT_TASK) >= 0) { - m_startup_complete_detected = true; - qDebug() << tr("端口%1检测到启动完成信号").arg(m_port_index); - emit displayMessage(tr("系统启动完成,可以执行GETIDS\r\n"), true); - m_boot_detect_buffer.clear(); - - if ((m_cmd_index == 3 || m_cmd_index == 4) && !m_uart_rx_flag) { - if (m_cmd_index == 3) { - m_cmd_index++; - } - m_uart_rx_buff_array.clear(); - if (m_cmd_index == 4) { - uart_send_data(ATCMD_GET_CPUID); + // 检测nand flash型号(直接在QByteArray上搜索) + if (m_test_state == TEST_STATE_WAIT_NAND_MODEL) { + if (lowerBuffer.contains("nand flash") && (lowerBuffer.contains("start init") || lowerBuffer.contains(" init"))) { + // 尝试提取型号:查找 "nand flash" 后的型号名称 + int nandPos = lowerBuffer.indexOf("nand flash"); + if (nandPos >= 0) { + QByteArray snippet = m_boot_detect_buffer.mid(nandPos, 100); + QString snippetStr = QString::fromLatin1(snippet); + + QRegExp modelRegex1("nand flash\\s+([A-Z0-9]+)\\s+start init", Qt::CaseInsensitive); + QRegExp modelRegex2("nand flash\\s+([A-Z0-9]+)", Qt::CaseInsensitive); + + QString model; + if (modelRegex1.indexIn(snippetStr) >= 0) { + model = modelRegex1.cap(1); + } else if (modelRegex2.indexIn(snippetStr) >= 0) { + model = modelRegex2.cap(1); + } + + if (!model.isEmpty()) { + // 显示解析后的数据到窗口 + emit displayMessage(tr("✓ 检测到nand flash型号: %1\r\n").arg(model), true); + transitionToState(TEST_STATE_WAIT_BLUE_WINDOW); + qDebug() << tr("端口%1 ✓ 检测到nand flash型号: %2").arg(m_port_index + 1).arg(model); + } } } } + // 检测蓝色窗口(直接在QByteArray上搜索) + if (m_test_state == TEST_STATE_WAIT_BLUE_WINDOW) { + if (m_boot_detect_buffer.contains("Blue window created and displayed:")) { + // 显示解析后的数据到窗口 + emit displayMessage(tr("✓ 检测到蓝色窗口已创建\r\n"), true); + transitionToState(TEST_STATE_CHECK_BLUE_COLOR); + // 延迟1秒后检测颜色 + m_color_check_timer->start(1000); + qDebug() << tr("端口%1检测到蓝色窗口,1秒后检测颜色").arg(m_port_index + 1); + } + } + + // 旧流程兼容代码已删除,现在只使用新的测试流程 + + // 新测试流程:处理日志消息 + if (m_working_state && m_test_state != TEST_STATE_IDLE) { + checkLogMessages(); + } + if (m_uart_rx_flag) { m_uart_rx_buff_array.append(data); @@ -309,56 +440,71 @@ void TestPortController::readData() } m_uart_rx_flag = false; - uart_process(); - if (m_cmd_index < 0) { - if (m_spp_timer_handle && m_spp_timer_handle->isActive()) { - m_spp_timer_handle->stop(); + // 新测试流程中不使用旧的uart_process逻辑,避免冲突 + // 新流程的状态转换由checkLogMessages()处理 + if (m_test_state == TEST_STATE_IDLE || m_test_state == TEST_STATE_WAIT_NAND_ID) { + // 只有在旧流程(空闲或等待启动)时才使用uart_process + uart_process(); + + if (m_cmd_index < 0) { + if (m_spp_timer_handle && m_spp_timer_handle->isActive()) { + m_spp_timer_handle->stop(); + } + + if (m_uart_rx_buff_array.indexOf("power off device") >= 0) { + emit displayMessage(tr("关机成功\r\n"), true); + } + return; } - if (m_uart_rx_buff_array.indexOf("power off device") >= 0) { - emit displayMessage(tr("关机成功\r\n"), true); + m_cmd_index++; + + switch(m_cmd_index) { + case 0: + break; + case 1: + uart_send_data(ATCMD_GET_MAC); + break; + case 2: + { + QString set_mac_cmd = QString(ATCMD_SET_MAC).arg(m_mac_address); + uart_send_data(set_mac_cmd); } - return; - } - - m_cmd_index++; - - switch(m_cmd_index) { - case 0: - break; - case 1: - uart_send_data(ATCMD_GET_MAC); - break; - case 2: - { - QString set_mac_cmd = QString(ATCMD_SET_MAC).arg(m_mac_address); - uart_send_data(set_mac_cmd); - } - break; - case 3: - uart_send_data(ATCMD_GET_MAC); - break; - case 4: - { - if (m_startup_complete_detected) { - uart_send_data(ATCMD_GET_CPUID); - } else { - emit displayMessage(tr("等待系统完全启动信号...\r\n"), false); - m_cmd_index = 4; - return; + break; + case 3: + uart_send_data(ATCMD_GET_MAC); + break; + case 4: + { + if (m_startup_complete_detected) { + uart_send_data(ATCMD_GET_CPUID); + } else { + emit displayMessage(tr("等待系统完全启动信号...\r\n"), false); + m_cmd_index = 4; + return; + } } - } - break; - case 5: - uart_send_data(ATCMD_POWEROFF); - break; - default: - m_cmd_index = -1; - if (m_spp_timer_handle && m_spp_timer_handle->isActive()) { - m_spp_timer_handle->stop(); + break; + case 5: + uart_send_data(ATCMD_POWEROFF); + break; + default: + m_cmd_index = -1; + if (m_spp_timer_handle && m_spp_timer_handle->isActive()) { + m_spp_timer_handle->stop(); + } + break; + } + } else { + // 新流程中,只处理命令响应,不调用uart_process + // 状态转换由checkLogMessages()根据日志消息处理 + qDebug() << tr("端口%1 新测试流程中,跳过uart_process,由checkLogMessages处理").arg(m_port_index + 1); + + // 新流程中,如果检测到关机命令响应,直接处理 + if (m_uart_rx_buff_array.indexOf("power off device") >= 0) { + emit displayMessage(tr("关机成功\r\n"), true); } - break; } } } @@ -519,7 +665,13 @@ void TestPortController::uart_send_data(const QString& cmd) m_spp_timer_handle->stop(); } - if (cmd.contains("GETIDS")) { + // 对于异步测试命令(如声音测试、GPIO测试),不启动AT命令超时定时器 + // 因为这些命令的结果通过日志异步返回,不是立即响应 + if (cmd.contains("AUDIOTEST") || cmd.contains("GPIOTEST") || + cmd.contains("BTSCANTEST") || cmd.contains("BTENABLE")) { + // 这些命令是异步的,结果通过日志返回,不需要等待立即响应 + qDebug() << tr("端口%1 发送异步测试命令,不启动AT命令超时定时器: %2").arg(m_port_index + 1).arg(cmd.trimmed()); + } else if (cmd.contains("GETIDS")) { m_spp_timer_handle->start(5000); } else if (cmd.contains("GETBTMAC")) { m_spp_timer_handle->start(3000); @@ -571,6 +723,17 @@ void TestPortController::resetState() m_boot_detect_buffer.clear(); m_write_success_count = 0; m_write_fail_count = 0; + + // 重置新测试流程状态 + m_test_state = TEST_STATE_IDLE; + m_vote_retry_count = 0; + m_blue_color_detected = false; + m_last_audio_level.clear(); + m_audio_level_count = 0; + m_gpio_result_detected = false; + m_test_result_summary.clear(); + m_color_check_timer->stop(); + m_audio_timeout_timer->stop(); } void TestPortController::clearBuffers() @@ -579,3 +742,477 @@ void TestPortController::clearBuffers() m_boot_detect_buffer.clear(); } +// ========== 新测试流程实现 ========== + +void TestPortController::processNewTestFlow() +{ + // 处理新测试流程的状态机 + checkLogMessages(); + processTestCommandResponse(); +} + +void TestPortController::checkLogMessages() +{ + // 直接在QByteArray上搜索,避免UTF-8转换问题 + QByteArray lowerBuffer = m_boot_detect_buffer.toLower(); + + // 根据当前状态检查相应的日志消息 + switch (m_test_state) { + case TEST_STATE_IDLE: + // 空闲状态,不需要处理日志 + break; + + case TEST_STATE_COMPLETE: + case TEST_STATE_FAILED: + // 测试完成或失败状态,不需要处理日志 + break; + + case TEST_STATE_WAIT_VOTE_SUCCESS: + if (m_boot_detect_buffer.contains("MCU WAKEUP SUCCESS") || m_boot_detect_buffer.contains("OK~")) { + emit displayMessage(tr("投票成功\r\n"), true); + transitionToState(TEST_STATE_GET_CPUID); + sendNextTestCommand(); + } + break; + + case TEST_STATE_WAIT_CPUID: + if (m_boot_detect_buffer.contains("OK~") && lowerBuffer.contains("nandflash id:")) { + emit displayMessage(tr("获取CPUID成功\r\n"), true); + transitionToState(TEST_STATE_GET_BT_MAC); + sendNextTestCommand(); + } + break; + + case TEST_STATE_WAIT_BT_MAC: + if (m_boot_detect_buffer.contains("BTMAC=") || m_boot_detect_buffer.contains("OK~")) { + emit displayMessage(tr("获取蓝牙MAC成功\r\n"), true); + transitionToState(TEST_STATE_ENABLE_BT); + sendNextTestCommand(); + } + break; + + case TEST_STATE_WAIT_BT_ENABLE: + if (lowerBuffer.contains("bt enable ok") || m_boot_detect_buffer.contains("OK~")) { + emit displayMessage(tr("蓝牙打开成功\r\n"), true); + transitionToState(TEST_STATE_START_SCAN); + sendNextTestCommand(); + } + break; + + case TEST_STATE_WAIT_SCAN_START: + if (m_boot_detect_buffer.contains("Starting Bluetooth scan test") || m_boot_detect_buffer.contains("OK~")) { + emit displayMessage(tr("开启扫描成功\r\n"), true); + qDebug() << tr("端口%1 检测到扫描开始,准备启动声音测试").arg(m_port_index + 1); + transitionToState(TEST_STATE_AUDIO_TEST); + sendNextTestCommand(); + } else { + // 调试:检查是否包含部分关键字 + static int scan_check_count[4] = {0, 0, 0, 0}; + scan_check_count[m_port_index]++; + if (scan_check_count[m_port_index] % 20 == 0) { + QString bufferStr = QString::fromLatin1(m_boot_detect_buffer.right(500)); + qDebug() << tr("端口%1 [扫描检测] 状态=%2, 缓冲区长度=%3, 检查次数=%4, 最后500字符包含'Starting'=%5, 包含'OK~'=%6") + .arg(m_port_index + 1) + .arg(getStateName(m_test_state)) + .arg(m_boot_detect_buffer.length()) + .arg(scan_check_count[m_port_index]) + .arg(bufferStr.contains("Starting")) + .arg(m_boot_detect_buffer.contains("OK~")); + } + } + break; + + case TEST_STATE_WAIT_AUDIO_RESULT: { + // 检测音量结果:需要连续接收到3次以上相同的音量Level值才算成功 + // 从日志中可以看到格式:APP|[AudioTest] Volume - RMS: 14.35% (-16.86 dB), Peak: 33.48% (-9.50 dB), Level: 中 + // 由于可能有二进制数据,直接在原始字节数组上搜索UTF-8字节序列,避免转换问题 + + // 准备要搜索的UTF-8字节序列 + QByteArray zhongBytes = QString("中").toUtf8(); // E4 B8 AD + QByteArray gaoBytes = QString("高").toUtf8(); // E9 AB 98 + QByteArray diBytes = QString("低").toUtf8(); // E4 BD 8E + QByteArray jidiBytes = QString("极低").toUtf8(); // E6 9E 81 E4 BD 8E + QByteArray jingyinBytes = QString("静音").toUtf8(); // E9 9D 99 E9 9F B3 + + // 在原始字节数组上搜索 "Level:"(不区分大小写) + // 从后往前搜索,找到最后一个"Level:",确保获取最新的Level值 + QByteArray lowerBuffer = m_boot_detect_buffer.toLower(); + int levelPos = lowerBuffer.lastIndexOf("level:"); + + if (levelPos >= 0) { + // 找到最后一个 "Level:" 位置,在后续的字节中搜索中文字符 + // 搜索范围:从 "Level:" 后到换行符之前(最多20字节,确保只搜索当前行的Level值) + int searchStart = levelPos + 6; // "level:" 长度是6 + // 找到换行符位置(\r\n 或 \n) + int newlinePos = m_boot_detect_buffer.indexOf("\r\n", searchStart); + if (newlinePos < 0) { + newlinePos = m_boot_detect_buffer.indexOf("\n", searchStart); + } + if (newlinePos < 0) { + newlinePos = qMin(m_boot_detect_buffer.length(), searchStart + 20); + } else { + newlinePos = qMin(newlinePos, searchStart + 20); // 最多20字节 + } + QByteArray searchArea = m_boot_detect_buffer.mid(searchStart, newlinePos - searchStart); + + qDebug() << tr("端口%1 [Level检测] 找到Level位置=%2, 搜索起始=%3, 换行位置=%4, 搜索区域长度=%5") + .arg(m_port_index + 1) + .arg(levelPos) + .arg(searchStart) + .arg(newlinePos) + .arg(searchArea.length()); + + // 直接在字节数组上搜索UTF-8字节序列 + bool hasZhong = searchArea.contains(zhongBytes); + bool hasGao = searchArea.contains(gaoBytes); + bool hasDi = searchArea.contains(diBytes); + bool hasJidi = searchArea.contains(jidiBytes); + bool hasJingyin = searchArea.contains(jingyinBytes); + + QString currentLevel; + bool isValidLevel = false; + bool isSilent = false; + + // 确定当前Level值(优先级:中 > 高 > 低 > 极低 > 静音) + if (hasZhong) { + currentLevel = "中"; + isValidLevel = true; + } else if (hasGao) { + currentLevel = "高"; + isValidLevel = true; + } else if (hasJidi) { + currentLevel = "极低"; + isValidLevel = true; + } else if (hasDi) { + currentLevel = "低"; + isValidLevel = true; + } else if (hasJingyin) { + currentLevel = "静音"; + isSilent = true; + } + + qDebug() << tr("端口%1 [Level检测] 搜索区域: %2, 包含'中'=%3, 包含'高'=%4, 包含'低'=%5, 包含'极低'=%6, 包含'静音'=%7, currentLevel='%8'") + .arg(m_port_index + 1) + .arg(QString::fromLatin1(searchArea.toHex(' '))) + .arg(hasZhong) + .arg(hasGao) + .arg(hasDi) + .arg(hasJidi) + .arg(hasJingyin) + .arg(currentLevel); + + if (isValidLevel) { + // 有效的Level值(非静音) + // 检查是否与上次检测到的Level值相同 + if (currentLevel == m_last_audio_level) { + // 相同,计数器+1 + m_audio_level_count++; + qDebug() << tr("端口%1 检测到相同有效Level: %2, 连续次数: %3") + .arg(m_port_index + 1) + .arg(currentLevel) + .arg(m_audio_level_count); + + // 如果连续3次以上相同,认为测试成功 + if (m_audio_level_count >= 3) { + m_audio_timeout_timer->stop(); + // 关闭声音检测 + uart_send_data("AT^AUDIOTEST=6\r\n"); + emit displayMessage(tr("声音测试完成(Level: %1,连续%2次)\r\n") + .arg(currentLevel) + .arg(m_audio_level_count), true); + transitionToState(TEST_STATE_WAIT_SCAN_END); + qDebug() << tr("端口%1 声音测试成功,连续%2次检测到Level: %3") + .arg(m_port_index + 1) + .arg(m_audio_level_count) + .arg(currentLevel); + // 重置计数 + m_last_audio_level.clear(); + m_audio_level_count = 0; + } + } else { + // 不同,重置计数,更新last_level + m_last_audio_level = currentLevel; + m_audio_level_count = 1; + qDebug() << tr("端口%1 检测到新的有效Level: %2, 重置计数为1") + .arg(m_port_index + 1) + .arg(currentLevel); + } + } else if (isSilent) { + // 检测到静音,重置计数(静音不应该计入有效Level) + if (m_last_audio_level != "静音") { + // 如果之前不是静音,重置计数 + m_last_audio_level.clear(); + m_audio_level_count = 0; + qDebug() << tr("端口%1 检测到静音,重置有效Level计数").arg(m_port_index + 1); + } + } + } + break; + } + + case TEST_STATE_WAIT_SCAN_END: + if (m_boot_detect_buffer.contains("Bluetooth scan test completed") || + lowerBuffer.contains("scan test end") || m_boot_detect_buffer.contains("OK~")) { + emit displayMessage(tr("蓝牙扫描结束\r\n"), true); + transitionToState(TEST_STATE_GPIO_TEST); + sendNextTestCommand(); + } + break; + + case TEST_STATE_WAIT_GPIO_RESULT: { + // 检测GPIO测试完成:[GpioTest] Test finished 代表测试结束 + // 从日志中可以看到格式:Test completed: 13 passed, 21 failed + // 如果检测到 "[GpioTest] Test finished" 但之前未检测到 "X passed, Y failed" 格式,算失败 + QString bufferStr = QString::fromLatin1(m_boot_detect_buffer); + + // 首先检查是否包含 "X passed, Y failed" 格式(可能在Test finished之前出现) + QRegExp resultRegex("(\\d+)\\s+passed[,\\s]+(\\d+)\\s+failed"); + if (resultRegex.indexIn(bufferStr) >= 0 && !m_gpio_result_detected) { + // 检测到结果格式,记录标志 + m_gpio_result_detected = true; + int passed = resultRegex.cap(1).toInt(); + int failed = resultRegex.cap(2).toInt(); + qDebug() << tr("端口%1 检测到GPIO测试结果:%2通过,%3失败").arg(m_port_index + 1).arg(passed).arg(failed); + } + + // 检测是否包含 "[GpioTest] Test finished" + if (bufferStr.contains("[GpioTest] Test finished") || bufferStr.contains("Test finished")) { + m_gpio_timeout_timer->stop(); + + if (m_gpio_result_detected) { + // 之前已经检测到结果格式,认为测试成功 + // 重新提取结果用于显示 + if (resultRegex.indexIn(bufferStr) >= 0) { + int passed = resultRegex.cap(1).toInt(); + int failed = resultRegex.cap(2).toInt(); + emit displayMessage(tr("GPIO测试完成(%1通过,%2失败)\r\n").arg(passed).arg(failed), true); + } else { + emit displayMessage(tr("GPIO测试完成\r\n"), true); + } + transitionToState(TEST_STATE_COMPLETE); + finalizeTestResult(); + } else { + // 检测到 "Test finished" 但之前未检测到结果格式,认为测试失败 + emit displayMessage(tr("GPIO测试失败:未检测到测试结果(X passed, Y failed)\r\n"), false); + transitionToState(TEST_STATE_FAILED); + finalizeTestResult(); + } + } + // 如果没有找到 "Test finished",继续等待(超时定时器会处理失败情况) + break; + } + + default: + break; + } +} + +void TestPortController::onColorCheckTimer() +{ + // 延迟1秒后检测颜色 + if (m_test_state == TEST_STATE_CHECK_BLUE_COLOR) { + // 检查RGB串口是否检测到蓝色 + // 这里需要通过信号连接来获取颜色信息 + emit displayMessage(tr("开始检测LCD颜色...\r\n"), true); + // 颜色检测结果会通过RGB串口的信号返回 + // 如果检测到蓝色,会调用transitionToState(TEST_STATE_SEND_VOTE) + } +} + +void TestPortController::onAudioTimeoutTimer() +{ + // 声音测试超时(5秒) + if (m_test_state == TEST_STATE_WAIT_AUDIO_RESULT) { + // 检查是否已经连续检测到3次以上相同的Level值 + if (m_audio_level_count >= 3 && !m_last_audio_level.isEmpty()) { + // 如果已经连续3次以上相同,直接继续下一步(不打印超时错误) + uart_send_data("AT^AUDIOTEST=6\r\n"); // 停止声音测试 + emit displayMessage(tr("声音测试完成(Level: %1,连续%2次)\r\n") + .arg(m_last_audio_level) + .arg(m_audio_level_count), true); + transitionToState(TEST_STATE_WAIT_SCAN_END); + // 重置计数 + m_last_audio_level.clear(); + m_audio_level_count = 0; + } else { + // 超时后停止声音测试(打印超时错误) + uart_send_data("AT^AUDIOTEST=6\r\n"); // 停止声音测试 + emit displayMessage(tr("声音测试超时,停止测试并继续下一步\r\n"), false); + transitionToState(TEST_STATE_WAIT_SCAN_END); + // 重置计数 + m_last_audio_level.clear(); + m_audio_level_count = 0; + } + } +} + +void TestPortController::onGpioTimeoutTimer() +{ + // GPIO测试超时(10秒) + if (m_test_state == TEST_STATE_WAIT_GPIO_RESULT) { + QString bufferStr = QString::fromLatin1(m_boot_detect_buffer); + + // 检查是否已经检测到 "[GpioTest] Test finished" + if (bufferStr.contains("[GpioTest] Test finished") || bufferStr.contains("Test finished")) { + // 如果已经检测到 "Test finished",检查之前是否检测到过结果 + if (m_gpio_result_detected) { + // 之前检测到过结果,认为成功 + QRegExp resultRegex("(\\d+)\\s+passed[,\\s]+(\\d+)\\s+failed"); + if (resultRegex.indexIn(bufferStr) >= 0) { + int passed = resultRegex.cap(1).toInt(); + int failed = resultRegex.cap(2).toInt(); + emit displayMessage(tr("GPIO测试完成(%1通过,%2失败)\r\n").arg(passed).arg(failed), true); + } else { + emit displayMessage(tr("GPIO测试完成\r\n"), true); + } + transitionToState(TEST_STATE_COMPLETE); + finalizeTestResult(); + } else { + // 之前未检测到结果,认为失败 + emit displayMessage(tr("GPIO测试失败:未检测到测试结果(X passed, Y failed)\r\n"), false); + transitionToState(TEST_STATE_FAILED); + finalizeTestResult(); + } + } else { + // 超时后没有检测到 "Test finished",认为测试失败 + emit displayMessage(tr("GPIO测试失败:超时未检测到Test finished\r\n"), false); + transitionToState(TEST_STATE_FAILED); + finalizeTestResult(); + } + } +} + +void TestPortController::transitionToState(TestState new_state) +{ + if (m_test_state != new_state) { + QString oldStateName = getStateName(m_test_state); + QString newStateName = getStateName(new_state); + qDebug() << tr("端口%1状态转换: %2 -> %3").arg(m_port_index + 1).arg(oldStateName).arg(newStateName); + m_test_state = new_state; + emit statusChanged(newStateName); + } +} + +QString TestPortController::getStateName(TestState state) const +{ + switch (state) { + case TEST_STATE_IDLE: return tr("空闲"); + case TEST_STATE_WAIT_NAND_ID: return tr("等待nand flash id"); + case TEST_STATE_WAIT_NAND_MODEL: return tr("等待nand flash型号"); + case TEST_STATE_WAIT_BLUE_WINDOW: return tr("等待蓝色窗口"); + case TEST_STATE_CHECK_BLUE_COLOR: return tr("检测蓝色"); + case TEST_STATE_SEND_VOTE: return tr("发送投票"); + case TEST_STATE_WAIT_VOTE_SUCCESS: return tr("等待投票成功"); + case TEST_STATE_GET_CPUID: return tr("获取CPUID"); + case TEST_STATE_WAIT_CPUID: return tr("等待CPUID"); + case TEST_STATE_GET_BT_MAC: return tr("获取蓝牙MAC"); + case TEST_STATE_WAIT_BT_MAC: return tr("等待蓝牙MAC"); + case TEST_STATE_ENABLE_BT: return tr("打开蓝牙"); + case TEST_STATE_WAIT_BT_ENABLE: return tr("等待蓝牙打开"); + case TEST_STATE_START_SCAN: return tr("开启扫描"); + case TEST_STATE_WAIT_SCAN_START: return tr("等待开启扫描"); + case TEST_STATE_AUDIO_TEST: return tr("声音测试"); + case TEST_STATE_WAIT_AUDIO_RESULT: return tr("等待音量结果"); + case TEST_STATE_WAIT_SCAN_END: return tr("等待扫描结束"); + case TEST_STATE_GPIO_TEST: return tr("GPIO测试"); + case TEST_STATE_WAIT_GPIO_RESULT: return tr("等待GPIO结果"); + case TEST_STATE_COMPLETE: return tr("测试完成"); + case TEST_STATE_FAILED: return tr("测试失败"); + default: return tr("未知状态"); + } +} + +void TestPortController::processTestCommandResponse() +{ + // 处理测试指令响应 + // 这个函数会在readData中被调用,检查响应缓冲区 +} + +void TestPortController::sendNextTestCommand() +{ + // 根据当前状态发送下一个测试指令 + switch (m_test_state) { + case TEST_STATE_SEND_VOTE: + // 发送投票指令(可以重试2-4次) + if (m_vote_retry_count < 4) { + m_vote_retry_count++; + uart_send_data(ATCMD_ADD_VOTE); + transitionToState(TEST_STATE_WAIT_VOTE_SUCCESS); + emit displayMessage(tr("发送投票指令(第%1次)\r\n").arg(m_vote_retry_count), true); + } else { + emit displayMessage(tr("投票失败,已达到最大重试次数\r\n"), false); + transitionToState(TEST_STATE_FAILED); + } + break; + + case TEST_STATE_GET_CPUID: + uart_send_data(ATCMD_GET_CPUID); + transitionToState(TEST_STATE_WAIT_CPUID); + break; + + case TEST_STATE_GET_BT_MAC: + uart_send_data(ATCMD_GET_MAC); + transitionToState(TEST_STATE_WAIT_BT_MAC); + break; + + case TEST_STATE_ENABLE_BT: + // 需要添加ATCMD_ENABLE_BT定义 + uart_send_data("AT^BTENABLE\r\n"); + transitionToState(TEST_STATE_WAIT_BT_ENABLE); + break; + + case TEST_STATE_START_SCAN: + uart_send_data("AT^BTSCANTEST=1\r\n"); + transitionToState(TEST_STATE_WAIT_SCAN_START); + break; + + case TEST_STATE_AUDIO_TEST: + // 声音测试指令:AT^AUDIOTEST=5 启动测试 + qDebug() << tr("端口%1 发送声音测试指令: AT^AUDIOTEST=5").arg(m_port_index + 1); + // 重置音量Level计数 + m_last_audio_level.clear(); + m_audio_level_count = 0; + uart_send_data("AT^AUDIOTEST=5\r\n"); + transitionToState(TEST_STATE_WAIT_AUDIO_RESULT); + // 启动5秒超时定时器 + m_audio_timeout_timer->start(5000); + qDebug() << tr("端口%1 声音测试指令已发送,状态已转换为等待结果,超时定时器已启动").arg(m_port_index + 1); + break; + + case TEST_STATE_GPIO_TEST: + // GPIO测试指令:AT^GPIOTEST=2 启动测试 + uart_send_data("AT^GPIOTEST=2\r\n"); + transitionToState(TEST_STATE_WAIT_GPIO_RESULT); + // 重置GPIO结果检测标志 + m_gpio_result_detected = false; + // 启动GPIO测试超时定时器(10秒) + m_gpio_timeout_timer->start(10000); + qDebug() << tr("端口%1 GPIO测试指令已发送,启动10秒超时定时器").arg(m_port_index + 1); + break; + + default: + break; + } +} + +void TestPortController::finalizeTestResult() +{ + // 统计所有测试结果 + m_test_result_summary = tr("测试完成\r\n"); + m_test_result_summary += tr("成功: %1\r\n").arg(m_write_success_count); + m_test_result_summary += tr("失败: %1\r\n").arg(m_write_fail_count); + + emit displayMessage(m_test_result_summary, m_write_fail_count == 0); + + if (m_write_fail_count == 0) { + emit showResult(tr("所有测试通过"), true); + m_write_success_count++; + } else { + emit showResult(tr("测试失败"), false); + m_write_fail_count++; + } + + emit successCountChanged(m_write_success_count); + emit failCountChanged(m_write_fail_count); +} + diff --git a/test_port_controller.h b/test_port_controller.h index 6e21501..d468f80 100644 --- a/test_port_controller.h +++ b/test_port_controller.h @@ -87,6 +87,43 @@ private: qint64 m_bytesToWrite; // 指令长度 int m_cmd_index; // 指令顺序: 0=AT投票, 1=GET_MAC, 2=SET_MAC, 3=GET_MAC验证, 4=GET_CPUID, 5=POWEROFF QString m_G_cmd; // 当前执行的AT命令 + + // 新的测试流程状态 + enum TestState { + TEST_STATE_IDLE = 0, // 空闲状态 + TEST_STATE_WAIT_NAND_ID, // 等待nand flash id + TEST_STATE_WAIT_NAND_MODEL, // 等待nand flash型号 + TEST_STATE_WAIT_BLUE_WINDOW, // 等待蓝色窗口 + TEST_STATE_CHECK_BLUE_COLOR, // 检测蓝色(延迟1s) + TEST_STATE_SEND_VOTE, // 发送投票指令 + TEST_STATE_WAIT_VOTE_SUCCESS, // 等待投票成功 + TEST_STATE_GET_CPUID, // 获取CPUID + TEST_STATE_WAIT_CPUID, // 等待CPUID + TEST_STATE_GET_BT_MAC, // 获取蓝牙MAC + TEST_STATE_WAIT_BT_MAC, // 等待蓝牙MAC + TEST_STATE_ENABLE_BT, // 打开蓝牙 + TEST_STATE_WAIT_BT_ENABLE, // 等待蓝牙打开成功 + TEST_STATE_START_SCAN, // 开启扫描 + TEST_STATE_WAIT_SCAN_START, // 等待开启扫描 + TEST_STATE_AUDIO_TEST, // 执行声音测试 + TEST_STATE_WAIT_AUDIO_RESULT, // 等待音量结果(3-5秒超时) + TEST_STATE_WAIT_SCAN_END, // 等待蓝牙扫描结束 + TEST_STATE_GPIO_TEST, // 执行GPIO测试 + TEST_STATE_WAIT_GPIO_RESULT, // 等待GPIO测试结果 + TEST_STATE_COMPLETE, // 测试完成 + TEST_STATE_FAILED // 测试失败 + }; + + TestState m_test_state; // 当前测试状态 + int m_vote_retry_count; // 投票重试次数(最多4次) + QTimer *m_color_check_timer; // 颜色检测定时器(延迟1s) + QTimer *m_audio_timeout_timer; // 声音测试超时定时器(3-5秒) + QTimer *m_gpio_timeout_timer; // GPIO测试超时定时器 + bool m_blue_color_detected; // 蓝色是否已检测 + QString m_test_result_summary; // 测试结果汇总 + QString m_last_audio_level; // 上次检测到的音量Level值 + int m_audio_level_count; // 连续相同Level的计数 + bool m_gpio_result_detected; // GPIO测试结果是否已检测到(X passed, Y failed) // 状态标志 bool m_working_state; // true=写号执行中, false=写号结束 @@ -114,6 +151,18 @@ private: void spp_timer_callback(); void resetState(); void clearBuffers(); + + // 新测试流程相关函数 + void processNewTestFlow(); // 处理新测试流程 + void checkLogMessages(); // 检查日志消息 + void onColorCheckTimer(); // 颜色检测定时器回调 + void onAudioTimeoutTimer(); // 声音测试超时定时器回调 + void onGpioTimeoutTimer(); // GPIO测试超时定时器回调 + void transitionToState(TestState new_state); // 状态转换 + QString getStateName(TestState state) const; // 获取状态名称 + void processTestCommandResponse(); // 处理测试指令响应 + void sendNextTestCommand(); // 发送下一个测试指令 + void finalizeTestResult(); // 完成测试结果统计 }; #endif // TEST_PORT_CONTROLLER_H diff --git "a/\346\265\213\350\257\225\346\265\201\347\250\213\346\214\207\344\273\244\351\241\272\345\272\217\345\210\206\346\236\220.md" "b/\346\265\213\350\257\225\346\265\201\347\250\213\346\214\207\344\273\244\351\241\272\345\272\217\345\210\206\346\236\220.md" new file mode 100644 index 0000000..ed351a8 --- /dev/null +++ "b/\346\265\213\350\257\225\346\265\201\347\250\213\346\214\207\344\273\244\351\241\272\345\272\217\345\210\206\346\236\220.md" @@ -0,0 +1,338 @@ +# 测试流程指令顺序分析 + +## 测试流程状态机执行顺序 + +### 初始状态 +- **状态**: `TEST_STATE_WAIT_NAND_ID` (等待nand flash id) +- **触发**: `connectPort()` 函数调用时初始化 +- **显示**: "等待设备启动..." + +--- + +### 步骤1: 检测 NAND Flash ID +- **状态**: `TEST_STATE_WAIT_NAND_ID` +- **检测位置**: `readData()` 函数 (行302-357) +- **检测内容**: + - 日志关键字: `"find nand flash chip id"` 或 `"nand flash chip id"` + - 提取ID格式: `0xXXXX` (4位十六进制) +- **检测方法**: + - 在 `QByteArray` 上直接搜索(不区分大小写) + - 使用正则表达式或简单匹配提取ID +- **成功动作**: + - 清空显示窗口 + - 显示: "=== 新一轮检测开始 ===" + - 显示: "✓ 检测到nand flash id: 0xXXXX" + - 状态转换: `TEST_STATE_WAIT_NAND_MODEL` + +--- + +### 步骤2: 检测 NAND Flash 型号 +- **状态**: `TEST_STATE_WAIT_NAND_MODEL` +- **检测位置**: `readData()` 函数 (行360-387) +- **检测内容**: + - 日志关键字: `"nand flash"` + `"start init"` 或 `" init"` + - 提取型号: 例如 `XT26Q02D` +- **检测方法**: + - 正则表达式: `"nand flash\\s+([A-Z0-9]+)\\s+start init"` 或 `"nand flash\\s+([A-Z0-9]+)"` +- **成功动作**: + - 显示: "✓ 检测到nand flash型号: XT26Q02D" + - 状态转换: `TEST_STATE_WAIT_BLUE_WINDOW` + +--- + +### 步骤3: 检测蓝色窗口创建 +- **状态**: `TEST_STATE_WAIT_BLUE_WINDOW` +- **检测位置**: `readData()` 函数 (行389-399) +- **检测内容**: + - 日志关键字: `"Blue window created and displayed:"` +- **成功动作**: + - 显示: "✓ 检测到蓝色窗口已创建" + - 状态转换: `TEST_STATE_CHECK_BLUE_COLOR` + - 启动1秒延迟定时器 (`m_color_check_timer->start(1000)`) + +--- + +### 步骤4: 检测LCD蓝色(RGB传感器) +- **状态**: `TEST_STATE_CHECK_BLUE_COLOR` +- **检测位置**: RGB串口信号回调 (行59-65) +- **检测内容**: + - RGB传感器检测到颜色名称包含 "蓝色" + - 通过 `RgbSerialReader::rgbcDataParsedWithColor` 信号触发 +- **成功动作**: + - 显示: "LCD颜色检测通过(蓝色)" + - 状态转换: `TEST_STATE_SEND_VOTE` + - 重置投票重试计数: `m_vote_retry_count = 0` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤5: 发送投票指令 +- **状态**: `TEST_STATE_SEND_VOTE` +- **执行位置**: `sendNextTestCommand()` 函数 (行882-893) +- **发送指令**: `ATCMD_ADD_VOTE` (`"AT^PMADDVOTE\r\n"`) +- **重试机制**: + - 最多重试4次 (`m_vote_retry_count < 4`) + - 每次重试递增计数 +- **超时设置**: 1.5秒 (在 `uart_send_data()` 中设置) +- **超时处理**: 如果超时,自动重发投票指令 (行669-670) +- **成功动作**: + - 显示: "发送投票指令(第X次)" + - 状态转换: `TEST_STATE_WAIT_VOTE_SUCCESS` +- **失败动作**: + - 如果达到最大重试次数,显示: "投票失败,已达到最大重试次数" + - 状态转换: `TEST_STATE_FAILED` + +--- + +### 步骤6: 检测投票成功 +- **状态**: `TEST_STATE_WAIT_VOTE_SUCCESS` +- **检测位置**: `checkLogMessages()` 函数 (行734-739) +- **检测内容**: + - 日志关键字: `"MCU WAKEUP SUCCESS"` 或 `"OK~"` +- **成功动作**: + - 显示: "投票成功" + - 状态转换: `TEST_STATE_GET_CPUID` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤7: 获取CPUID +- **状态**: `TEST_STATE_GET_CPUID` +- **执行位置**: `sendNextTestCommand()` 函数 (行895-898) +- **发送指令**: `ATCMD_GET_CPUID` (`"AT^GETIDS\r\n"`) +- **超时设置**: 5秒 +- **成功动作**: + - 状态转换: `TEST_STATE_WAIT_CPUID` + +--- + +### 步骤8: 检测CPUID响应 +- **状态**: `TEST_STATE_WAIT_CPUID` +- **检测位置**: `checkLogMessages()` 函数 (行742-747) +- **检测内容**: + - 日志关键字: `"OK~"` 且 `"nandflash id:"` +- **成功动作**: + - 显示: "获取CPUID成功" + - 状态转换: `TEST_STATE_GET_BT_MAC` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤9: 获取蓝牙MAC地址 +- **状态**: `TEST_STATE_GET_BT_MAC` +- **执行位置**: `sendNextTestCommand()` 函数 (行900-903) +- **发送指令**: `ATCMD_GET_MAC` (`"AT^GETBTMAC\r\n"`) +- **超时设置**: 3秒 +- **成功动作**: + - 状态转换: `TEST_STATE_WAIT_BT_MAC` + +--- + +### 步骤10: 检测蓝牙MAC响应 +- **状态**: `TEST_STATE_WAIT_BT_MAC` +- **检测位置**: `checkLogMessages()` 函数 (行750-755) +- **检测内容**: + - 日志关键字: `"BTMAC="` 或 `"OK~"` +- **成功动作**: + - 显示: "获取蓝牙MAC成功" + - 状态转换: `TEST_STATE_ENABLE_BT` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤11: 打开蓝牙 +- **状态**: `TEST_STATE_ENABLE_BT` +- **执行位置**: `sendNextTestCommand()` 函数 (行905-909) +- **发送指令**: `"AT^BTENABLE\r\n"` +- **超时设置**: 1.5秒 +- **成功动作**: + - 状态转换: `TEST_STATE_WAIT_BT_ENABLE` + +--- + +### 步骤12: 检测蓝牙打开成功 +- **状态**: `TEST_STATE_WAIT_BT_ENABLE` +- **检测位置**: `checkLogMessages()` 函数 (行758-763) +- **检测内容**: + - 日志关键字: `"bt enable ok"` (不区分大小写) 或 `"OK~"` +- **成功动作**: + - 显示: "蓝牙打开成功" + - 状态转换: `TEST_STATE_START_SCAN` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤13: 开启蓝牙扫描 +- **状态**: `TEST_STATE_START_SCAN` +- **执行位置**: `sendNextTestCommand()` 函数 (行911-914) +- **发送指令**: `"AT^BTSCANTEST=1\r\n"` +- **超时设置**: 1.5秒 +- **成功动作**: + - 状态转换: `TEST_STATE_WAIT_SCAN_START` + +--- + +### 步骤14: 检测扫描启动成功 +- **状态**: `TEST_STATE_WAIT_SCAN_START` +- **检测位置**: `checkLogMessages()` 函数 (行766-771) +- **检测内容**: + - 日志关键字: `"Starting Bluetooth scan test"` 或 `"OK~"` +- **成功动作**: + - 显示: "开启扫描成功" + - 状态转换: `TEST_STATE_AUDIO_TEST` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤15: 执行声音测试 +- **状态**: `TEST_STATE_AUDIO_TEST` +- **执行位置**: `sendNextTestCommand()` 函数 (行916-922) +- **发送指令**: `"AT^AUDIOTEST\r\n"` (假设的指令,需要确认实际指令) +- **超时设置**: 1.5秒 +- **超时定时器**: 启动5秒超时定时器 (`m_audio_timeout_timer->start(5000)`) +- **成功动作**: + - 状态转换: `TEST_STATE_WAIT_AUDIO_RESULT` + +--- + +### 步骤16: 检测音量结果 +- **状态**: `TEST_STATE_WAIT_AUDIO_RESULT` +- **检测位置**: `checkLogMessages()` 函数 (行774-787) +- **检测内容**: + - 日志关键字: `"音量"` 或 `"volume"` 或 `"高"` 或 `"中"` 或 `"低"` 或 `"极低"` + - 使用 `QString::fromLatin1()` 转换缓冲区以支持中文搜索 +- **超时处理**: + - 如果5秒内未检测到结果,`onAudioTimeoutTimer()` 回调触发 + - 显示: "声音测试超时,继续下一步" + - 状态转换: `TEST_STATE_WAIT_SCAN_END` +- **成功动作**: + - 停止超时定时器 + - 显示: "声音测试完成" + - 状态转换: `TEST_STATE_WAIT_SCAN_END` + +--- + +### 步骤17: 检测蓝牙扫描结束 +- **状态**: `TEST_STATE_WAIT_SCAN_END` +- **检测位置**: `checkLogMessages()` 函数 (行789-795) +- **检测内容**: + - 日志关键字: `"Bluetooth scan test completed"` 或 `"scan test end"` (不区分大小写) 或 `"OK~"` +- **成功动作**: + - 显示: "蓝牙扫描结束" + - 状态转换: `TEST_STATE_GPIO_TEST` + - 调用 `sendNextTestCommand()` + +--- + +### 步骤18: 执行GPIO测试 +- **状态**: `TEST_STATE_GPIO_TEST` +- **执行位置**: `sendNextTestCommand()` 函数 (行924-928) +- **发送指令**: `"AT^GPIOTEST\r\n"` (假设的指令,需要确认实际指令) +- **超时设置**: 1.5秒 +- **成功动作**: + - 状态转换: `TEST_STATE_WAIT_GPIO_RESULT` + +--- + +### 步骤19: 检测GPIO测试结果 +- **状态**: `TEST_STATE_WAIT_GPIO_RESULT` +- **检测位置**: `checkLogMessages()` 函数 (行798-804) +- **检测内容**: + - 日志关键字: `"gpio test"` (不区分大小写) 或 `"OK~"` +- **成功动作**: + - 显示: "GPIO测试完成" + - 状态转换: `TEST_STATE_COMPLETE` + - 调用 `finalizeTestResult()` + +--- + +### 步骤20: 完成测试并统计结果 +- **状态**: `TEST_STATE_COMPLETE` +- **执行位置**: `finalizeTestResult()` 函数 (行935-954) +- **统计内容**: + - 成功计数: `m_write_success_count` + - 失败计数: `m_write_fail_count` +- **显示内容**: + - "测试完成" + - "成功: X" + - "失败: Y" +- **结果判断**: + - 如果 `m_write_fail_count == 0`: 显示 "所有测试通过" (成功) + - 否则: 显示 "测试失败" (失败) +- **更新计数**: 根据结果更新成功或失败计数 + +--- + +## 关键函数说明 + +### 1. `readData()` (行230-489) +- **作用**: 接收DUT串口数据,检测启动日志(flash id、型号、蓝色窗口) +- **调用时机**: DUT串口有数据到达时 (`onReadyRead()`) +- **主要检测**: + - NAND Flash ID (行302-357) + - NAND Flash 型号 (行360-387) + - 蓝色窗口 (行389-399) +- **然后调用**: `checkLogMessages()` 处理其他日志消息 + +### 2. `checkLogMessages()` (行723-809) +- **作用**: 根据当前测试状态检查相应的日志消息 +- **调用时机**: `readData()` 中,当 `m_test_state != TEST_STATE_IDLE` 时 +- **检测内容**: 根据状态机当前状态检测对应的日志关键字 + +### 3. `sendNextTestCommand()` (行878-933) +- **作用**: 根据当前测试状态发送下一个AT命令 +- **调用时机**: + - 检测到日志消息后自动调用 + - 状态转换到需要发送命令的状态时 +- **发送指令**: 根据状态发送相应的AT命令 + +### 4. `uart_send_data()` (行633-653) +- **作用**: 发送AT命令到DUT串口 +- **超时设置**: + - GETIDS: 5秒 + - GETBTMAC: 3秒 + - 其他: 1.5秒 +- **超时处理**: `spp_timer_callback()` 函数处理超时 + +### 5. `transitionToState()` (行832-841) +- **作用**: 状态转换,更新UI状态显示 +- **调用时机**: 检测到日志消息或命令响应后 + +--- + +## 数据流说明 + +### 缓冲区管理 +1. **`m_boot_detect_buffer`**: 开机检测数据缓存 + - 最大16KB,超过时智能截断(保留flash信息) + - 用于检测启动日志 + +2. **`m_uart_rx_buff_array`**: AT命令响应缓冲区 + - 用于接收AT命令的响应数据 + - 检测结束标志: `"OK~"`, `"power off device!"`, `"DSP0 power down"` + +### 编码处理 +- **问题**: 缓冲区可能包含非UTF-8数据(乱码/二进制) +- **解决方案**: + - 在 `QByteArray` 上直接搜索(`indexOf()`, `contains()`) + - 需要字符串匹配时使用 `QString::fromLatin1()` 转换 + +--- + +## 注意事项 + +1. **投票指令重试**: 最多4次,每次超时自动重发 +2. **声音测试超时**: 5秒超时,超时后继续下一步 +3. **颜色检测**: 通过RGB串口传感器检测,延迟1秒后检测 +4. **状态转换**: 所有状态转换都会更新UI状态显示 +5. **错误处理**: 投票失败会转换到 `TEST_STATE_FAILED` 状态 + +--- + +## 待确认的指令 + +1. **声音测试指令**: `"AT^AUDIOTEST\r\n"` (行918) - 需要确认实际指令 +2. **GPIO测试指令**: `"AT^GPIOTEST\r\n"` (行926) - 需要确认实际指令 + +这些指令在代码中标记为"假设的指令",需要根据实际设备协议确认。 +