2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Logger.cpp@29:cb2f55fbfe9c, 2018-12-22 (annotated)
- Committer:
- shimniok
- Date:
- Sat Dec 22 20:28:52 2018 +0000
- Revision:
- 29:cb2f55fbfe9c
- Parent:
- 24:a7f92dfc5310
- Child:
- 30:ed791f1f7f7d
Updates to shell. Implemented eventqueue-based data logging for gps. added start/stop/enabled functions to Logger and shell commands to start/stop/status logging
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 24:a7f92dfc5310 | 1 | #include "Logger.h" |
shimniok | 24:a7f92dfc5310 | 2 | |
shimniok | 24:a7f92dfc5310 | 3 | Logger::Logger(const char *file) { |
shimniok | 24:a7f92dfc5310 | 4 | _file = file; |
shimniok | 29:cb2f55fbfe9c | 5 | _fp = NULL; |
shimniok | 29:cb2f55fbfe9c | 6 | } |
shimniok | 29:cb2f55fbfe9c | 7 | |
shimniok | 29:cb2f55fbfe9c | 8 | |
shimniok | 29:cb2f55fbfe9c | 9 | void Logger::start() { |
shimniok | 29:cb2f55fbfe9c | 10 | if (_fp == NULL) _fp = fopen(_file, "a"); |
shimniok | 29:cb2f55fbfe9c | 11 | } |
shimniok | 29:cb2f55fbfe9c | 12 | |
shimniok | 29:cb2f55fbfe9c | 13 | |
shimniok | 29:cb2f55fbfe9c | 14 | void Logger::stop() { |
shimniok | 29:cb2f55fbfe9c | 15 | if (_fp && fclose(_fp) != EOF) { |
shimniok | 29:cb2f55fbfe9c | 16 | _fp = NULL; |
shimniok | 29:cb2f55fbfe9c | 17 | } |
shimniok | 29:cb2f55fbfe9c | 18 | } |
shimniok | 29:cb2f55fbfe9c | 19 | |
shimniok | 29:cb2f55fbfe9c | 20 | |
shimniok | 29:cb2f55fbfe9c | 21 | bool Logger::enabled() { |
shimniok | 29:cb2f55fbfe9c | 22 | return (_fp != NULL); |
shimniok | 24:a7f92dfc5310 | 23 | } |
shimniok | 24:a7f92dfc5310 | 24 | |
shimniok | 24:a7f92dfc5310 | 25 | |
shimniok | 24:a7f92dfc5310 | 26 | void Logger::log_gps(GpsData gd) { |
shimniok | 29:cb2f55fbfe9c | 27 | if (enabled()) { |
shimniok | 29:cb2f55fbfe9c | 28 | fprintf(_fp, "G,%llu,%3.9f,%3.9f,%3.1f,%2.1f,%2.1f,%d\n", |
shimniok | 29:cb2f55fbfe9c | 29 | Kernel::get_ms_count(), |
shimniok | 29:cb2f55fbfe9c | 30 | gd.latitude, |
shimniok | 29:cb2f55fbfe9c | 31 | gd.longitude, |
shimniok | 29:cb2f55fbfe9c | 32 | gd.course, |
shimniok | 29:cb2f55fbfe9c | 33 | gd.speed, |
shimniok | 29:cb2f55fbfe9c | 34 | gd.hdop, |
shimniok | 29:cb2f55fbfe9c | 35 | gd.svcount |
shimniok | 29:cb2f55fbfe9c | 36 | ); |
shimniok | 29:cb2f55fbfe9c | 37 | } |
shimniok | 24:a7f92dfc5310 | 38 | } |
shimniok | 24:a7f92dfc5310 | 39 | |
shimniok | 24:a7f92dfc5310 | 40 | |
shimniok | 24:a7f92dfc5310 | 41 | void Logger::log_estimation() { |
shimniok | 29:cb2f55fbfe9c | 42 | if (enabled()) { |
shimniok | 24:a7f92dfc5310 | 43 | } |
shimniok | 24:a7f92dfc5310 | 44 | } |