Rev 440 | Rev 450 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 440 | Rev 449 | ||
---|---|---|---|
1 | #ifndef PARSER_H |
1 | #ifndef PARSER_H |
2 | #define PARSER_H |
2 | #define PARSER_H |
3 | #include <string> |
- | |
4 | #include <cmath> |
3 | #include <cmath> |
5 | 4 | ||
6 | /** |
5 | /** |
7 | * The Parser gets values from the Mikrokopter-USART interface |
6 | * The Parser gets values from the Mikrokopter-USART interface |
8 | * and parses them into a sRxData-Struct |
7 | * and parses them into a sRxData-Struct |
9 | */ |
8 | */ |
10 | - | ||
11 | using namespace std; |
- | |
12 | 9 | /* |
|
13 | struct sRxData |
10 | struct sRxData |
14 | { |
11 | { |
15 | char *input; |
12 | char *input; |
16 | string str; |
- | |
17 | int decode[150]; |
13 | int decode[150]; |
18 | int decLen; |
14 | int decLen; |
19 | }; |
15 | }; |
20 | 16 | */ |
|
21 | class Parser { |
17 | class Parser { |
22 | public: |
18 | public: |
- | 19 | void create_frame(char cmd, int address, char * data, unsigned int length); |
|
- | 20 | ||
23 | static bool decode64(sRxData &rx); |
21 | static int decode64(char * data, int len, unsigned char *ptrOut, int offset); |
24 | static string encode64(char data[150],unsigned int length); |
22 | static void encode64(char data[150],unsigned int length); |
25 | 23 | ||
26 | static string add_CRC(string TX); |
24 | static void add_CRC(char * tx, int length); |
27 | static bool check_CRC(string RX); |
25 | static bool check_CRC(char * rx, int length); |
28 | 26 | ||
29 | static float getFloat(long value, int count); |
27 | static float getFloat(long value, int count); |
30 | 28 | ||
31 | static int dataToInt(int *Data , int Start, bool is_signed = true); |
29 | static int dataToInt(int *data , int start, bool is_signed = true); |
32 | static long dataToLong(int *Data , int Start, bool is_signed = true); |
30 | static long dataToLong(int *data , int start, bool is_signed = true); |
33 | static int dataToChar(int *data , int start, bool is_signed = true); |
- | |
34 | static string dataToString(int Data[150], int Start = 0, int End = 150); |
31 | static int dataToChar(int *data , int start, bool is_signed = true); |
35 | static int charToData(int data); |
32 | static int charToData(int data); |
36 | }; |
33 | }; |
37 | 34 | ||
38 | #endif |
35 | #endif |
39 | 36 |