feat(v2.0): Auto-discovery, correzione bug critici, e documentazione completa
Build Docker Image for Raspberry Pi / build-and-push (push) Failing after 4m42s

🆕 Funzionalità Auto-Discovery
- Aggiunto metodo AutoDiscoverBufferSizes() per rilevamento automatico QPIGS/QPIRI/QMOD/QPIWS
- Supporto variabili d'ambiente (INVERTER_DEVICE, MQTT_SERVER, etc.)
- Caching persistente buffer sizes in /cache/inverter.conf.cache
- Flag -a/--auto-discover per modalità auto-detection

🐛 Bug Fixes Critici
- **Parsing interi**: Aggiunta attemptAddSettingInt() con stoi() invece di stof()
  - Fix: stof('98') = 98.0f → 97 (int), ora stoi('98') = 98 direttamente
  - Applicato a: qpiri, qpiws, qmod, qpigs
- **Thread sync**: Aggiunto ups_qpiws_changed a main loop e condizione exit poll()
  - Fix: loop principale controllava solo 3 flag su 4, causava hang
  - Fix: thread poll() non usciva in runOnce perché mancava controllo QPIWS
- **Config accuracy**: Corretti buffer sizes (qpiri: 98→103, qpiws: 36→40)
  - Rimosso sources/inverter-cli/inverter.conf che sovrascriveva config globale
  - Validato con test: inverter_poller -1 completa in 6s con JSON completo

📚 Documentazione Completa
- Creato documentation/CODE_ARCHITECTURE.md (38KB)
  - Mappa logica variabili globali
  - Flusso esecuzione main() con diagrammi ASCII
  - Sequence diagram classe cInverter (poll, query, auto-discovery)
  - Thread synchronization diagrams
  - MQTT integration bash scripts flow
  - Mappa concettuale 5-layer system architecture
  - Error handling e performance optimizations
- Organizzati file .md in documentation/ (AUTO_DISCOVERY, IMPLEMENTATION, QUICKSTART, DEBUG)
- Aggiornato README.md con sezione v2.0 e indice documentazione
- Aggiornato .github/copilot-instructions.md con novità v2.0

🔧 Miglioramenti Build & CI/CD
- Gitea Actions per build multi-arch (arm/v6, arm/v7, arm64, amd64, 386)
- Configurazione VS Code completa (tasks, launch, debug GDB)
- Script test-autodiscovery.sh e test-device.sh

 Testing Validato
