Rev 1072 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1072 | Rev 1340 | ||
---|---|---|---|
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 | // + Copyright (c) 04.2007 Holger Buss |
2 | // + Copyright (c) Holger Buss, Ingo Busker |
3 | // + only for non-profit use |
3 | // + only for non-profit use |
4 | // + www.MikroKopter.com |
4 | // + www.MikroKopter.com |
5 | // + see the File "License.txt" for further Informations |
5 | // + see the File "License.txt" for further Informations |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
6 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
7 | #include <stdarg.h> |
7 | #include <stdarg.h> |
8 | #include <string.h> |
8 | #include <string.h> |
9 | #include "main.h" |
9 | #include "main.h" |
10 | #include "uart.h" |
10 | #include "uart.h" |
11 | 11 | ||
12 | 12 | ||
13 | #define FC_ADDRESS 1 |
13 | #define FC_ADDRESS 1 |
14 | #define NC_ADDRESS 2 |
14 | #define NC_ADDRESS 2 |
15 | #define MK3MAG_ADDRESS 3 |
15 | #define MK3MAG_ADDRESS 3 |
16 | 16 | ||
17 | unsigned char GetExternalControl = 0,DebugDisplayAnforderung1 = 0, DebugDisplayAnforderung = 0,DebugDataAnforderung = 0,GetVersionAnforderung = 0, GetPPMChannelAnforderung = 0; |
17 | unsigned char GetExternalControl = 0,DebugDisplayAnforderung1 = 0, DebugDisplayAnforderung = 0,DebugDataAnforderung = 0,GetVersionAnforderung = 0, GetPPMChannelAnforderung = 0; |
18 | unsigned char DisplayLine = 0; |
18 | unsigned char DisplayLine = 0; |
19 | unsigned volatile char SioTmp = 0; |
19 | unsigned volatile char SioTmp = 0; |
20 | unsigned volatile char SendeBuffer[MAX_SENDE_BUFF]; |
20 | unsigned volatile char SendeBuffer[MAX_SENDE_BUFF]; |
21 | unsigned volatile char RxdBuffer[MAX_EMPFANGS_BUFF]; |
21 | unsigned volatile char RxdBuffer[MAX_EMPFANGS_BUFF]; |
22 | unsigned volatile char NMEABuffer[MAX_EMPFANGS_BUFF]; |
22 | unsigned volatile char NMEABuffer[MAX_EMPFANGS_BUFF]; |
23 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
23 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
24 | unsigned volatile char NeueKoordinateEmpfangen = 0; |
24 | unsigned volatile char NeueKoordinateEmpfangen = 0; |
25 | unsigned volatile char UebertragungAbgeschlossen = 1; |
25 | unsigned volatile char UebertragungAbgeschlossen = 1; |
26 | unsigned volatile char CntCrcError = 0; |
26 | unsigned volatile char CntCrcError = 0; |
27 | unsigned volatile char AnzahlEmpfangsBytes = 0; |
27 | unsigned volatile char AnzahlEmpfangsBytes = 0; |
28 | unsigned char *pRxData = 0; |
28 | unsigned char *pRxData = 0; |
29 | unsigned char RxDataLen = 0; |
29 | unsigned char RxDataLen = 0; |
30 | unsigned volatile char PC_DebugTimeout = 0; |
30 | unsigned volatile char PC_DebugTimeout = 0; |
31 | 31 | ||
32 | unsigned char DebugTextAnforderung = 255; |
32 | unsigned char DebugTextAnforderung = 255; |
33 | unsigned char PcZugriff = 100; |
33 | unsigned char PcZugriff = 100; |
34 | unsigned char MotorTest[4] = {0,0,0,0}; |
34 | unsigned char MotorTest[4] = {0,0,0,0}; |
35 | unsigned char MeineSlaveAdresse = 1; // Flight-Ctrl |
35 | unsigned char MeineSlaveAdresse = 1; // Flight-Ctrl |
36 | unsigned char ConfirmFrame; |
36 | unsigned char ConfirmFrame; |
37 | struct str_DebugOut DebugOut; |
37 | struct str_DebugOut DebugOut; |
38 | struct str_ExternControl ExternControl; |
38 | struct str_ExternControl ExternControl; |
39 | struct str_VersionInfo VersionInfo; |
39 | struct str_VersionInfo VersionInfo; |
40 | struct str_WinkelOut WinkelOut; |
40 | struct str_WinkelOut WinkelOut; |
41 | 41 | ||
42 | int Debug_Timer,Kompass_Timer; |
42 | int Debug_Timer,Kompass_Timer; |
43 | unsigned int DebugDataIntervall = 200; |
43 | unsigned int DebugDataIntervall = 200; |
44 | 44 | ||
45 | const unsigned char ANALOG_TEXT[32][16] = |
45 | const unsigned char ANALOG_TEXT[32][16] = |
46 | { |
46 | { |
47 | //1234567890123456 |
47 | //1234567890123456 |
48 | "IntegralNick ", //0 |
48 | "IntegralNick ", //0 |
49 | "IntegralRoll ", |
49 | "IntegralRoll ", |
50 | "AccNick ", |
50 | "AccNick ", |
51 | "AccRoll ", |
51 | "AccRoll ", |
52 | "GyroGier ", |
52 | "GyroGier ", |
53 | "HoehenWert ", //5 |
53 | "HoehenWert ", //5 |
54 | "AccZ ", |
54 | "AccZ ", |
55 | "Gas ", |
55 | "Gas ", |
56 | "KompassValue ", |
56 | "KompassValue ", |
57 | "Spannung ", |
57 | "Spannung ", |
58 | "Empfang ", //10 |
58 | "Empfang ", //10 |
59 | "Ersatzkompass ", |
59 | "Ersatzkompass ", |
60 | "Motor_Vorne ", |
60 | "Motor_Vorne ", |
61 | "Motor_Hinten ", |
61 | "Motor_Hinten ", |
62 | "Motor_Links ", |
62 | "Motor_Links ", |
63 | "Motor_Rechts ", //15 |
63 | "Motor_Rechts ", //15 |
64 | " ", |
64 | " ", |
65 | "Distance ", |
65 | "Distance ", |
66 | "OsdBar ", |
66 | "OsdBar ", |
67 | "MK3Mag CalState ", |
67 | "MK3Mag CalState ", |
68 | "Servo ", //20 |
68 | "Servo ", //20 |
69 | "Nick ", |
69 | "Nick ", |
70 | "Roll ", |
70 | "Roll ", |
71 | " ", |
71 | " ", |
72 | " ", |
72 | " ", |
73 | " ", //25 |
73 | " ", //25 |
74 | " ", |
74 | " ", |
75 | "Kalman_MaxDrift ", |
75 | "Kalman_MaxDrift ", |
76 | " ", |
76 | " ", |
77 | "Kalman K ", |
77 | "Kalman K ", |
78 | "GPS_Nick ", //30 |
78 | "GPS_Nick ", //30 |
79 | "GPS_Roll " |
79 | "GPS_Roll " |
80 | }; |
80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
84 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
85 | //++ Sende-Part der Datenübertragung |
85 | //++ Sende-Part der Datenübertragung |
86 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
86 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
87 | SIGNAL(INT_VEC_TX) |
87 | SIGNAL(INT_VEC_TX) |
88 | { |
88 | { |
89 | static unsigned int ptr = 0; |
89 | static unsigned int ptr = 0; |
90 | unsigned char tmp_tx; |
90 | unsigned char tmp_tx; |
91 | if(!UebertragungAbgeschlossen) |
91 | if(!UebertragungAbgeschlossen) |
92 | { |
92 | { |
93 | ptr++; // die [0] wurde schon gesendet |
93 | ptr++; // die [0] wurde schon gesendet |
94 | tmp_tx = SendeBuffer[ptr]; |
94 | tmp_tx = SendeBuffer[ptr]; |
95 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
95 | if((tmp_tx == '\r') || (ptr == MAX_SENDE_BUFF)) |
96 | { |
96 | { |
97 | ptr = 0; |
97 | ptr = 0; |
98 | UebertragungAbgeschlossen = 1; |
98 | UebertragungAbgeschlossen = 1; |
99 | } |
99 | } |
100 | UDR = tmp_tx; |
100 | UDR = tmp_tx; |
101 | } |
101 | } |
102 | else ptr = 0; |
102 | else ptr = 0; |
103 | } |
103 | } |
104 | 104 | ||
105 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
105 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
106 | //++ Empfangs-Part der Datenübertragung, incl. CRC-Auswertung |
106 | //++ Empfangs-Part der Datenübertragung, incl. CRC-Auswertung |
107 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
107 | //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
108 | SIGNAL(INT_VEC_RX) |
108 | SIGNAL(INT_VEC_RX) |
109 | { |
109 | { |
110 | static unsigned int crc; |
110 | static unsigned int crc; |
111 | static unsigned char crc1,crc2,buf_ptr; |
111 | static unsigned char crc1,crc2,buf_ptr; |
112 | static unsigned char UartState = 0; |
112 | static unsigned char UartState = 0; |
113 | unsigned char CrcOkay = 0; |
113 | unsigned char CrcOkay = 0; |
114 | 114 | ||
115 | SioTmp = UDR; |
115 | SioTmp = UDR; |
116 | if(buf_ptr >= MAX_EMPFANGS_BUFF) UartState = 0; |
116 | if(buf_ptr >= MAX_EMPFANGS_BUFF) UartState = 0; |
117 | if(SioTmp == '\r' && UartState == 2) |
117 | if(SioTmp == '\r' && UartState == 2) |
118 | { |
118 | { |
119 | UartState = 0; |
119 | UartState = 0; |
120 | crc -= RxdBuffer[buf_ptr-2]; |
120 | crc -= RxdBuffer[buf_ptr-2]; |
121 | crc -= RxdBuffer[buf_ptr-1]; |
121 | crc -= RxdBuffer[buf_ptr-1]; |
122 | crc %= 4096; |
122 | crc %= 4096; |
123 | crc1 = '=' + crc / 64; |
123 | crc1 = '=' + crc / 64; |
124 | crc2 = '=' + crc % 64; |
124 | crc2 = '=' + crc % 64; |
125 | CrcOkay = 0; |
125 | CrcOkay = 0; |
126 | if((crc1 == RxdBuffer[buf_ptr-2]) && (crc2 == RxdBuffer[buf_ptr-1])) CrcOkay = 1; else { CrcOkay = 0; CntCrcError++;}; |
126 | if((crc1 == RxdBuffer[buf_ptr-2]) && (crc2 == RxdBuffer[buf_ptr-1])) CrcOkay = 1; else { CrcOkay = 0; CntCrcError++;}; |
127 | if(!NeuerDatensatzEmpfangen && CrcOkay) // Datensatz schon verarbeitet |
127 | if(!NeuerDatensatzEmpfangen && CrcOkay) // Datensatz schon verarbeitet |
128 | { |
128 | { |
129 | NeuerDatensatzEmpfangen = 1; |
129 | NeuerDatensatzEmpfangen = 1; |
130 | AnzahlEmpfangsBytes = buf_ptr + 1; |
130 | AnzahlEmpfangsBytes = buf_ptr + 1; |
131 | RxdBuffer[buf_ptr] = '\r'; |
131 | RxdBuffer[buf_ptr] = '\r'; |
132 | if(RxdBuffer[2] == 'R') wdt_enable(WDTO_250MS); // Reset-Commando |
132 | if(RxdBuffer[2] == 'R') wdt_enable(WDTO_250MS); // Reset-Commando |
133 | } |
133 | } |
134 | } |
134 | } |
135 | else |
135 | else |
136 | switch(UartState) |
136 | switch(UartState) |
137 | { |
137 | { |
138 | case 0: |
138 | case 0: |
139 | if(SioTmp == '#' && !NeuerDatensatzEmpfangen) UartState = 1; // Startzeichen und Daten schon verarbeitet |
139 | if(SioTmp == '#' && !NeuerDatensatzEmpfangen) UartState = 1; // Startzeichen und Daten schon verarbeitet |
140 | buf_ptr = 0; |
140 | buf_ptr = 0; |
141 | RxdBuffer[buf_ptr++] = SioTmp; |
141 | RxdBuffer[buf_ptr++] = SioTmp; |
142 | crc = SioTmp; |
142 | crc = SioTmp; |
143 | break; |
143 | break; |
144 | case 1: // Adresse auswerten |
144 | case 1: // Adresse auswerten |
145 | UartState++; |
145 | UartState++; |
146 | RxdBuffer[buf_ptr++] = SioTmp; |
146 | RxdBuffer[buf_ptr++] = SioTmp; |
147 | crc += SioTmp; |
147 | crc += SioTmp; |
148 | break; |
148 | break; |
149 | case 2: // Eingangsdaten sammeln |
149 | case 2: // Eingangsdaten sammeln |
150 | RxdBuffer[buf_ptr] = SioTmp; |
150 | RxdBuffer[buf_ptr] = SioTmp; |
151 | if(buf_ptr < MAX_EMPFANGS_BUFF) buf_ptr++; |
151 | if(buf_ptr < MAX_EMPFANGS_BUFF) buf_ptr++; |
152 | else UartState = 0; |
152 | else UartState = 0; |
153 | crc += SioTmp; |
153 | crc += SioTmp; |
154 | break; |
154 | break; |
155 | default: |
155 | default: |
156 | UartState = 0; |
156 | UartState = 0; |
157 | break; |
157 | break; |
158 | } |
158 | } |
159 | } |
159 | } |
160 | 160 | ||
161 | 161 | ||
162 | // -------------------------------------------------------------------------- |
162 | // -------------------------------------------------------------------------- |
163 | void AddCRC(unsigned int wieviele) |
163 | void AddCRC(unsigned int wieviele) |
164 | { |
164 | { |
165 | unsigned int tmpCRC = 0,i; |
165 | unsigned int tmpCRC = 0,i; |
166 | for(i = 0; i < wieviele;i++) |
166 | for(i = 0; i < wieviele;i++) |
167 | { |
167 | { |
168 | tmpCRC += SendeBuffer[i]; |
168 | tmpCRC += SendeBuffer[i]; |
169 | } |
169 | } |
170 | tmpCRC %= 4096; |
170 | tmpCRC %= 4096; |
171 | SendeBuffer[i++] = '=' + tmpCRC / 64; |
171 | SendeBuffer[i++] = '=' + tmpCRC / 64; |
172 | SendeBuffer[i++] = '=' + tmpCRC % 64; |
172 | SendeBuffer[i++] = '=' + tmpCRC % 64; |
173 | SendeBuffer[i++] = '\r'; |
173 | SendeBuffer[i++] = '\r'; |
174 | UebertragungAbgeschlossen = 0; |
174 | UebertragungAbgeschlossen = 0; |
175 | UDR = SendeBuffer[0]; |
175 | UDR = SendeBuffer[0]; |
176 | } |
176 | } |
177 | 177 | ||
178 | 178 | ||
179 | 179 | ||
180 | // -------------------------------------------------------------------------- |
180 | // -------------------------------------------------------------------------- |
181 | void SendOutData(unsigned char cmd,unsigned char address, unsigned char BufferAnzahl, ...) //unsigned char *snd, unsigned char len) |
181 | void SendOutData(unsigned char cmd,unsigned char address, unsigned char BufferAnzahl, ...) //unsigned char *snd, unsigned char len) |
182 | { |
182 | { |
183 | va_list ap; |
183 | va_list ap; |
184 | unsigned int pt = 0; |
184 | unsigned int pt = 0; |
185 | unsigned char a,b,c; |
185 | unsigned char a,b,c; |
186 | unsigned char ptr = 0; |
186 | unsigned char ptr = 0; |
187 | 187 | ||
188 | unsigned char *snd = 0; |
188 | unsigned char *snd = 0; |
189 | int len = 0; |
189 | int len = 0; |
190 | 190 | ||
191 | SendeBuffer[pt++] = '#'; // Startzeichen |
191 | SendeBuffer[pt++] = '#'; // Startzeichen |
192 | SendeBuffer[pt++] = 'a' + address; // Adresse (a=0; b=1,...) |
192 | SendeBuffer[pt++] = 'a' + address; // Adresse (a=0; b=1,...) |
193 | SendeBuffer[pt++] = cmd; // Commando |
193 | SendeBuffer[pt++] = cmd; // Commando |
194 | 194 | ||
195 | va_start(ap, BufferAnzahl); |
195 | va_start(ap, BufferAnzahl); |
196 | if(BufferAnzahl) |
196 | if(BufferAnzahl) |
197 | { |
197 | { |
198 | snd = va_arg(ap, unsigned char*); |
198 | snd = va_arg(ap, unsigned char*); |
199 | len = va_arg(ap, int); |
199 | len = va_arg(ap, int); |
200 | ptr = 0; |
200 | ptr = 0; |
201 | BufferAnzahl--; |
201 | BufferAnzahl--; |
202 | } |
202 | } |
203 | while(len) |
203 | while(len) |
204 | { |
204 | { |
205 | if(len) |
205 | if(len) |
206 | { |
206 | { |
207 | a = snd[ptr++]; |
207 | a = snd[ptr++]; |
208 | len--; |
208 | len--; |
209 | if((!len) && BufferAnzahl) |
209 | if((!len) && BufferAnzahl) |
210 | { |
210 | { |
211 | snd = va_arg(ap, unsigned char*); |
211 | snd = va_arg(ap, unsigned char*); |
212 | len = va_arg(ap, int); |
212 | len = va_arg(ap, int); |
213 | ptr = 0; |
213 | ptr = 0; |
214 | BufferAnzahl--; |
214 | BufferAnzahl--; |
215 | } |
215 | } |
216 | } |
216 | } |
217 | else a = 0; |
217 | else a = 0; |
218 | if(len) |
218 | if(len) |
219 | { |
219 | { |
220 | b = snd[ptr++]; |
220 | b = snd[ptr++]; |
221 | len--; |
221 | len--; |
222 | if((!len) && BufferAnzahl) |
222 | if((!len) && BufferAnzahl) |
223 | { |
223 | { |
224 | snd = va_arg(ap, unsigned char*); |
224 | snd = va_arg(ap, unsigned char*); |
225 | len = va_arg(ap, int); |
225 | len = va_arg(ap, int); |
226 | ptr = 0; |
226 | ptr = 0; |
227 | BufferAnzahl--; |
227 | BufferAnzahl--; |
228 | } |
228 | } |
229 | } |
229 | } |
230 | else b = 0; |
230 | else b = 0; |
231 | if(len) |
231 | if(len) |
232 | { |
232 | { |
233 | c = snd[ptr++]; |
233 | c = snd[ptr++]; |
234 | len--; |
234 | len--; |
235 | if((!len) && BufferAnzahl) |
235 | if((!len) && BufferAnzahl) |
236 | { |
236 | { |
237 | snd = va_arg(ap, unsigned char*); |
237 | snd = va_arg(ap, unsigned char*); |
238 | len = va_arg(ap, int); |
238 | len = va_arg(ap, int); |
239 | ptr = 0; |
239 | ptr = 0; |
240 | BufferAnzahl--; |
240 | BufferAnzahl--; |
241 | } |
241 | } |
242 | } |
242 | } |
243 | else c = 0; |
243 | else c = 0; |
244 | SendeBuffer[pt++] = '=' + (a >> 2); |
244 | SendeBuffer[pt++] = '=' + (a >> 2); |
245 | SendeBuffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
245 | SendeBuffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
246 | SendeBuffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
246 | SendeBuffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
247 | SendeBuffer[pt++] = '=' + ( c & 0x3f); |
247 | SendeBuffer[pt++] = '=' + ( c & 0x3f); |
248 | } |
248 | } |
249 | va_end(ap); |
249 | va_end(ap); |
250 | AddCRC(pt); |
250 | AddCRC(pt); |
251 | } |
251 | } |
252 | 252 | ||
253 | 253 | ||
254 | // -------------------------------------------------------------------------- |
254 | // -------------------------------------------------------------------------- |
255 | void Decode64(void) // die daten werden im rx buffer dekodiert, das geht nur, weil aus 4 byte immer 3 gemacht werden. |
255 | void Decode64(void) // die daten werden im rx buffer dekodiert, das geht nur, weil aus 4 byte immer 3 gemacht werden. |
256 | { |
256 | { |
257 | unsigned char a,b,c,d; |
257 | unsigned char a,b,c,d; |
258 | unsigned char x,y,z; |
258 | unsigned char x,y,z; |
259 | unsigned char ptrIn = 3; // start at begin of data block |
259 | unsigned char ptrIn = 3; // start at begin of data block |
260 | unsigned char ptrOut = 3; |
260 | unsigned char ptrOut = 3; |
261 | unsigned char len = AnzahlEmpfangsBytes - 6; // von der Gesamtbytezahl eines Frames gehen 3 Bytes des Headers ('#',Addr, Cmd) und 3 Bytes des Footers (CRC1, CRC2, '\r') ab. |
261 | unsigned char len = AnzahlEmpfangsBytes - 6; // von der Gesamtbytezahl eines Frames gehen 3 Bytes des Headers ('#',Addr, Cmd) und 3 Bytes des Footers (CRC1, CRC2, '\r') ab. |
262 | 262 | ||
263 | while(len) |
263 | while(len) |
264 | { |
264 | { |
265 | a = RxdBuffer[ptrIn++] - '='; |
265 | a = RxdBuffer[ptrIn++] - '='; |
266 | b = RxdBuffer[ptrIn++] - '='; |
266 | b = RxdBuffer[ptrIn++] - '='; |
267 | c = RxdBuffer[ptrIn++] - '='; |
267 | c = RxdBuffer[ptrIn++] - '='; |
268 | d = RxdBuffer[ptrIn++] - '='; |
268 | d = RxdBuffer[ptrIn++] - '='; |
269 | 269 | ||
270 | x = (a << 2) | (b >> 4); |
270 | x = (a << 2) | (b >> 4); |
271 | y = ((b & 0x0f) << 4) | (c >> 2); |
271 | y = ((b & 0x0f) << 4) | (c >> 2); |
272 | z = ((c & 0x03) << 6) | d; |
272 | z = ((c & 0x03) << 6) | d; |
273 | 273 | ||
274 | if(len--) RxdBuffer[ptrOut++] = x; else break; |
274 | if(len--) RxdBuffer[ptrOut++] = x; else break; |
275 | if(len--) RxdBuffer[ptrOut++] = y; else break; |
275 | if(len--) RxdBuffer[ptrOut++] = y; else break; |
276 | if(len--) RxdBuffer[ptrOut++] = z; else break; |
276 | if(len--) RxdBuffer[ptrOut++] = z; else break; |
277 | } |
277 | } |
278 | pRxData = (unsigned char*)&RxdBuffer[3]; // decodierte Daten beginnen beim 4. Byte |
278 | pRxData = (unsigned char*)&RxdBuffer[3]; // decodierte Daten beginnen beim 4. Byte |
279 | RxDataLen = ptrOut - 3; // wie viele Bytes wurden dekodiert? |
279 | RxDataLen = ptrOut - 3; // wie viele Bytes wurden dekodiert? |
280 | 280 | ||
281 | } |
281 | } |
282 | 282 | ||
283 | // -------------------------------------------------------------------------- |
283 | // -------------------------------------------------------------------------- |
284 | void BearbeiteRxDaten(void) |
284 | void BearbeiteRxDaten(void) |
285 | { |
285 | { |
286 | if(!NeuerDatensatzEmpfangen) return; |
286 | if(!NeuerDatensatzEmpfangen) return; |
287 | 287 | ||
288 | unsigned char tempchar1, tempchar2; |
288 | unsigned char tempchar1, tempchar2; |
289 | Decode64(); // dekodiere datenblock im Empfangsbuffer |
289 | Decode64(); // dekodiere datenblock im Empfangsbuffer |
290 | switch(RxdBuffer[1]-'a') // check for Slave Address |
290 | switch(RxdBuffer[1]-'a') // check for Slave Address |
291 | { |
291 | { |
292 | case FC_ADDRESS: // FC special commands |
292 | case FC_ADDRESS: // FC special commands |
293 | 293 | ||
294 | switch(RxdBuffer[2]) |
294 | switch(RxdBuffer[2]) |
295 | { |
295 | { |
296 | case 'K':// Kompasswert |
296 | case 'K':// Kompasswert |
297 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
297 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
298 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
298 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
299 | break; |
299 | break; |
300 | 300 | ||
301 | case 't':// Motortest |
301 | case 't':// Motortest |
302 | memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
302 | memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
303 | //while(!UebertragungAbgeschlossen); |
303 | //while(!UebertragungAbgeschlossen); |
304 | //SendOutData('T', MeineSlaveAdresse, 0); |
304 | //SendOutData('T', MeineSlaveAdresse, 0); |
305 | PcZugriff = 255; |
305 | PcZugriff = 255; |
306 | break; |
306 | break; |
307 | 307 | ||
308 | case 'p': // get PPM Channels |
308 | case 'p': // get PPM Channels |
309 | GetPPMChannelAnforderung = 1; |
309 | GetPPMChannelAnforderung = 1; |
310 | break; |
310 | break; |
311 | 311 | ||
312 | case 'q':// "Get"-Anforderung für Settings |
312 | case 'q':// "Get"-Anforderung für Settings |
313 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
313 | // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
314 | if(pRxData[0] == 0xFF) |
314 | if(pRxData[0] == 0xFF) |
315 | { |
315 | { |
316 | pRxData[0] = GetActiveParamSetNumber(); |
316 | pRxData[0] = GetActiveParamSetNumber(); |
317 | } |
317 | } |
318 | // limit settings range |
318 | // limit settings range |
319 | if(pRxData[0] < 1) pRxData[0] = 1; // limit to 5 |
319 | if(pRxData[0] < 1) pRxData[0] = 1; // limit to 5 |
320 | else if(pRxData[0] > 5) pRxData[0] = 5; // limit to 5 |
320 | else if(pRxData[0] > 5) pRxData[0] = 5; // limit to 5 |
321 | // load requested parameter set |
321 | // load requested parameter set |
322 | ReadParameterSet(pRxData[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
322 | ReadParameterSet(pRxData[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
323 | 323 | ||
324 | while(!UebertragungAbgeschlossen); |
324 | while(!UebertragungAbgeschlossen); |
325 | tempchar1 = pRxData[0]; |
325 | tempchar1 = pRxData[0]; |
326 | tempchar2 = EE_DATENREVISION; |
326 | tempchar2 = EE_DATENREVISION; |
327 | SendOutData('Q', FC_ADDRESS, 3, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
327 | SendOutData('Q', FC_ADDRESS, 3, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
328 | break; |
328 | break; |
329 | 329 | ||
330 | case 's': // Parametersatz speichern |
330 | case 's': // Parametersatz speichern |
331 | if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EE_DATENREVISION)) // check for setting to be in range |
331 | if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EE_DATENREVISION)) // check for setting to be in range |
332 | { |
332 | { |
333 | memcpy((unsigned char *) &EE_Parameter.Kanalbelegung[0], (unsigned char *)&pRxData[2], STRUCT_PARAM_LAENGE); |
333 | memcpy((unsigned char *) &EE_Parameter.Kanalbelegung[0], (unsigned char *)&pRxData[2], STRUCT_PARAM_LAENGE); |
334 | WriteParameterSet(pRxData[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
334 | WriteParameterSet(pRxData[0], (unsigned char *) &EE_Parameter.Kanalbelegung[0], STRUCT_PARAM_LAENGE); |
335 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
335 | Umschlag180Nick = (long) EE_Parameter.WinkelUmschlagNick * 2500L; |
336 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
336 | Umschlag180Roll = (long) EE_Parameter.WinkelUmschlagRoll * 2500L; |
337 | SetActiveParamSetNumber(pRxData[0]); |
337 | SetActiveParamSetNumber(pRxData[0]); |
338 | tempchar1 = GetActiveParamSetNumber(); |
338 | tempchar1 = GetActiveParamSetNumber(); |
339 | Piep(tempchar1); |
339 | Piep(tempchar1); |
340 | } |
340 | } |
341 | else |
341 | else |
342 | { |
342 | { |
343 | tempchar1 = 0; // mark in response an invlid setting |
343 | tempchar1 = 0; // mark in response an invlid setting |
344 | } |
344 | } |
345 | while(!UebertragungAbgeschlossen); |
345 | while(!UebertragungAbgeschlossen); |
346 | SendOutData('S', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
346 | SendOutData('S', FC_ADDRESS, 1, &tempchar1, sizeof(tempchar1)); |
347 | break; |
347 | break; |
348 | 348 | ||
349 | } // case FC_ADDRESS: |
349 | } // case FC_ADDRESS: |
350 | 350 | ||
351 | default: // any Slave Address |
351 | default: // any Slave Address |
352 | 352 | ||
353 | switch(RxdBuffer[2]) |
353 | switch(RxdBuffer[2]) |
354 | { |
354 | { |
355 | // 't' comand placed here only for compatibility to BL |
355 | // 't' comand placed here only for compatibility to BL |
356 | case 't':// Motortest |
356 | case 't':// Motortest |
357 | memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
357 | memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
358 | while(!UebertragungAbgeschlossen); |
358 | while(!UebertragungAbgeschlossen); |
359 | SendOutData('T', MeineSlaveAdresse, 0); |
359 | SendOutData('T', MeineSlaveAdresse, 0); |
360 | PcZugriff = 255; |
360 | PcZugriff = 255; |
361 | break; |
361 | break; |
362 | // 'K' comand placed here only for compatibility to old MK3MAG software, that does not send the right Slave Address |
362 | // 'K' comand placed here only for compatibility to old MK3MAG software, that does not send the right Slave Address |
363 | case 'K':// Kompasswert |
363 | case 'K':// Kompasswert |
364 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
364 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
365 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
365 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
366 | break; |
366 | break; |
367 | 367 | ||
368 | case 'a':// Texte der Analogwerte |
368 | case 'a':// Texte der Analogwerte |
369 | DebugTextAnforderung = pRxData[0]; |
369 | DebugTextAnforderung = pRxData[0]; |
370 | if (DebugTextAnforderung > 31) DebugTextAnforderung = 31; |
370 | if (DebugTextAnforderung > 31) DebugTextAnforderung = 31; |
371 | PcZugriff = 255; |
371 | PcZugriff = 255; |
372 | break; |
372 | break; |
373 | 373 | ||
374 | case 'b': |
374 | case 'b': |
375 | memcpy((unsigned char *)&ExternControl, (unsigned char *)pRxData, sizeof(ExternControl)); |
375 | memcpy((unsigned char *)&ExternControl, (unsigned char *)pRxData, sizeof(ExternControl)); |
376 | ConfirmFrame = ExternControl.Frame; |
376 | ConfirmFrame = ExternControl.Frame; |
377 | PcZugriff = 255; |
377 | PcZugriff = 255; |
378 | break; |
378 | break; |
379 | case 'd': // Poll the debug data |
379 | case 'd': // Poll the debug data |
380 | DebugDataIntervall = pRxData[0] * 10; |
380 | DebugDataIntervall = pRxData[0] * 10; |
381 | if (DebugDataIntervall > 0) DebugDataAnforderung = 1; |
381 | if (DebugDataIntervall > 0) DebugDataAnforderung = 1; |
382 | break; |
382 | break; |
383 | 383 | ||
384 | case 'h':// x-1 Displayzeilen |
384 | case 'h':// x-1 Displayzeilen |
385 | PcZugriff = 255; |
385 | PcZugriff = 255; |
386 | RemoteKeys |= pRxData[0]; |
386 | RemoteKeys |= pRxData[0]; |
387 | if(RemoteKeys) DisplayLine = 0; |
387 | if(RemoteKeys) DisplayLine = 0; |
388 | DebugDisplayAnforderung = 1; |
388 | DebugDisplayAnforderung = 1; |
389 | break; |
389 | break; |
390 | 390 | ||
391 | case 'l':// x-1 Displayzeilen |
391 | case 'l':// x-1 Displayzeilen |
392 | PcZugriff = 255; |
392 | PcZugriff = 255; |
393 | MenuePunkt = pRxData[0]; |
393 | MenuePunkt = pRxData[0]; |
394 | DebugDisplayAnforderung1 = 1; |
394 | DebugDisplayAnforderung1 = 1; |
395 | break; |
395 | break; |
396 | case 'v': // Version-Anforderung und Ausbaustufe |
396 | case 'v': // Version-Anforderung und Ausbaustufe |
397 | GetVersionAnforderung = 1; |
397 | GetVersionAnforderung = 1; |
398 | break; |
398 | break; |
399 | 399 | ||
400 | case 'g':// |
400 | case 'g':// |
401 | GetExternalControl = 1; |
401 | GetExternalControl = 1; |
402 | break; |
402 | break; |
403 | } |
403 | } |
404 | break; // default: |
404 | break; // default: |
405 | } |
405 | } |
406 | NeuerDatensatzEmpfangen = 0; |
406 | NeuerDatensatzEmpfangen = 0; |
407 | pRxData = 0; |
407 | pRxData = 0; |
408 | RxDataLen = 0; |
408 | RxDataLen = 0; |
409 | } |
409 | } |
410 | 410 | ||
411 | //############################################################################ |
411 | //############################################################################ |
412 | //Routine für die Serielle Ausgabe |
412 | //Routine für die Serielle Ausgabe |
413 | int uart_putchar (char c) |
413 | int uart_putchar (char c) |
414 | //############################################################################ |
414 | //############################################################################ |
415 | { |
415 | { |
416 | if (c == '\n') |
416 | if (c == '\n') |
417 | uart_putchar('\r'); |
417 | uart_putchar('\r'); |
418 | //Warten solange bis Zeichen gesendet wurde |
418 | //Warten solange bis Zeichen gesendet wurde |
419 | loop_until_bit_is_set(USR, UDRE); |
419 | loop_until_bit_is_set(USR, UDRE); |
420 | //Ausgabe des Zeichens |
420 | //Ausgabe des Zeichens |
421 | UDR = c; |
421 | UDR = c; |
422 | 422 | ||
423 | return (0); |
423 | return (0); |
424 | } |
424 | } |
425 | 425 | ||
426 | // -------------------------------------------------------------------------- |
426 | // -------------------------------------------------------------------------- |
427 | void WriteProgramData(unsigned int pos, unsigned char wert) |
427 | void WriteProgramData(unsigned int pos, unsigned char wert) |
428 | { |
428 | { |
429 | //if (ProgramLocation == IN_RAM) Buffer[pos] = wert; |
429 | //if (ProgramLocation == IN_RAM) Buffer[pos] = wert; |
430 | // else eeprom_write_byte(&EE_Buffer[pos], wert); |
430 | // else eeprom_write_byte(&EE_Buffer[pos], wert); |
431 | // Buffer[pos] = wert; |
431 | // Buffer[pos] = wert; |
432 | } |
432 | } |
433 | 433 | ||
434 | //############################################################################ |
434 | //############################################################################ |
435 | //INstallation der Seriellen Schnittstelle |
435 | //INstallation der Seriellen Schnittstelle |
436 | void UART_Init (void) |
436 | void UART_Init (void) |
437 | //############################################################################ |
437 | //############################################################################ |
438 | { |
438 | { |
439 | //Enable TXEN im Register UCR TX-Data Enable & RX Enable |
439 | //Enable TXEN im Register UCR TX-Data Enable & RX Enable |
440 | 440 | ||
441 | UCR=(1 << TXEN) | (1 << RXEN); |
441 | UCR=(1 << TXEN) | (1 << RXEN); |
442 | // UART Double Speed (U2X) |
442 | // UART Double Speed (U2X) |
443 | USR |= (1<<U2X); |
443 | USR |= (1<<U2X); |
444 | // RX-Interrupt Freigabe |
444 | // RX-Interrupt Freigabe |
445 | UCSRB |= (1<<RXCIE); |
445 | UCSRB |= (1<<RXCIE); |
446 | // TX-Interrupt Freigabe |
446 | // TX-Interrupt Freigabe |
447 | UCSRB |= (1<<TXCIE); |
447 | UCSRB |= (1<<TXCIE); |
448 | 448 | ||
449 | //Teiler wird gesetzt |
449 | //Teiler wird gesetzt |
450 | UBRR=(SYSCLK / (BAUD_RATE * 8L) - 1); |
450 | UBRR=(SYSCLK / (BAUD_RATE * 8L) - 1); |
451 | //UBRR = 33; |
451 | //UBRR = 33; |
452 | //öffnet einen Kanal für printf (STDOUT) |
452 | //öffnet einen Kanal für printf (STDOUT) |
453 | //fdevopen (uart_putchar, 0); |
453 | //fdevopen (uart_putchar, 0); |
454 | //sbi(PORTD,4); |
454 | //sbi(PORTD,4); |
455 | Debug_Timer = SetDelay(DebugDataIntervall); |
455 | Debug_Timer = SetDelay(DebugDataIntervall); |
456 | Kompass_Timer = SetDelay(220); |
456 | Kompass_Timer = SetDelay(220); |
457 | 457 | ||
458 | VersionInfo.SWMajor = VERSION_MAJOR; |
458 | VersionInfo.SWMajor = VERSION_MAJOR; |
459 | VersionInfo.SWMinor = VERSION_MINOR; |
459 | VersionInfo.SWMinor = VERSION_MINOR; |
460 | VersionInfo.SWPatch = VERSION_PATCH; |
460 | VersionInfo.SWPatch = VERSION_PATCH; |
461 | VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR; |
461 | VersionInfo.ProtoMajor = VERSION_SERIAL_MAJOR; |
462 | VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR; |
462 | VersionInfo.ProtoMinor = VERSION_SERIAL_MINOR; |
463 | 463 | ||
464 | pRxData = 0; |
464 | pRxData = 0; |
465 | RxDataLen = 0; |
465 | RxDataLen = 0; |
466 | } |
466 | } |
467 | 467 | ||
468 | //--------------------------------------------------------------------------------------------- |
468 | //--------------------------------------------------------------------------------------------- |
469 | void DatenUebertragung(void) |
469 | void DatenUebertragung(void) |
470 | { |
470 | { |
471 | if(!UebertragungAbgeschlossen) return; |
471 | if(!UebertragungAbgeschlossen) return; |
472 | 472 | ||
473 | if(DebugDisplayAnforderung && UebertragungAbgeschlossen) |
473 | if(DebugDisplayAnforderung && UebertragungAbgeschlossen) |
474 | { |
474 | { |
475 | Menu(); |
475 | Menu(); |
476 | SendOutData('H', FC_ADDRESS, 2, &DisplayLine, sizeof(DisplayLine), &DisplayBuff[DisplayLine * 20], 20); |
476 | SendOutData('H', FC_ADDRESS, 2, &DisplayLine, sizeof(DisplayLine), &DisplayBuff[DisplayLine * 20], 20); |
477 | DisplayLine++; |
477 | DisplayLine++; |
478 | if(DisplayLine >= 4) DisplayLine = 0; |
478 | if(DisplayLine >= 4) DisplayLine = 0; |
479 | DebugDisplayAnforderung = 0; |
479 | DebugDisplayAnforderung = 0; |
480 | } |
480 | } |
481 | if(DebugDisplayAnforderung1 && UebertragungAbgeschlossen) |
481 | if(DebugDisplayAnforderung1 && UebertragungAbgeschlossen) |
482 | { |
482 | { |
483 | Menu(); |
483 | Menu(); |
484 | SendOutData('L', FC_ADDRESS, 3, &MenuePunkt, sizeof(MenuePunkt), &MaxMenue, sizeof(MaxMenue), DisplayBuff, sizeof(DisplayBuff)); |
484 | SendOutData('L', FC_ADDRESS, 3, &MenuePunkt, sizeof(MenuePunkt), &MaxMenue, sizeof(MaxMenue), DisplayBuff, sizeof(DisplayBuff)); |
485 | DebugDisplayAnforderung1 = 0; |
485 | DebugDisplayAnforderung1 = 0; |
486 | } |
486 | } |
487 | if(GetVersionAnforderung && UebertragungAbgeschlossen) |
487 | if(GetVersionAnforderung && UebertragungAbgeschlossen) |
488 | { |
488 | { |
489 | SendOutData('V', FC_ADDRESS, 1, (unsigned char *) &VersionInfo, sizeof(VersionInfo)); |
489 | SendOutData('V', FC_ADDRESS, 1, (unsigned char *) &VersionInfo, sizeof(VersionInfo)); |
490 | GetVersionAnforderung = 0; |
490 | GetVersionAnforderung = 0; |
491 | } |
491 | } |
492 | 492 | ||
493 | if(GetExternalControl && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
493 | if(GetExternalControl && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
494 | { |
494 | { |
495 | SendOutData('G',MeineSlaveAdresse, 1, (unsigned char *) &ExternControl, sizeof(ExternControl)); |
495 | SendOutData('G',MeineSlaveAdresse, 1, (unsigned char *) &ExternControl, sizeof(ExternControl)); |
496 | GetExternalControl = 0; |
496 | GetExternalControl = 0; |
497 | } |
497 | } |
498 | 498 | ||
499 | if((CheckDelay(Kompass_Timer)) && UebertragungAbgeschlossen) |
499 | if((CheckDelay(Kompass_Timer)) && UebertragungAbgeschlossen) |
500 | { |
500 | { |
501 | WinkelOut.Winkel[0] = (int) (IntegralNick / 108); // etwa in 0,1 Grad |
501 | WinkelOut.Winkel[0] = (int) (IntegralNick / 108); // etwa in 0,1 Grad |
502 | WinkelOut.Winkel[1] = (int) (IntegralRoll / 108); // etwa in 0,1 Grad |
502 | WinkelOut.Winkel[1] = (int) (IntegralRoll / 108); // etwa in 0,1 Grad |
503 | WinkelOut.UserParameter[0] = Parameter_UserParam1; |
503 | WinkelOut.UserParameter[0] = Parameter_UserParam1; |
504 | WinkelOut.UserParameter[1] = Parameter_UserParam2; |
504 | WinkelOut.UserParameter[1] = Parameter_UserParam2; |
505 | SendOutData('w', MK3MAG_ADDRESS, 1, (unsigned char *) &WinkelOut,sizeof(WinkelOut)); |
505 | SendOutData('w', MK3MAG_ADDRESS, 1, (unsigned char *) &WinkelOut,sizeof(WinkelOut)); |
506 | if(WinkelOut.CalcState > 4) WinkelOut.CalcState = 6; // wird dann in SPI auf Null gesetzt |
506 | if(WinkelOut.CalcState > 4) WinkelOut.CalcState = 6; // wird dann in SPI auf Null gesetzt |
507 | Kompass_Timer = SetDelay(99); |
507 | Kompass_Timer = SetDelay(99); |
508 | } |
508 | } |
509 | if((( DebugDataIntervall>0 && CheckDelay(Debug_Timer)) || DebugDataAnforderung) && UebertragungAbgeschlossen) |
509 | if((( DebugDataIntervall>0 && CheckDelay(Debug_Timer)) || DebugDataAnforderung) && UebertragungAbgeschlossen) |
510 | { |
510 | { |
511 | SendOutData('D', FC_ADDRESS, 1, (unsigned char *) &DebugOut,sizeof(DebugOut)); |
511 | SendOutData('D', FC_ADDRESS, 1, (unsigned char *) &DebugOut,sizeof(DebugOut)); |
512 | DebugDataAnforderung = 0; |
512 | DebugDataAnforderung = 0; |
513 | if(DebugDataIntervall>0) Debug_Timer = SetDelay(DebugDataIntervall); |
513 | if(DebugDataIntervall>0) Debug_Timer = SetDelay(DebugDataIntervall); |
514 | } |
514 | } |
515 | if(DebugTextAnforderung != 255) // Texte für die Analogdaten |
515 | if(DebugTextAnforderung != 255) // Texte für die Analogdaten |
516 | { |
516 | { |
517 | SendOutData('A', FC_ADDRESS, 2, (unsigned char *)&DebugTextAnforderung, sizeof(DebugTextAnforderung),(unsigned char *) ANALOG_TEXT[DebugTextAnforderung], 16); |
517 | SendOutData('A', FC_ADDRESS, 2, (unsigned char *)&DebugTextAnforderung, sizeof(DebugTextAnforderung),(unsigned char *) ANALOG_TEXT[DebugTextAnforderung], 16); |
518 | DebugTextAnforderung = 255; |
518 | DebugTextAnforderung = 255; |
519 | } |
519 | } |
520 | if(ConfirmFrame && UebertragungAbgeschlossen) // Datensatz bestätigen |
520 | if(ConfirmFrame && UebertragungAbgeschlossen) // Datensatz bestätigen |
521 | { |
521 | { |
522 | SendOutData('B', FC_ADDRESS, 1, (uint8_t*)&ConfirmFrame, sizeof(ConfirmFrame)); |
522 | SendOutData('B', FC_ADDRESS, 1, (uint8_t*)&ConfirmFrame, sizeof(ConfirmFrame)); |
523 | ConfirmFrame = 0; |
523 | ConfirmFrame = 0; |
524 | } |
524 | } |
525 | 525 | ||
526 | if(GetPPMChannelAnforderung && UebertragungAbgeschlossen) |
526 | if(GetPPMChannelAnforderung && UebertragungAbgeschlossen) |
527 | { |
527 | { |
528 | SendOutData('P', FC_ADDRESS, 1, (unsigned char *) &PPM_in, sizeof(PPM_in)); |
528 | SendOutData('P', FC_ADDRESS, 1, (unsigned char *) &PPM_in, sizeof(PPM_in)); |
529 | GetPPMChannelAnforderung = 0; |
529 | GetPPMChannelAnforderung = 0; |
530 | } |
530 | } |
531 | 531 | ||
532 | } |
532 | } |
533 | 533 | ||
534 | 534 |