Revision 1282
Fixes: robot_read_bom_all
trunk/code/projects/diagnostic_station/station/dump_robot.c | ||
---|---|---|
50 | 50 |
|
51 | 51 |
void dump_robot_bom (void) |
52 | 52 |
{ |
53 |
uint16_t bom[16];
|
|
53 |
int16_t bom[16]; |
|
54 | 54 |
char c; |
55 | 55 |
|
56 | 56 |
while (usb_getc_nb (&c)==-1) |
57 | 57 |
{ |
58 | 58 |
// First read all of the values, then print them, because it's much more readable that way. |
59 | 59 |
|
60 |
for (uint8_t i=0; i<16; ++i) |
|
61 |
robot_read_bom (i, &bom[i]); |
|
62 |
//robot_read_bom_all (bom); |
|
60 |
//for (uint8_t i=0; i<16; ++i) |
|
61 |
//robot_read_bom (i, &bom[i]); |
|
62 |
|
|
63 |
robot_read_bom_all (bom); |
|
63 | 64 |
|
64 | 65 |
for (uint8_t i=0; i<16; ++i) |
65 | 66 |
{ |
trunk/code/projects/diagnostic_station/station/comm_robot.c | ||
---|---|---|
13 | 13 |
#define received_state_received 3 |
14 | 14 |
#define received_state_uninitialized 4 |
15 | 15 |
|
16 |
uint8_t received_buffer[10]; // Maximum length of a packet to be handled |
|
16 |
#define MAX_PACKET_LENGTH 32 |
|
17 |
|
|
18 |
uint8_t received_buffer[MAX_PACKET_LENGTH]; // Maximum length of a packet to be handled |
|
17 | 19 |
uint8_t received_length; |
18 | 20 |
uint8_t received_state; |
19 | 21 |
|
... | ... | |
224 | 226 |
} |
225 | 227 |
} |
226 | 228 |
|
227 |
bool robot_read_bom_all (uint16_t *value)
|
|
229 |
bool robot_read_bom_all (int16_t *value) |
|
228 | 230 |
{ |
229 | 231 |
send_request_packet(station_robot_read_bom_all, NULL, 0); |
230 | 232 |
|
... | ... | |
279 | 281 |
// The packet buffer might be overwritten after this function returns, so we have to make a copy of the data. |
280 | 282 |
|
281 | 283 |
// First, determine the number of bytes to copy. It is the minimum of the received length and the size of the data |
282 |
// buffer the data is copied to. |
|
284 |
// buffer the data is copied to. TODO: signal an error if this happens.
|
|
283 | 285 |
received_length=length; |
284 | 286 |
if (sizeof (received_buffer)<received_length) received_length=sizeof (received_buffer); |
285 | 287 |
|
trunk/code/projects/diagnostic_station/station/comm_robot.h | ||
---|---|---|
17 | 17 |
bool robot_read_encoders (int16_t *left, int16_t *right); |
18 | 18 |
bool robot_read_bom (uint8_t num, uint16_t *value); |
19 | 19 |
bool robot_read_rangefinder (uint8_t num, uint16_t *value); |
20 |
bool robot_read_bom_all (uint16_t *value);
|
|
20 |
bool robot_read_bom_all (int16_t *value); |
|
21 | 21 |
|
22 | 22 |
#define motor_direction_off 0 |
23 | 23 |
#define motor_direction_forward 1 |
trunk/code/projects/diagnostic_station/robot/main.c | ||
---|---|---|
126 | 126 |
} |
127 | 127 |
|
128 | 128 |
static void message_read_bom_all(int length, uint8_t *data){ |
129 |
int i; |
|
130 |
int16_t value[16]; |
|
129 |
int16_t value; |
|
131 | 130 |
char senddata[32]; |
131 |
|
|
132 | 132 |
bom_refresh(BOM_ALL); |
133 |
for(i=0; i<16; i++){ |
|
134 |
value[i] = bom_get(i); |
|
135 |
senddata[2*i] = WORD_BYTE_0 (value[i]); |
|
136 |
senddata[(2*i)+1] = WORD_BYTE_1 (value[i]); |
|
133 |
|
|
134 |
for(uint8_t i=0; i<16; ++i){ |
|
135 |
value=bom_get(i); |
|
136 |
senddata[2*i ] = WORD_BYTE_0 (value); |
|
137 |
senddata[2*i+1] = WORD_BYTE_1 (value); |
|
137 | 138 |
} |
138 | 139 |
|
139 | 140 |
wl_send_global_packet(robot_station_group, robot_station_data_bom_all, senddata, 32, 0); |
Also available in: Unified diff