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