Subversion Repositories Projects

Rev

Rev 500 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 500 Rev 513
Line 42... Line 42...
42
    }
42
    }
43
    //TODO: Error message, because communication could not established
43
    //TODO: Error message, because communication could not established
44
};
44
};
Line 45... Line 45...
45
 
45
 
46
/**
-
 
47
 * received new data from MK
-
 
48
 */
-
 
49
 
-
 
50
 
-
 
51
/**
46
/**
52
 * send command to Mikrokopter
47
 * send command to Mikrokopter
53
 */
48
 */
-
 
49
void QTSerialCommunication::send_cmd(char cmd, int address, char data[150], unsigned int length, bool resend) {
54
void QTSerialCommunication::send_cmd(char cmd, int address, char data[150], unsigned int length, bool resend) {
50
    char send_data[150];
55
    if (is_connected()) {
51
    if (is_connected()) {
56
        Parser::create_frame(cmd, address, data, length);
52
        Parser::create_frame(send_data, cmd, address, data, length);
57
        if (resend) {
53
        if (resend) {
58
            //resend every 2 seconds
54
            //resend every 2 seconds
59
            resendTimer.start(2000);
55
            resendTimer.start(2000);
60
            resendData = data;
56
            resendData = send_data;
61
        }
57
        }
62
        //TODO: save outgoing data for debug purpose
58
        //TODO: save outgoing data for debug purpose
-
 
59
        std::cout << "send: ";
63
        std::cout << "send: " << data << std::endl;
60
        FlightLog::log_data(send_data, length+3);
64
        QByteArray temp(data);
61
        QByteArray temp(send_data);
65
        serial->sendData(temp);
62
        serial->sendData(temp);
66
    } else {
63
    } else {
67
        //FIXME: Error message: not connected
64
        //FIXME: Error message: not connected
68
    }
65
    }
Line 85... Line 82...
85
/**
82
/**
86
 * get incomming data from QT-Serial-Manager
83
 * get incomming data from QT-Serial-Manager
87
 * and just give it to the handler.
84
 * and just give it to the handler.
88
 */
85
 */
89
void QTSerialCommunication::slot_received_data(const QByteArray & data) {
86
void QTSerialCommunication::slot_received_data(const QByteArray & data) {
-
 
87
    std::cout << "receive something" << std::endl;
90
    received_data((char *)data.data(), data.length());
88
    received_data((char *)data.data(), data.length());
91
}
89
}
Line 92... Line 90...
92
 
90
 
93
/**
91
/**
94
 * handel received data
92
 * handel received data from MK
95
 */
93
 */
96
void QTSerialCommunication::received_data(char * data, int length) {
94
void QTSerialCommunication::received_data(char * data, int length) {
97
    //Debug: print oud debug data
95
    //Debug: print oud debug data
98
    //TODO: save data in a file for debug purposes
96
    //TODO: save data in a file for debug purposes
-
 
97
    std::cout << "receive: ";
99
    std::cout << "receive: " << data << std::endl;
98
    FlightLog::log_data(data, length);
100
    //handle incomming data
-
 
101
    //FIXME: HIER! Hardware-Id = Mode.id
-
 
102
 
99
    //handle incomming data
103
    handler->receive_data(data, length);
100
    handler->receive_data(data, length);
104
}
101
}