Subversion Repositories Projects

Rev

Rev 450 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 450 Rev 451
1
#ifndef PARSER_H
1
#ifndef PARSER_H
2
#define PARSER_H
2
#define PARSER_H
3
#include "Kopter.h"
3
#include "Kopter.h"
4
#include <cmath>
4
#include <cmath>
5
#include <string>
5
#include <string>
6
 
6
 
7
/**
7
/**
8
 * The Parser gets values from the Mikrokopter-USART interface
8
 * The Parser gets values from the Mikrokopter-USART interface
9
 *  and parses them into a sRxData-Struct
9
 *  and parses them into a sRxData-Struct
10
 */
10
 */
11
/*
-
 
12
struct sRxData
-
 
13
{
11
 
14
    char *input;
-
 
15
    int decode[150];
-
 
16
    int decLen;
-
 
17
};
-
 
18
*/
-
 
19
class Parser {
12
class Parser {
20
    public:
13
    public:
21
        static void create_frame(char cmd, int address, char * data, unsigned int length);
14
        static void create_frame(char cmd, int address, char * data, unsigned int length);
22
 
15
 
23
        static int decode64(char * data, int len, unsigned char *ptrOut, int offset);
16
        static int decode64(char * data, int len, unsigned char *ptrOut, int offset);
24
        static void encode64(char data[150],unsigned int length);
17
        static void encode64(char data[150],unsigned int length);
25
 
18
 
26
        static void add_CRC(char * tx, int length);
19
        static void add_CRC(char * tx, int length);
27
        static bool check_CRC(char * rx, int length);
20
        static bool check_CRC(char * rx, int length);
28
 
21
 
29
        static float getFloat(long value, int count);
22
        static float getFloat(long value, int count);
30
 
23
 
31
        static int dataToInt(char *data , int start, bool is_signed = true);
24
        static int dataToInt(char *data , int start, bool is_signed = true);
32
        static long dataToLong(char *data , int start, bool is_signed = true);
25
        static long dataToLong(char *data , int start, bool is_signed = true);
33
        static int dataToChar(char *data , int start, bool is_signed = true);
26
        static int dataToChar(char *data , int start, bool is_signed = true);
34
        static std::string dataToString(char * data, int start, int end);
27
        static std::string dataToString(char * data, int start, int end);
35
        static int charToData(int data);
28
        static int charToData(int data);
36
};
29
};
37
 
30
 
38
#endif
31
#endif
39
 
32