Subversion Repositories Projects

Rev

Rev 500 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 500 Rev 513
Line 11... Line 11...
11
 
11
 
12
//#include <ctime>
12
//#include <ctime>
Line 13... Line 13...
13
#include <sys/time.h>
13
#include <sys/time.h>
14
 
14
 
15
void print_data(char * data, std::string type, char * color) {
15
void print_data(char * data, std::string type, char * color) {
16
    char buffer [100];
16
    char buffer [20];
17
    timeval timestamp;
17
    timeval timestamp;
-
 
18
    gettimeofday(&timestamp, 0);
18
    gettimeofday(&timestamp, 0);
19
    sprintf(buffer, "%i.%03i", timestamp.tv_sec, (timestamp.tv_usec+500)/1000);
19
    sprintf(buffer, "%i.%03i", timestamp.tv_sec, (timestamp.tv_usec+500)/1000);
20
//alternative to show human readable output
20
/*
21
/*
21
    time_t rawtime;
22
    time_t rawtime;
22
    struct tm * timeinfo;
23
    struct tm * timeinfo;
Line 31... Line 32...
31
    #else
32
    #else
32
        std::cout  << buffer << " " << type << ": " << data << std::endl;
33
        std::cout  << buffer << " " << type << ": " << data << std::endl;
33
    #endif
34
    #endif
34
}
35
}
Line -... Line 36...
-
 
36
 
-
 
37
void FlightLog::log_data(char * data, int length) {
-
 
38
    printf("raw data:");
-
 
39
    for( int i = 0 ; i < length; i++ ){
-
 
40
        printf("%c", data[i]);
-
 
41
    }
-
 
42
    printf(" hex:");
-
 
43
    for( int i = 0 ; i < length ; i++ ){
-
 
44
        printf( "%02hhx " , data[i] );
-
 
45
    }
-
 
46
    printf( "\n" );
-
 
47
}
35
 
48
 
36
void FlightLog::info(char * data) {
49
void FlightLog::info(char * data) {
37
    print_data(data, "INFO", INFO_COLOR);
50
    print_data(data, "INFO", INFO_COLOR);
Line -... Line 51...
-
 
51
}
-
 
52
 
-
 
53
void FlightLog::info_FC(char * data) {
-
 
54
    print_data(data, "INFO FC", INFO_FC_COLOR);
-
 
55
}
-
 
56
 
-
 
57
void FlightLog::info_NC(char * data) {
-
 
58
    print_data(data, "INFO NC", INFO_NC_COLOR);
-
 
59
}
-
 
60
 
-
 
61
void FlightLog::info_GPS(char * data) {
-
 
62
    print_data(data, "INFO GPS", INFO_GPS_COLOR);
-
 
63
}
-
 
64
 
-
 
65
void FlightLog::info_MK3(char * data) {
-
 
66
    print_data(data, "INFO MK3", INFO_MK3_COLOR);
38
}
67
}
39
 
68
 
40
void FlightLog::warning(char * data) {
69
void FlightLog::warning(char * data) {
Line 41... Line 70...
41
    print_data(data, "WARNING", WARNING_COLOR);
70
    print_data(data, "WARNING", WARNING_COLOR);