Skip to content
Snippets Groups Projects
Commit a65049b6 authored by fortissBot's avatar fortissBot
Browse files

Wrong pointer in LaserRangeFinder

refs 7956
parent 3a6bd1d0
No related branches found
No related tags found
No related merge requests found
......@@ -32,32 +32,37 @@ GEN_TYPE_int lrf_read() {
if (uart_filestream == -1)
return -1;
// free buffer
//empty buffer
uart_flush();
//initialize arrays
int i;
char bytes[6];
for (i = 0; i < 6; i++) {
bytes[i] = 0;
}
int n_read = 0;
char value[3];
int n = 0;
int i;
char value[4];
for (i = 0; i < 4; i++) {
value[i] = 0;
}
int n = 0;
int d;
// looks like a blocking call and actually is but is always very fast
// since it only has to read the queue
//receive values
while (1) {
n_read = uart_receive(&bytes, 6, 0);
n_read = uart_receive(bytes, 6, 0);
if(n_read <= 0)
return -1;
for (i = 0; i < n_read; i++) {
if (bytes[i] != 0xd && bytes[i] != 0xa) {
value[n++] = bytes[i];
} else if (atoi(value) != 0) {
d = atoi(value);
for (i = n; i < 3; i++) {
value[i] = 0;
}
return d;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment