2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: main.cpp
- Revision:
- 29:cb2f55fbfe9c
- Parent:
- 27:bfe141fad082
- Child:
- 30:ed791f1f7f7d
--- a/main.cpp Sat Dec 22 06:56:55 2018 +0000 +++ b/main.cpp Sat Dec 22 20:28:52 2018 +0000 @@ -42,9 +42,8 @@ /////////////////////////////////////////////////////////////////////////////// // Logging -EventQueue logQueue(8 * EVENTS_EVENT_SIZE); -Logger logger("/etc/test.log"); - +EventQueue logQueue(16 * EVENTS_EVENT_SIZE); +Logger logger("/log/test.csv"); /////////////////////////////////////////////////////////////////////////////// // Updater @@ -66,9 +65,9 @@ led2 = !led2; ublox.read(d.latitude, d.longitude, d.course, d.speed, d.hdop, d.svcount); - //logQueue.call(&logger, &Logger::log_gps, d); + logQueue.call(&logger, &Logger::log_gps, d); } - + // ISR for GPS serial, passes off to thread void gps_handler() { while (s.readable()) { @@ -125,6 +124,31 @@ printf("Encoder: %d\n", u->encoder()); } +void log(int argc, char **argv) +{ + char *usage = "usage: log [start|stop]"; + + if (argc == 1) { + printf("logging "); + if (logger.enabled()) + printf("enabled"); + else + printf("disabled"); + printf("\n"); + } else if (argc == 2) { + if (!strcmp("start", argv[1])) { + logger.start(); + } else if (!strcmp("stop", argv[1])) { + logger.stop(); + } else { + puts(usage); + } + } else { + puts(usage); + } +} + + void bridge_uart1(int argc, char **argv) { RawSerial s(UART1TX, UART1RX, 38400); while (1) { @@ -185,13 +209,13 @@ updaterThread.start(callback(&updaterQueue, &EventQueue::dispatch_forever)); printf("Starting gps...\n"); - Thread gpsThread(osPriorityHigh, 256, 0, "gps"); + Thread gpsThread(osPriorityHigh, 2048, 0, "gps"); gpsThread.start(callback(&gpsQueue, &EventQueue::dispatch_forever)); ublox.subscribe(gps_callback); s.attach(gps_handler); printf("Starting logging...\n"); - Thread logThread(osPriorityNormal, 256, 0, "log"); + Thread logThread(osPriorityNormal, 2048, 0, "log"); logThread.start(callback(&logQueue, &EventQueue::dispatch_forever)); printf("Starting shell...\n"); @@ -201,6 +225,7 @@ sh.attach(read_gps, "gps"); sh.attach(reset, "reset"); sh.attach(stats, "stats"); + sh.attach(log, "log"); sh.run(); while (true) {