-
Notifications
You must be signed in to change notification settings - Fork 0
/
BayDebug.h
91 lines (71 loc) · 1.65 KB
/
BayDebug.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
/*
* Serial Debugging Class
*
* S.Holzheu ([email protected])
*
* This is a Class sending BayEOS-Frames in a human readable form
* helps debugging Arduino-BayEOS-Projects...
*
*/
#ifndef BayDEBUG_h
#define BayDEBUG_h
#include <BayEOS.h>
class BayEOSDebugInterface : virtual public Stream, public BayEOS {
public:
using Print::write; // pull in write(str) and write(buf, size) from Print
uint8_t sendPayload(void);
protected:
uint8_t _modus;
uint8_t _error_next;
private:
uint8_t _checksum;
void parse(uint8_t offset=0);
void parseDataFrame(uint8_t offset);
float getFloat(uint8_t offset);
long getLong(uint8_t offset);
int16_t getInt16(uint8_t offset);
};
class BayDebugCharbuffer : public BayEOSDebugInterface {
public:
/**
* Constructor
*/
BayDebugCharbuffer(char* buffer, int size);
char* get(void);
uint8_t sendPayload(void);
private:
char* _buffer;
char _tmp[12]; //for itoa...
int _size;
int _pos;
int available(void);
int read(void);
size_t write(uint8_t b);
int peek(void);
void flush(void);
};
class BayDebug : public BayEOSDebugInterface {
public:
/**
* Constructor
*/
BayDebug(HardwareSerial &serial);
/**
* Begin Serial connection...
* modus=0 -> Print out Hex
* modus=1 -> Print out frames in human readable form
* modus=2 -> Print out Hex with send error every second frame
* modus=3 -> Print out frames in human readable form
* with send error every second frame
*
**/
void begin(long baud,uint8_t modus=3);
private:
HardwareSerial* _serial;
int available(void);
int read(void);
size_t write(uint8_t b);
int peek(void);
void flush(void);
};
#endif