Revision 1744
Wireless testing, made changes to wireless library (xbee.c, debugging changes only) and test_wireless2.c for continued wireless tests.
test_wireless2.c | ||
---|---|---|
161 | 161 |
WL_DEBUG_PRINT_P("\r\nTesting XBee fuctions...\r\n"); |
162 | 162 |
status = 0; |
163 | 163 |
orb2_set_color(GREEN); |
164 |
uint16_t pan = xbee_get_pan(); |
|
165 |
if(pan != 0){ |
|
166 |
WL_DEBUG_PRINT_P("Pan error: defaulted to non-default Pan id (0):"); |
|
167 |
usb_puti(pan); |
|
168 |
orb2_set_color(ORANGE); |
|
169 |
status++; |
|
164 |
/* while(1){ |
|
165 |
uint16_t pan = xbee_get_pan(); |
|
166 |
if(pan != 0){ |
|
167 |
WL_DEBUG_PRINT_P("Pan error: defaulted to non-default Pan id (0):"); |
|
168 |
usb_puti(pan); |
|
169 |
orb2_set_color(ORANGE); |
|
170 |
status++; |
|
171 |
} |
|
172 |
status = xbee_set_pan(0x2B7D); |
|
173 |
if(status != 0){ |
|
174 |
WL_DEBUG_PRINT_P("\r\nPan error: error setting Pan id: "); |
|
175 |
// usb_puth16(pan); |
|
176 |
orb2_set_color(ORANGE); |
|
177 |
status++; |
|
178 |
} |
|
179 |
pan = xbee_get_pan(); |
|
180 |
if(pan != 0x2B7D){ |
|
181 |
WL_DEBUG_PRINT_P("\r\nPan error: Pan id reads different than set value 0x2B7D: "); |
|
182 |
usb_puth16(pan); |
|
183 |
orb2_set_color(ORANGE); |
|
184 |
status++; |
|
185 |
} |
|
186 |
status = xbee_set_pan(0); |
|
187 |
if(status != 0){ |
|
188 |
WL_DEBUG_PRINT_P("\r\nPan error: error setting Pan id: "); |
|
189 |
usb_puti(pan); |
|
190 |
orb2_set_color(ORANGE); |
|
191 |
status++; |
|
192 |
} |
|
193 |
pan = xbee_get_pan(); |
|
194 |
if(pan != 0){ |
|
195 |
WL_DEBUG_PRINT_P("\r\nPan error: Pan id reads different than set value 0: "); |
|
196 |
usb_puti(pan); |
|
197 |
orb2_set_color(ORANGE); |
|
198 |
status++; |
|
199 |
} |
|
200 |
int chanCount; |
|
201 |
for(chanCount = 0x0B; chanCount <= 0x1A; chanCount++){ |
|
202 |
xbee_set_channel(0x10); |
|
203 |
WL_DEBUG_PRINT_P("\r\nChannel: "); |
|
204 |
WL_DEBUG_PRINT_HEX(xbee_get_channel()); |
|
205 |
} |
|
206 |
uint16_t data = xbee_get_address(); |
|
207 |
uint8_t sendBuffer[2]; |
|
208 |
uint16_t address = 0; |
|
209 |
sendBuffer[0] = (data& 0xFF00) >> 8; |
|
210 |
sendBuffer[1] = (data& 0x00FF); |
|
211 |
wl_send((uint8_t*)&sendBuffer, 2, 0, GLOBAL, BROADCAST, FAST); |
|
170 | 212 |
} |
171 |
status = xbee_set_pan(0x2B7D); |
|
172 |
if(status != 0){ |
|
173 |
WL_DEBUG_PRINT_P("\r\nPan error: error setting Pan id: "); |
|
174 |
// usb_puth16(pan); |
|
175 |
orb2_set_color(ORANGE); |
|
176 |
status++; |
|
177 |
} |
|
178 |
pan = xbee_get_pan(); |
|
179 |
if(pan != 0x2B7D){ |
|
180 |
WL_DEBUG_PRINT_P("\r\nPan error: Pan id reads different than set value 0x2B7D: "); |
|
181 |
usb_puth16(pan); |
|
182 |
orb2_set_color(ORANGE); |
|
183 |
status++; |
|
184 |
} |
|
185 |
status = xbee_set_pan(0); |
|
186 |
if(status != 0){ |
|
187 |
WL_DEBUG_PRINT_P("\r\nPan error: error setting Pan id: "); |
|
188 |
usb_puti(pan); |
|
189 |
orb2_set_color(ORANGE); |
|
190 |
status++; |
|
191 |
} |
|
192 |
pan = xbee_get_pan(); |
|
193 |
if(pan != 0){ |
|
194 |
WL_DEBUG_PRINT_P("\r\nPan error: Pan id reads different than set value 0: "); |
|
195 |
usb_puti(pan); |
|
196 |
orb2_set_color(ORANGE); |
|
197 |
status++; |
|
198 |
} |
|
199 |
|
|
200 |
xbee_set_channel(0x10); |
|
201 |
WL_DEBUG_PRINT_P("\r\nChannel: "); |
|
202 |
WL_DEBUG_PRINT_HEX(xbee_get_channel()); |
|
203 |
|
|
213 |
*/ |
|
204 | 214 |
WL_DEBUG_PRINT_P("\r\nXBee tests completed. There were "); |
205 | 215 |
usb_puti(status); |
206 | 216 |
WL_DEBUG_PRINT_P(" errors.\r\n"); |
... | ... | |
243 | 253 |
uint16_t address = 0; |
244 | 254 |
orb2_set_color(BLUE); |
245 | 255 |
while(1){ |
246 |
WL_DEBUG_PRINT_P("\r\nMy address: "); |
|
256 |
/* WL_DEBUG_PRINT_P("\r\nMy address: ");
|
|
247 | 257 |
usb_puti(data); |
248 | 258 |
usb_puti(xbee_get_address()); |
249 | 259 |
sendBuffer[0] = (data& 0xFF00) >> 8; |
... | ... | |
254 | 264 |
if(len != 0){ |
255 | 265 |
address = (buffer[0] << 8) + buffer[1]; |
256 | 266 |
orb2_set_color(GREEN); |
257 |
WL_DEBUG_PRINTP("\r\nLength: "); |
|
267 |
WL_DEBUG_PRINT_P("\r\nLength: ");
|
|
258 | 268 |
WL_DEBUG_PRINT_INT(len); |
259 | 269 |
WL_DEBUG_PRINT_P("\r\nFriend address: "); |
260 | 270 |
usb_puth16(address); |
261 | 271 |
friendAddress = address; |
262 | 272 |
} |
263 |
if(button1_read()){ |
|
273 |
*/ if(button1_read()){
|
|
264 | 274 |
test_sending(); |
265 | 275 |
break; |
266 | 276 |
} |
... | ... | |
308 | 318 |
for(count = 0; count < 5; count++){ |
309 | 319 |
usb_puti(count); |
310 | 320 |
usb_puti(wl_send_basic(&count, 1)); |
311 |
delay_ms(count * 10);
|
|
321 |
delay_ms(1000);
|
|
312 | 322 |
} |
313 | 323 |
for(count = 5; count < 10; count++){ |
314 | 324 |
usb_puti(count); |
315 | 325 |
usb_puti(wl_send_global(&count, 1, 0)); |
316 |
delay_ms(count * 10);
|
|
326 |
delay_ms(1000);
|
|
317 | 327 |
} |
318 | 328 |
for(count = 10; count < 15; count++){ |
319 | 329 |
usb_puti(count); |
320 | 330 |
usb_puti(wl_send_pan(&count, 1, xbee_get_pan())); |
321 |
delay_ms(count * 10);
|
|
331 |
delay_ms(1000);
|
|
322 | 332 |
} |
323 |
for(count = 15; count < 20; count++){ |
|
333 |
/* for(count = 15; count < 20; count++){
|
|
324 | 334 |
usb_puti(count); |
325 | 335 |
usb_puti(wl_send_robot(&count, 1, 0, friendAddress, FAST)); |
326 |
delay_ms(count * 10);
|
|
336 |
delay_ms(1000);
|
|
327 | 337 |
} |
328 |
for(count = 20; count < 25; count++){ |
|
338 |
*/ for(count = 20; count < 25; count++){
|
|
329 | 339 |
usb_puti(count); |
330 | 340 |
usb_puti(wl_send_global(&count, 1, 1)); |
331 |
delay_ms(count * 10);
|
|
341 |
delay_ms(1000);
|
|
332 | 342 |
} |
333 | 343 |
for(count = 25; count < 30; count++){ |
334 | 344 |
usb_puti(count); |
335 | 345 |
usb_puti(wl_send_global(&count, 1, 2)); |
336 |
delay_ms(count * 10);
|
|
346 |
delay_ms(1000);
|
|
337 | 347 |
} |
338 | 348 |
for(count = 30; count < 35; count++){ |
339 | 349 |
usb_puti(count); |
340 | 350 |
usb_puti(wl_send_global(&count, 1, 3)); |
341 |
delay_ms(count * 10);
|
|
351 |
delay_ms(1000);
|
|
342 | 352 |
} |
343 | 353 |
for(count = 35; count < 40; count++){ |
344 | 354 |
usb_puti(count); |
345 | 355 |
usb_puti(wl_send_global(&count, 1, 4)); |
346 |
delay_ms(count * 10);
|
|
356 |
delay_ms(1000);
|
|
347 | 357 |
} |
348 | 358 |
//FAST mode tests completed. Now testing ACK system |
349 |
for(count = 40; count < 45; count++){ |
|
359 |
/* for(count = 40; count < 45; count++){
|
|
350 | 360 |
usb_puti(count); |
351 | 361 |
usb_puti(wl_send_robot(&count, 1, 0, friendAddress, RELIABLE)); |
352 |
delay_ms(count * 10);
|
|
362 |
delay_ms(1000);
|
|
353 | 363 |
} |
354 | 364 |
for(count = 45; count < 50; count++){ |
355 | 365 |
usb_puti(count); |
356 | 366 |
usb_puti(wl_send_robot(&count, 1, 1, friendAddress, RELIABLE)); |
357 |
delay_ms(count * 10);
|
|
367 |
delay_ms(1000);
|
|
358 | 368 |
} |
359 | 369 |
for(count = 50; count < 55; count++){ |
360 | 370 |
usb_puti(count); |
361 | 371 |
usb_puti(wl_send_robot(&count, 1, 2, friendAddress, RELIABLE)); |
362 |
delay_ms(count * 10);
|
|
372 |
delay_ms(1000);
|
|
363 | 373 |
} |
364 | 374 |
for(count = 55; count < 60; count++){ |
365 | 375 |
usb_puti(count); |
366 | 376 |
usb_puti(wl_send_robot(&count, 1, 3, friendAddress, RELIABLE)); |
367 |
delay_ms(count * 10);
|
|
377 |
delay_ms(1000);
|
|
368 | 378 |
} |
369 | 379 |
for(count = 60; count < 65; count++){ |
370 | 380 |
usb_puti(count); |
371 | 381 |
usb_puti(wl_send_robot(&count, 1, 4, friendAddress, RELIABLE)); |
372 |
delay_ms(count * 10);
|
|
382 |
delay_ms(1000);
|
|
373 | 383 |
} |
374 | 384 |
WL_DEBUG_PRINT_P("ACK Errors: "); |
375 | 385 |
usb_puti(wl_ack_error()); |
... | ... | |
382 | 392 |
} |
383 | 393 |
WL_DEBUG_PRINT_P("ACK Errors: "); |
384 | 394 |
usb_puti(wl_ack_error()); |
385 |
} |
|
395 |
*/}
|
|
386 | 396 |
|
387 | 397 |
void test_receiving(){ |
388 | 398 |
int8_t result, length; |
389 | 399 |
char* data[8]; |
390 | 400 |
while(1){ |
391 |
result = wl_get(data, length); |
|
401 |
result = wl_get_basic(data, length);
|
|
392 | 402 |
if(result){ |
393 |
usb_puti(*data); |
|
403 |
WL_DEBUG_PRINT_P("\r\nData length: "); |
|
404 |
WL_DEBUG_PRINT_INT(result); |
|
405 |
WL_DEBUG_PRINT_P("\r\nData: "); |
|
406 |
WL_DEBUG_PRINT_HEX(*data); |
|
407 |
}else{ |
|
408 |
delay_ms(100); |
|
394 | 409 |
} |
395 | 410 |
} |
396 | 411 |
} |
Also available in: Unified diff