Revision 732
New stuff works, fixed bugs, removed malloc.
xbee.c | ||
---|---|---|
106 | 106 |
#endif |
107 | 107 |
|
108 | 108 |
// TODO: is this a good size? |
109 |
#define XBEE_BUFFER_SIZE 256 |
|
109 |
#define XBEE_BUFFER_SIZE 128 |
|
110 |
#define PACKET_BUFFER_SIZE 108 |
|
110 | 111 |
// a buffer for data received from the XBee |
111 | 112 |
char arrival_buf[XBEE_BUFFER_SIZE]; |
112 | 113 |
// location of last unread byte in buffer |
... | ... | |
116 | 117 |
|
117 | 118 |
|
118 | 119 |
//used to store packets as they are read |
119 |
static char xbee_buf[128];
|
|
120 |
static char xbee_buf[PACKET_BUFFER_SIZE];
|
|
120 | 121 |
static int currentBufPos = 0; |
121 | 122 |
|
122 | 123 |
//XBee status |
... | ... | |
177 | 178 |
while (1) |
178 | 179 |
{ |
179 | 180 |
if (xbee_read(&c, 1) != 0) { |
180 |
fprintf(stderr, "xbee_read failed.\n");
|
|
181 |
WL_DEBUG_PRINT("xbee_read failed.\n");
|
|
181 | 182 |
return NULL; |
182 | 183 |
} |
183 | 184 |
|
... | ... | |
204 | 205 |
**/ |
205 | 206 |
int xbee_lib_init() |
206 | 207 |
{ |
207 |
arrival_buf[0] = 'A'; |
|
208 |
arrival_buf[1] = 'A'; |
|
209 |
arrival_buf[2] = 'A'; |
|
210 | 208 |
#ifdef ROBOT |
211 | 209 |
|
212 | 210 |
//enable the receiving interrupt |
... | ... | |
404 | 402 |
} |
405 | 403 |
|
406 | 404 |
/** |
407 |
* Exit API mode. (warning - does not check for response) |
|
408 |
**/ |
|
409 |
static int xbee_exit_api_mode() |
|
410 |
{ |
|
411 |
return xbee_send_string("ATAP 0\r"); |
|
412 |
} |
|
413 |
|
|
414 |
/** |
|
415 | 405 |
* Wait until the string "OK\r" is received from the XBee. |
416 | 406 |
**/ |
417 | 407 |
static void xbee_wait_for_ok() |
Also available in: Unified diff