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 |
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 | }; |
Line 40... | Line 41... | ||
40 | 41 | ||
- | 42 | /** |
|
- | 43 | * received new data from MK |
|
- | 44 | */ |
|
- | 45 | ||
- | 46 | ||
41 | /** |
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) { |
- | 54 | //resend evrey 2 seconds |
|
- | 55 | resendTimer.start(2000); |
|
48 | //FIXME: start timer...? |
56 | resendData = data; |
49 | } |
57 | } |
50 | QByteArray temp(data); |
58 | QByteArray temp(data); |
- | 59 | serial->sendData(temp); |
|
- | 60 | } else { |
|
51 | serial->sendData(temp); |
61 | //FIXME: Error message: not connected |
52 | } |
62 | } |
Line 53... | Line 63... | ||
53 | }; |
63 | }; |
54 | 64 | ||
55 | /** |
65 | /** |
56 | * stop sending commands to Mikrokopter |
66 | * stop sending commands to Mikrokopter |
57 | * stop timer |
67 | * stop timer |
Line 58... | Line -... | ||
58 | */ |
- | |
59 | void QTSerialCommunication::stop_resend() { |
68 | */ |
- | 69 | void QTSerialCommunication::stop_resend() { |
|
- | 70 | ||
- | 71 | }; |
|
- | 72 | ||
- | 73 | /** |
|
- | 74 | * resend timer timout |
|
- | 75 | */ |
|
60 | 76 | void QTSerialCommunication::slot_resend_timer() { |