Revision 911
fixed output filename and unsigned data
trunk/code/projects/mapping/server/test.c | ||
---|---|---|
1 | 1 |
#include <stdlib.h> |
2 | 2 |
#include <stdio.h> |
3 |
#include <curses.h> |
|
3 |
#include <curses.h> // you need to install the ncurses library
|
|
4 | 4 |
#include "../../libwireless/lib/wireless.h" |
5 | 5 |
|
6 | 6 |
#define WL_CNTL_GROUP 4 |
... | ... | |
32 | 32 |
char c; |
33 | 33 |
int robot = atoi(argv[1]); |
34 | 34 |
|
35 |
file = fopen("data_test.txt", "w");
|
|
35 |
file = fopen("input.txt", "w");
|
|
36 | 36 |
if (file == NULL) { |
37 | 37 |
printf("fopen error\n"); |
38 | 38 |
return 1; |
... | ... | |
98 | 98 |
} |
99 | 99 |
|
100 | 100 |
void packet_receive (char type, int source, unsigned char* packet, int length) { |
101 |
fprintf(file, "received packet: ");
|
|
101 |
//expected input: x y theta IR1 IR2 IR3 IR4 IR5
|
|
102 | 102 |
int i, temp; |
103 | 103 |
for (i = 0; i < length; i += 2) { |
104 |
temp = packet[i+1] << 8; |
|
105 |
temp &= 0xFF00; |
|
106 |
temp |= packet[i]; |
|
107 |
fprintf(file, "%d, ", temp); |
|
104 |
temp = (char)packet[i+1] << 8; |
|
105 |
temp |= (char)packet[i]; |
|
106 |
fprintf(file, "%d ", temp); |
|
108 | 107 |
} |
109 | 108 |
fprintf(file, "\n"); |
110 | 109 |
} |
Also available in: Unified diff