Project

General

Profile

Revision 717

Added by Jason knichel about 16 years ago

added a bunch of TODO comments that will improve the style, efficiency, and possibly memory usage of the wireless library

View differences:

xbee.c
107 107
#endif
108 108

  
109 109
// TODO: is this a good size?
110
//TODO: does this buffer size need to be so large?  we have constrained memory, so this should be as small as feasibly possible
110 111
#define XBEE_BUFFER_SIZE	256
111 112
// a buffer for data received from the XBee
112 113
char arrival_buf[XBEE_BUFFER_SIZE];
......
117 118

  
118 119

  
119 120
//used to store packets as they are read
121

  
122
//TODO: does this need to be 128?  can it be smaller to save memory?
123
//TODO: this shouldn't be hardcoded as 128.  it should be a define.
120 124
static char xbee_buf[128];
121 125
static int currentBufPos = 0;
122 126

  
......
127 131
static int xbee_pending_channel = XBEE_CHANNEL_DEFAULT;
128 132
static volatile unsigned int xbee_address = 0;
129 133

  
134
//TODO: this is only needed for the computer side, right?  I'm going to put #ifndef ROBOT around it to remove it from robot code
135
#ifndef ROBOT
130 136
void printHex(char * s, int len) {
131 137
  int i;
132 138
  for (i = 0; i < len; i++) {
......
134 140
  }
135 141
  printf("\n");
136 142
}
143
#endif
137 144

  
138 145

  
139 146
/*Function Implementations*/
......
190 197
			fprintf(stderr, "xbee_read failed.\n");
191 198
			return NULL;
192 199
		}
193
		
200

  
194 201
		//DEBUGGING PRINT
195 202
		//printf("interrupt: %c (%d)\n", c, (int)c);
196 203
		arrival_buf[buffer_last] = c;
......
340 347
	//	printf("After exiting while loop to get xbee_address.\n");
341 348
#else
342 349
	//wait to return until the address is set
350
  //TODO: this shouldn't wait indefinitely.  There should be some sort of reasonable timeout
351
  // so if the address is never set right, an error can be returned instead of having the
352
  // robot hang forever
343 353
	while (xbee_address == 0) {
344 354
	  xbee_get_packet(NULL);
345 355
	}
......
419 429
 *
420 430
 * @param c the string to send to the XBEE
421 431
 **/
432
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
433
// it reduces code size or not should be done to be sure.
422 434
static int xbee_send_string(char* c)
423 435
{
424 436
	return xbee_send(c, strlen(c));
......
489 501
/**
490 502
 * Exit API mode. (warning - does not check for response)
491 503
 **/
504
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
505
// it reduces code size or not should be done to be sure.
492 506
static int xbee_exit_api_mode()
493 507
{
494 508
	return xbee_send_string("ATAP 0\r");
......
497 511
/**
498 512
 * Wait until the string "OK\r" is received from the XBee.
499 513
 **/
514
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
515
// it reduces code size or not should be done to be sure.
500 516
static int xbee_wait_for_ok()
501 517
{
502 518
  //DEBUGGING PRINT
......
633 649
 * use ID to read the PAN ID and MY to return the XBee ID.
634 650
 * See the XBee reference guide for a complete listing.
635 651
 **/
652
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
653
// it reduces code size or not should be done to be sure.
636 654
static int xbee_send_read_at_command(char* command)
637 655
{
638 656
	return xbee_send_modify_at_command(command, NULL);
......
1009 1027
 * @return the personal area network id, or
1010 1028
 * XBEE_PAN_DEFAULT if it has not yet been set.
1011 1029
 **/
1030
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
1031
// it reduces code size or not should be done to be sure.
1012 1032
unsigned int xbee_get_pan_id()
1013 1033
{
1014 1034
	return xbee_panID;
......
1045 1065
 *
1046 1066
 * @see xbee_set_channel
1047 1067
 **/
1068
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
1069
// it reduces code size or not should be done to be sure.
1048 1070
int xbee_get_channel(void)
1049 1071
{
1050 1072
	return xbee_channel;
......
1057 1079
 *
1058 1080
 * @return the 16-bit address of the XBee.
1059 1081
 **/
1082
//TODO: this function is so simple, it *may* be beneficial to inline this function.  testing of if
1083
// it reduces code size or not should be done to be sure.
1060 1084
unsigned int xbee_get_address()
1061 1085
{
1062 1086
	return xbee_address;

Also available in: Unified diff