Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MODSERIAL FATFileSystem
MbedLogger/MbedLogger.hpp@39:58375ca6b6ff, 2017-12-21 (annotated)
- Committer:
- tnhnrl
- Date:
- Thu Dec 21 23:13:44 2017 +0000
- Revision:
- 39:58375ca6b6ff
- Parent:
- 36:966a86937e17
Pool-tested code with Mbed logging and OpenLog (SD card)
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| tnhnrl | 32:f2f8ae34aadc | 1 | #ifndef MBEDLOGGER_HPP | 
| tnhnrl | 32:f2f8ae34aadc | 2 | #define MBEDLOGGER_HPP | 
| tnhnrl | 32:f2f8ae34aadc | 3 | |
| tnhnrl | 32:f2f8ae34aadc | 4 | #include "mbed.h" | 
| tnhnrl | 32:f2f8ae34aadc | 5 | #include <string> | 
| tnhnrl | 32:f2f8ae34aadc | 6 | using namespace std; | 
| tnhnrl | 32:f2f8ae34aadc | 7 | |
| tnhnrl | 32:f2f8ae34aadc | 8 | #include "DirectoryList.h" | 
| tnhnrl | 32:f2f8ae34aadc | 9 | |
| tnhnrl | 32:f2f8ae34aadc | 10 | class MbedLogger { | 
| tnhnrl | 32:f2f8ae34aadc | 11 | public: | 
| tnhnrl | 32:f2f8ae34aadc | 12 | MbedLogger(); //constructor | 
| tnhnrl | 32:f2f8ae34aadc | 13 | void createTestLog(); //test log function | 
| tnhnrl | 32:f2f8ae34aadc | 14 | |
| tnhnrl | 32:f2f8ae34aadc | 15 | //one log file type for now | 
| tnhnrl | 36:966a86937e17 | 16 | void openFile(); | 
| tnhnrl | 32:f2f8ae34aadc | 17 | |
| tnhnrl | 32:f2f8ae34aadc | 18 | //save float array to file (append each time) | 
| tnhnrl | 36:966a86937e17 | 19 | void saveDataToFile(int input_state, float *input); | 
| tnhnrl | 32:f2f8ae34aadc | 20 | |
| tnhnrl | 32:f2f8ae34aadc | 21 | //print the directory to the screen | 
| tnhnrl | 32:f2f8ae34aadc | 22 | void printMbedDirectory(); | 
| tnhnrl | 32:f2f8ae34aadc | 23 | |
| tnhnrl | 32:f2f8ae34aadc | 24 | //close the current file stream [before creating a new one] | 
| tnhnrl | 32:f2f8ae34aadc | 25 | void closeFile(); | 
| tnhnrl | 35:2f66ea4863d5 | 26 | |
| tnhnrl | 35:2f66ea4863d5 | 27 | //print the current MBED log file | 
| tnhnrl | 35:2f66ea4863d5 | 28 | void printCurrentLogFile(); | 
| tnhnrl | 32:f2f8ae34aadc | 29 | |
| tnhnrl | 32:f2f8ae34aadc | 30 | private: | 
| tnhnrl | 32:f2f8ae34aadc | 31 | int _f; //file name number | 
| tnhnrl | 32:f2f8ae34aadc | 32 | char _file_name[128]; //file name placeholder | 
| tnhnrl | 32:f2f8ae34aadc | 33 | int _file_number; | 
| tnhnrl | 32:f2f8ae34aadc | 34 | |
| tnhnrl | 32:f2f8ae34aadc | 35 | FILE *_fp; //the file is a class member variable | 
| tnhnrl | 32:f2f8ae34aadc | 36 | }; | 
| tnhnrl | 32:f2f8ae34aadc | 37 | |
| tnhnrl | 32:f2f8ae34aadc | 38 | #endif |