Revision f8cf404d components/Lidar.cpp
components/Lidar.cpp | ||
---|---|---|
1 | 1 |
#include <amiro/Lidar.h> |
2 | 2 |
|
3 |
#include <global.hpp> |
|
4 |
|
|
3 | 5 |
using namespace chibios_rt; |
4 | 6 |
using namespace amiro; |
5 | 7 |
|
8 |
extern Global global; |
|
9 |
|
|
6 | 10 |
uint8_t Lidar::scannedData[NUMBER_OF_CHARACTERS + 1] = {}; |
7 | 11 |
|
8 | 12 |
Lidar::Lidar(const uint8_t boardId, Lidar::SETUP setup) |
... | ... | |
49 | 53 |
flushSD2InputQueue(); |
50 | 54 |
|
51 | 55 |
// Configure LIDAR serial interface speed |
52 |
// chprintf((BaseSequentialStream*) &SD1, "Speed switch to " STR(SD_SPEED) "\n");
|
|
56 |
// chprintf((BaseSequentialStream*) &global.sercanmux1, "Speed switch to " STR(SD_SPEED) "\n");
|
|
53 | 57 |
chprintf((BaseSequentialStream*) &SD2, "SS" STR(SD_SPEED_PREFIX) STR(SD_SPEED) LF); |
54 | 58 |
|
55 | 59 |
// Check if the switch went well, otherwise terminate the thread |
56 | 60 |
if (checkDataString("SS" STR(SD_SPEED_PREFIX) STR(SD_SPEED) "\n00P\n\n")) { |
57 |
chprintf((BaseSequentialStream*) &SD1, "Lidar speed switch OK\n");
|
|
61 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "Lidar speed switch OK\n");
|
|
58 | 62 |
// Configure serial interface of STM32 |
59 | 63 |
sdStop(&SD2); |
60 | 64 |
SerialConfig sdLidarconf = { SD_SPEED, 0, 0, 0 }; |
61 | 65 |
sdStart(&SD2, &sdLidarconf); |
62 | 66 |
} else { |
63 |
chprintf((BaseSequentialStream*) &SD1, "Lidar speed switch NOT OK: Terminating Lidar \n");
|
|
67 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "Lidar speed switch NOT OK: Terminating Lidar \n");
|
|
64 | 68 |
palWritePad(GPIOB, GPIOB_LASER_EN, PAL_LOW); |
65 | 69 |
return -1; |
66 | 70 |
} |
... | ... | |
200 | 204 |
--this->dataIdx; |
201 | 205 |
this->lastInput = this->newInput; |
202 | 206 |
} |
203 |
//chprintf((BaseSequentialStream*) &SD1, "%d ", this->newInput);
|
|
207 |
//chprintf((BaseSequentialStream*) &global.sercanmux1, "%d ", this->newInput);
|
|
204 | 208 |
} else { |
205 | 209 |
step = FAIL; |
206 | 210 |
} |
... | ... | |
216 | 220 |
break; |
217 | 221 |
case DATA_SHOW: |
218 | 222 |
// Show the decoded data |
219 |
chprintf((BaseSequentialStream*) &SD1, "\n%d", this->dataCounter);
|
|
223 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "\n%d", this->dataCounter);
|
|
220 | 224 |
for (uint32_t idx=0; idx < this->dataIdx; idx+=2) { |
221 |
chprintf((BaseSequentialStream*) &SD1, "\n%d", *((uint16_t*) &(Lidar::scannedData[idx])));
|
|
225 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "\n%d", *((uint16_t*) &(Lidar::scannedData[idx])));
|
|
222 | 226 |
} |
223 | 227 |
step = FINISH; |
224 | 228 |
break; |
... | ... | |
252 | 256 |
if (lastInput == 10 && newInput == 10) { |
253 | 257 |
return; |
254 | 258 |
} else { |
255 |
chprintf((BaseSequentialStream*) &SD1, "%c", newInput);
|
|
259 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "%c", newInput);
|
|
256 | 260 |
} |
257 | 261 |
lastInput = newInput; |
258 | 262 |
} else { |
259 |
chprintf((BaseSequentialStream*) &SD1, "TIMEOUT\n", newInput);
|
|
263 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "TIMEOUT\n", newInput);
|
|
260 | 264 |
return; |
261 | 265 |
} |
262 | 266 |
} |
... | ... | |
291 | 295 |
|
292 | 296 |
void Lidar::printDetails() { |
293 | 297 |
|
294 |
chprintf((BaseSequentialStream*) &SD1, "Print sensor details:\n");
|
|
298 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "Print sensor details:\n");
|
|
295 | 299 |
|
296 | 300 |
// Tell the sensor to transmit its details |
297 | 301 |
chprintf((BaseSequentialStream*) &SD2, "VV\n"); |
... | ... | |
302 | 306 |
|
303 | 307 |
void Lidar::printSpecification() { |
304 | 308 |
|
305 |
chprintf((BaseSequentialStream*) &SD1, "Print sensor specification:\n");
|
|
309 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "Print sensor specification:\n");
|
|
306 | 310 |
|
307 | 311 |
// Tell the sensor to transmit its specifications |
308 | 312 |
chprintf((BaseSequentialStream*) &SD2, "PP\n"); |
... | ... | |
312 | 316 |
} |
313 | 317 |
|
314 | 318 |
void Lidar::printInformation() { |
315 |
chprintf((BaseSequentialStream*) &SD1, "Print sensor information:\n");
|
|
319 |
chprintf((BaseSequentialStream*) &global.sercanmux1, "Print sensor information:\n");
|
|
316 | 320 |
|
317 | 321 |
// Tell the sensor to transmit its information |
318 | 322 |
chprintf((BaseSequentialStream*) &SD2, "II\n"); |
Also available in: Unified diff