-
Notifications
You must be signed in to change notification settings - Fork 0
/
x16ppd.h
96 lines (84 loc) · 2.15 KB
/
x16ppd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
#include "pstream.h"
//#ifdef __arm__
#include "pportbone.h"
//#else
// #include "pportlpt.h"
//#endif
class PPCmd{
public:
std::string mCmd;
std::vector<std::string> mArgs;
virtual int init(std::string cCmd, int cArgNum);
void setArg(int cArgNum, std::string cArg);
std::string getCmd();
virtual void run();
};
class PPCmdGetRetVal : public PPCmd{
public:
virtual int check();
virtual void run();
};
class PPCmdCheckRetVal : public PPCmd {
public:
PPCmdGetRetVal mCmdCheck;
};
class PPCmdHostStat : public PPCmd{
public:
PPCmdHostStat();
virtual void run();
};
class PPCmdPing : public PPCmd{
public:
PPCmdPing();
void setHost(std::string cHost);
void setCount(std::string cCount);
virtual void run();
};
class PPCmdWget : public PPCmdCheckRetVal{
public:
PPCmdWget();
void setURL(std::string cURL);
virtual void run();
};
class PPDaemon {
public:
PPort mPort;
int mMode = PPDM_INIT;
int mState = PPDS_IDLE;
int mError = PPDERR_NONE;
redi::pstream mProcess;
unsigned char mOutData;
unsigned char mInData;
std::vector<unsigned char> mOutBuf;
std::vector<unsigned char> mInBuf;
bool bRunning = true;
bool init();
void send(unsigned char cData);
unsigned char recive();
void send(std::string cStrSend);
void send(int cBytes);
void recive(int cBytes);
void setMode(int cMode);
void setState(int cState);
void handleEvent(int cEvent);
void throwError(int cError, std::string cErrMsg);
void handleError(std::string cErrMsg);
void handleState();
void handleState(int cState);
int getValue(int cVal);
int run();
void close();
};