Subversion Repositories Projects

Rev

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

Rev 450 Rev 451
Line 4... Line 4...
4
 
4
 
5
/**
5
/**
6
 * initiate connection and stuff
6
 * initiate connection and stuff
7
 */
7
 */
8
QTSerialCommunication::QTSerialCommunication() {
8
QTSerialCommunication::QTSerialCommunication() {
-
 
9
    connection_lost();
9
    serial = new ManageSerialPort();
10
    serial = new ManageSerialPort();
10
    serial->setBaudRate(BAUD57600);   //BaudRate
11
    serial->setBaudRate(BAUD57600);   //BaudRate
11
    serial->setDataBits(DATA_8);      //DataBits
12
    serial->setDataBits(DATA_8);      //DataBits
12
    serial->setParity(PAR_NONE);      //Parity
13
    serial->setParity(PAR_NONE);      //Parity
13
    serial->setStopBits(STOP_1);      //StopBits
14
    serial->setStopBits(STOP_1);      //StopBits
Line 37... Line 38...
37
    }
38
    }
38
    //TODO: Error message, because communication could not established
39
    //TODO: Error message, because communication could not established
39
};
40
};
40
 
41
 
41
/**
42
/**
-
 
43
 * received new data from MK
-
 
44
 */
-
 
45
 
-
 
46
 
-
 
47
/**
42
 * send command to Mikrokopter
48
 * send command to Mikrokopter
43
 */
49
 */
44
void QTSerialCommunication::send_cmd(char cmd, int address, char data[150], unsigned int length, bool resend) {
50
void QTSerialCommunication::send_cmd(char cmd, int address, char data[150], unsigned int length, bool resend) {
45
    if (is_connected()) {
51
    if (is_connected()) {
46
        Parser::create_frame(cmd, address, data, length);
52
        Parser::create_frame(cmd, address, data, length);
47
        if (resend) {
53
        if (resend) {
48
            //FIXME: start timer...?
54
            //resend evrey 2 seconds
-
 
55
            resendTimer.start(2000);
-
 
56
            resendData = data;
49
        }
57
        }
50
        QByteArray temp(data);
58
        QByteArray temp(data);
51
        serial->sendData(temp);
59
        serial->sendData(temp);
-
 
60
    } else {
-
 
61
        //FIXME: Error message: not connected
52
    }
62
    }
53
};
63
};
54
 
64
 
55
/**
65
/**
56
 * stop sending commands to Mikrokopter
66
 * stop sending commands to Mikrokopter
57
 * stop timer
67
 * stop timer
58
 */
68
 */
59
void QTSerialCommunication::stop_resend() {
69
void QTSerialCommunication::stop_resend() {
60
   
70
   
61
};
-
 
62
71
};
-
 
72
 
-
 
73
/**
-
 
74
 * resend timer timout
-
 
75
 */
-
 
76
void QTSerialCommunication::slot_resend_timer() {
-
 
77
}
-
 
78
63
79