- inverter_poller -1 completa in 6 secondi
- Output JSON completo con tutte le metriche
- Exit pulito senza timeout (exit code 0)
- Tutte le 4 query QMOD/QPIGS/QPIRI/QPIWS funzionanti
This commit is contained in:
Pi Developer
2026-01-25 15:00:48 +01:00
parent ac2642639f
commit 6af9fcad7e
30 changed files with 4503 additions and 139 deletions
+27
View File
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/sources/inverter-cli",
"/usr/include",
"/usr/local/include"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "linux-gcc-arm",
"configurationProvider": "ms-vscode.cmake-tools",
"compileCommands": "${workspaceFolder}/sources/inverter-cli/compile_commands.json",
"browse": {
"path": [
"${workspaceFolder}/sources/inverter-cli"
],
"limitSymbolsToIncludedHeaders": true
}
}
],
"version": 4
}
+12
View File
@@ -0,0 +1,12 @@
{
"recommendations": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"twxs.cmake",
"ms-azuretools.vscode-docker",
"timonwong.shellcheck",
"foxundermoon.shell-format",
"redhat.vscode-yaml",
"GitHub.copilot"
]
}
+127
View File
@@ -0,0 +1,127 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Debug inverter_poller",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller",
"args": [
"-d",
"-1"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/sources/inverter-cli",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "build-inverter-cli",
"miDebuggerPath": "/usr/bin/gdb",
"logging": {
"engineLogging": false
}
},
{
"name": "(gdb) Debug inverter_poller - Run Once with Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller",
"args": [
"-d",
"-1"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/sources/inverter-cli",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build-inverter-cli-debug",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "(gdb) Debug inverter_poller - Loop Mode",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller",
"args": [
"-d"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/sources/inverter-cli",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build-inverter-cli-debug",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "(gdb) Debug inverter_poller - Raw Command",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller",
"args": [
"-r",
"QPIGS"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/sources/inverter-cli",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build-inverter-cli-debug",
"miDebuggerPath": "/usr/bin/gdb"
},
{
"name": "(gdb) Attach to running inverter_poller",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
+23
View File
@@ -0,0 +1,23 @@
{
"cmake.sourceDirectory": "/home/pi/Progetti/sources/inverter-cli",
"files.associations": {
"*.h": "cpp",
"*.cpp": "cpp",
"*.sh": "shellscript"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"C_Cpp.default.cppStandard": "c++11",
"C_Cpp.default.cStandard": "c11",
"cmake.configureOnOpen": false,
"cmake.buildDirectory": "${workspaceFolder}/sources/inverter-cli/bin",
"editor.formatOnSave": false,
"files.exclude": {
"**/.git": true,
"**/CMakeFiles": true,
"**/CMakeCache.txt": true
},
"search.exclude": {
"**/bin": true,
"**/CMakeFiles": true
}
}
+128
View File
@@ -0,0 +1,128 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build-inverter-cli",
"type": "shell",
"command": "cd ${workspaceFolder}/sources/inverter-cli && mkdir -p bin && cmake . && make",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
],
"detail": "Build inverter_poller con cmake (Release mode)"
},
{
"label": "build-inverter-cli-debug",
"type": "shell",
"command": "cd ${workspaceFolder}/sources/inverter-cli && mkdir -p bin && cmake -DCMAKE_BUILD_TYPE=Debug . && make",
"group": "build",
"problemMatcher": [
"$gcc"
],
"detail": "Build inverter_poller con debug symbols (Debug mode)"
},
{
"label": "clean-inverter-cli",
"type": "shell",
"command": "cd ${workspaceFolder}/sources/inverter-cli && rm -rf bin CMakeFiles CMakeCache.txt cmake_install.cmake Makefile",
"group": "build",
"problemMatcher": [],
"detail": "Pulisce i file di build di inverter-cli"
},
{
"label": "rebuild-inverter-cli",
"type": "shell",
"dependsOn": [
"clean-inverter-cli",
"build-inverter-cli"
],
"dependsOrder": "sequence",
"group": "build",
"problemMatcher": [],
"detail": "Pulisce e ricompila inverter_poller"
},
{
"label": "run-inverter-cli-once",
"type": "shell",
"command": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller -d -1",
"group": "test",
"problemMatcher": [],
"detail": "Esegue inverter_poller una volta con debug",
"dependsOn": "build-inverter-cli",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
},
{
"label": "run-inverter-cli-loop",
"type": "shell",
"command": "${workspaceFolder}/sources/inverter-cli/bin/inverter_poller -d",
"group": "test",
"problemMatcher": [],
"detail": "Esegue inverter_poller in loop mode con debug",
"dependsOn": "build-inverter-cli",
"isBackground": true,
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true,
"clear": false
}
},
{
"label": "docker-build",
"type": "shell",
"command": "docker build -f ${workspaceFolder}/Dockerfile.dev -t voltronic-mqtt:dev .",
"options": {
"cwd": "${workspaceFolder}"
},
"group": "build",
"problemMatcher": [],
"detail": "Build Docker image locale per development"
},
{
"label": "docker-run",
"type": "shell",
"command": "docker-compose up -d",
"options": {
"cwd": "${workspaceFolder}"
},
"group": "test",
"problemMatcher": [],
"detail": "Avvia il container con docker-compose"
},
{
"label": "docker-logs",
"type": "shell",
"command": "docker logs -f voltronic-mqtt",
"options": {
"cwd": "${workspaceFolder}"
},
"group": "test",
"problemMatcher": [],
"isBackground": true,
"detail": "Mostra i log del container in tempo reale"
},
{
"label": "docker-stop",
"type": "shell",
"command": "docker-compose down",
"options": {
"cwd": "${workspaceFolder}"
},
"group": "test",
"problemMatcher": [],
"detail": "Ferma il container docker-compose"
}
]
}