Log data to a micro SD card.
Dependencies: SDFileSystem mbed
Log.h@1:c5e56e2580bf, 2015-05-04 (annotated)
- Committer:
- onaka
- Date:
- Mon May 04 07:10:55 2015 +0000
- Revision:
- 1:c5e56e2580bf
revision 1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| onaka | 1:c5e56e2580bf | 1 | //**** Log.h **** |
| onaka | 1:c5e56e2580bf | 2 | //ログをリングバッファを用いて、 |
| onaka | 1:c5e56e2580bf | 3 | //シリアル送信、SDカード出力を行う |
| onaka | 1:c5e56e2580bf | 4 | //*************** |
| onaka | 1:c5e56e2580bf | 5 | |
| onaka | 1:c5e56e2580bf | 6 | #ifndef LOG_H_ |
| onaka | 1:c5e56e2580bf | 7 | #define LOG_H_ |
| onaka | 1:c5e56e2580bf | 8 | |
| onaka | 1:c5e56e2580bf | 9 | #include "mbed.h" |
| onaka | 1:c5e56e2580bf | 10 | #include "SDFileSystem.h" |
| onaka | 1:c5e56e2580bf | 11 | #include "RingBuffer.h" |
| onaka | 1:c5e56e2580bf | 12 | |
| onaka | 1:c5e56e2580bf | 13 | class Log{ |
| onaka | 1:c5e56e2580bf | 14 | public: |
| onaka | 1:c5e56e2580bf | 15 | Log(PinName rx, PinName tx, PinName mosi, PinName miso, PinName sck, PinName cs, const char* name); |
| onaka | 1:c5e56e2580bf | 16 | int initialize_sdlog(const char* str); |
| onaka | 1:c5e56e2580bf | 17 | void close(); |
| onaka | 1:c5e56e2580bf | 18 | int find_last(); |
| onaka | 1:c5e56e2580bf | 19 | void puts(const char *str); |
| onaka | 1:c5e56e2580bf | 20 | void putc(char ch); |
| onaka | 1:c5e56e2580bf | 21 | void write_data(uint8_t* buf, int16_t size); |
| onaka | 1:c5e56e2580bf | 22 | bool is_empty(); |
| onaka | 1:c5e56e2580bf | 23 | int16_t recieve_buffer_size(); |
| onaka | 1:c5e56e2580bf | 24 | int16_t getc(); |
| onaka | 1:c5e56e2580bf | 25 | int16_t read_data(uint8_t* buf, int16_t size); |
| onaka | 1:c5e56e2580bf | 26 | char int_tx(); |
| onaka | 1:c5e56e2580bf | 27 | void int_serial_tx(); |
| onaka | 1:c5e56e2580bf | 28 | |
| onaka | 1:c5e56e2580bf | 29 | protected: |
| onaka | 1:c5e56e2580bf | 30 | SDFileSystem _sd; |
| onaka | 1:c5e56e2580bf | 31 | FILE *fp; |
| onaka | 1:c5e56e2580bf | 32 | Serial _device; |
| onaka | 1:c5e56e2580bf | 33 | RingBuffer buf_send; |
| onaka | 1:c5e56e2580bf | 34 | RingBuffer buf_recieve; |
| onaka | 1:c5e56e2580bf | 35 | }; |
| onaka | 1:c5e56e2580bf | 36 | |
| onaka | 1:c5e56e2580bf | 37 | #endif /* LOG_H_ */ |