Project

General

Profile

Revision 613

Added by Jason knichel about 16 years ago

added some prints that are commented out with DEBUGGING PRINT above it that can be uncommented out later for debugging purposes

did we do anything else?

View differences:

trunk/code/projects/libwireless/lib/xbee.c
127 127
static int xbee_pending_channel = XBEE_CHANNEL_DEFAULT;
128 128
static volatile unsigned int xbee_address = 0;
129 129

  
130
void printHex(char * s, int len) {
131
  int i;
132
  for (i = 0; i < len; i++) {
133
    printf("0x%x ", (int)(s[i]));
134
  }
135
  printf("\n");
136
}
137

  
138

  
130 139
/*Function Implementations*/
131 140

  
132 141
#ifdef ROBOT
......
181 190
			fprintf(stderr, "xbee_read failed.\n");
182 191
			return NULL;
183 192
		}
184

  
193
		
194
		//DEBUGGING PRINT
195
		//printf("interrupt: %c (%d)\n", c, (int)c);
185 196
		arrival_buf[buffer_last] = c;
186 197
		int t = buffer_last + 1;
187 198
		if (t == XBEE_BUFFER_SIZE)
......
272 283
	}
273 284
#endif
274 285

  
286
	//DEBUGGING PRINT
287
	//printf("about to call xbee_enter_command_mode\n");
288

  
275 289
	if (xbee_enter_command_mode() != 0) {
276 290
#ifndef ROBOT
277 291
	  printf("Error returned from xbee_enter_command_mode\n");
......
279 293
		return -1;
280 294
	}
281 295

  
296
	//DEBUGGING PRINT
297
	//printf("about to call xbee_enter_api_mode\n");
298

  
282 299
	if (xbee_enter_api_mode() != 0) {
283 300
#ifndef ROBOT
284 301
	  printf("Error returned from xbee_enter_api_mode\n");
......
286 303
		return -1;
287 304
	}
288 305

  
306
	//DEBUGGING PRINT
307
	//printf("about to call xbee_exit_command_mode\n");
308

  
289 309
	if (xbee_exit_command_mode() != 0) {
290 310
#ifndef ROBOT
291 311
	  printf("Error returned from xbee_exit_command_mode\n");
......
293 313
		return -1;
294 314
	}
295 315

  
316
	//DEBUGGING PRINT
317
	//printf("about to call xbee_send_read_at_command\n");
318

  
296 319
	if (xbee_send_read_at_command("MY")) {
297 320
#ifndef ROBOT
298 321
	  printf("Error returned from xbee_send_read_at_command\n");
......
366 389
	return 0;
367 390

  
368 391
#else
392
	//DEBUGGING PRINT
393
	//printf("in xbee_send ");
394
	//printHex(buf, size);
369 395

  
370 396
	int ret = write(xbee_stream, buf, size);
371 397
	//success
......
473 499
 **/
474 500
static int xbee_wait_for_ok()
475 501
{
502
  //DEBUGGING PRINT
503
  //printf("\tin xbee_wait_for_ok\n");
476 504
	return xbee_wait_for_string("OK\r", 3);
477 505
}
478 506

  
......
485 513
 **/
486 514
static int xbee_wait_for_string(char* s, int len)
487 515
{
516
  //DEBUGGING PRINT
517
  //printf("\t in xbee_wait_for_string\n");
518

  
488 519
#ifndef ROBOT
489 520
  //printf("In xbee_wait_for_string.\n");
490 521
#endif
......
498 529
				buffer_first = 0;
499 530
			}
500 531

  
532
			//DEBUGGING PRINT
533
			//printf("\t\t c is %c (%d)\n", c, (int)c);
534

  
501 535
			if (c == *curr) {
502 536
				curr++;
503 537
			} else {
504 538
#ifndef ROBOT
505
			  return -1; // Computer is less forgiving.
539
			  //return -1; // Computer is less forgiving.
540
			  curr = s;
506 541
#else
507 542
			  curr = s;
508 543
#endif
......
568 603
 **/
569 604
static int xbee_send_frame(char* buf, int len)
570 605
{
606
  printf("in %s and len is %d\n", __FUNCTION__, len);
607

  
571 608
	char prefix[3];
572 609
	prefix[0] = XBEE_FRAME_START;
573 610
	prefix[1] = (len & 0xFF00) >> 8;
......
610 647
 **/
611 648
static int xbee_send_modify_at_command(char* command, char* value)
612 649
{
650
  printf("in %s with command %s and value %s\n", __FUNCTION__, command, value);
651

  
613 652
	char buf[16];
614 653
	int i;
615 654

  
......
901 940

  
902 941
		if (xbee_address == 0)
903 942
		{
943
		  printf("XBee 16-bit address must be set using ATMY.\r\n");
904 944
			WL_DEBUG_PRINT("XBee 16-bit address must be set using ATMY.\r\n");
905 945
			exit(0);
906 946
		}
......
921 961
 */
922 962
static int xbee_handle_packet(char* packet, int len)
923 963
{
964
  //DEBUGGING PRINT
965
  //printf("xbee_handle_packet: ");
966
  //printHex(packet, len);
967

  
924 968
	char command[3] = {1, 2, 3};
925 969
	if (len <= 0) //this should not happend
926 970
	{
......
934 978
			xbee_handle_status(packet[1]);
935 979
			return 1;
936 980
		case XBEE_FRAME_AT_COMMAND_RESPONSE:
981
		  printf("in XBEE_FRAME_AT_COMMAND_RESPONSE case\n");
937 982
			command[0] = packet[2];
938 983
			command[1] = packet[3];
939 984
			command[2] = 0;

Also available in: Unified diff