Merge pull request #13 from raph2i/add_qpiri
Add qpiri as a config value
This commit is contained in:
@@ -21,3 +21,7 @@ amperage_factor=1.0
|
||||
# This allos you to modify the wattage in case the inverter is giving an incorrect
|
||||
# reading compared to measurement tools. Normally this will remain '1'
|
||||
watt_factor=1.01
|
||||
|
||||
# This allows you to modify the buffersize for the qpiri command
|
||||
# as mentioned in https://github.com/ned-kelly/docker-voltronic-homeassistant/issues/5
|
||||
qpiri=97
|
||||
|
||||
@@ -21,3 +21,5 @@ amperage_factor=1.0
|
||||
# This allos you to modify the wattage in case the inverter is giving an incorrect
|
||||
# reading compared to measurement tools. Normally this will remain '1'
|
||||
watt_factor=1.01
|
||||
|
||||
qpiri=97
|
||||
|
||||
@@ -9,12 +9,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
|
||||
cInverter::cInverter(std::string devicename) {
|
||||
cInverter::cInverter(std::string devicename, int qpiri) {
|
||||
device = devicename;
|
||||
status1[0] = 0;
|
||||
status2[0] = 0;
|
||||
warnings[0] = 0;
|
||||
mode = 0;
|
||||
qpiri = qpiri;
|
||||
}
|
||||
|
||||
string *cInverter::GetQpigsStatus() {
|
||||
@@ -153,6 +154,7 @@ bool cInverter::query(const char *cmd, int replysize) {
|
||||
|
||||
void cInverter::poll() {
|
||||
int n,j;
|
||||
extern const int qpiri;
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -176,7 +178,7 @@ void cInverter::poll() {
|
||||
|
||||
// Reading QPIRI status
|
||||
if (!ups_qpiri_changed) {
|
||||
if (query("QPIRI", 97)) {
|
||||
if (query("QPIRI", qpiri)) {
|
||||
m.lock();
|
||||
strcpy(status2, (const char*)buf+1);
|
||||
m.unlock();
|
||||
|
||||
@@ -23,7 +23,7 @@ class cInverter {
|
||||
uint16_t cal_crc_half(uint8_t *pin, uint8_t len);
|
||||
|
||||
public:
|
||||
cInverter(std::string devicename);
|
||||
cInverter(std::string devicename, int qpiri);
|
||||
void poll();
|
||||
void runMultiThread() {
|
||||
std::thread t1(&cInverter::poll, this);
|
||||
|
||||
@@ -43,6 +43,7 @@ string devicename;
|
||||
int runinterval;
|
||||
float ampfactor;
|
||||
float wattfactor;
|
||||
int qpiri;
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
@@ -90,6 +91,8 @@ void getSettingsFile(string filename) {
|
||||
attemptAddSetting(&wattfactor, linepart2);
|
||||
else if(linepart1 == "watt_factor")
|
||||
attemptAddSetting(&wattfactor, linepart2);
|
||||
else if(linepart1 == "qpiri")
|
||||
attemptAddSetting(&qpiri, linepart2);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
@@ -171,7 +174,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
bool ups_status_changed(false);
|
||||
ups = new cInverter(devicename);
|
||||
ups = new cInverter(devicename,qpiri);
|
||||
|
||||
// Logic to send 'raw commands' to the inverter..
|
||||
if (!rawcmd.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user