refactor for better support with ch341 and other unreliable rs232 adapters

This commit is contained in:
David
2019-07-27 22:34:34 +10:00
parent c9ba895410
commit ccb999b8dc
28 changed files with 800 additions and 774 deletions
+41
View File
@@ -0,0 +1,41 @@
#ifndef ___INVERTER_H
#define ___INVERTER_H
#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;
void SetMode(char newmode);
bool CheckCRC(unsigned char *buff, int len);
bool query(const char *cmd, int replysize);
uint16_t cal_crc_half(uint8_t *pin, uint8_t len);
public:
cInverter(std::string devicename);
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);
};
#endif // ___INVERTER_H