Files
docker-voltronic-homeassistant/sources/inverter-cli/inverter.h
T
Pi Developer 547537e761
Build Docker Image for Raspberry Pi / build-and-push (push) Failing after 1m15s
Implementazione supporto multi-inverter paralleli e fix comunicazione MQTT
- Aggiunto supporto lettura inverter paralleli tramite comandi QPGS0-QPGS9
- Implementato discovery automatico inverter con filtro duplicati e serial invalidi
- Risolti bug critici comunicazione seriale:
  * Fix buffer ExecuteCmd da 7 a 200 bytes
  * Supporto terminatori CR e LF
  * Modalità blocking con delay 500ms
  * Lettura byte-by-byte per terminatore affidabile
- Implementato script MQTT per pubblicazione dati multi-inverter:
  * mqtt-push-parallel.sh con topic separati per ogni inverter
  * Fix autenticazione MQTT con username/password
  * Aggiunto flag retain (-r) per persistenza dati
- Creato test-loop-parallel.sh per simulazione completa container
- Aggiornata documentazione con compatibilità MKS IV e guida test loop
- Aggiornati profili debug VS Code per bash e parallel discovery
- Configurazione MQTT completa con server reale (192.168.1.37:1883)

Sistema testato e funzionante con 2 inverter Voltronic Axpert MKS IV
2026-01-31 16:15:26 +01:00

53 lines
1.3 KiB
C++

#ifndef ___INVERTER_H
#define ___INVERTER_H
#include <string>
#include <thread>
#include <mutex>
using namespace std;
class cInverter {
unsigned char buf[1024]; //internal work buffer
char warnings[1024];
char status1[1024];
char status2[1024];
char mode;
std::string device;
std::mutex m;
// Buffer sizes for different commands
int buf_qpiri;
int buf_qpiws;
int buf_qmod;
int buf_qpigs;
void SetMode(char newmode);
bool CheckCRC(unsigned char *buff, int len);
bool query(const char *cmd, int replysize);
int query_auto(const char *cmd, int max_size);
uint16_t cal_crc_half(uint8_t *pin, uint8_t len);
public:
cInverter(std::string devicename, int qpiri, int qpiws, int qmod, int qpigs);
void poll();
void runMultiThread() {
std::thread t1(&cInverter::poll, this);
t1.detach();
}
string *GetQpiriStatus();
string *GetQpigsStatus();
string *GetWarnings();
int GetMode();
void ExecuteCmd(const std::string cmd);
void AutoDiscoverBufferSizes();
int DiscoverParallelInverters(); // Returns number of parallel inverters
string GetParallelStatus(int inverter_num); // Get QPGS data for specific inverter
};
#endif // ___INVERTER_H