Zachary Rubin / Mbed 2 deprecated PVA_logger

Dependencies:   FatFileSystem mbed

Committer:
Xach
Date:
Sat Sep 08 20:40:58 2012 +0000
Revision:
0:82a02991476c
a program i made a while back to log gps/accelerometer data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Xach 0:82a02991476c 1 #pragma once
Xach 0:82a02991476c 2
Xach 0:82a02991476c 3 // This is a buffered serial reading class, using the serial interrupt introduced in mbed library version 18 on 17/11/09
Xach 0:82a02991476c 4
Xach 0:82a02991476c 5 // In the simplest case, construct it with a buffer size at least equal to the largest message you
Xach 0:82a02991476c 6 // expect your program to receive in one go.
Xach 0:82a02991476c 7 #define STRING_BUFFERS 24
Xach 0:82a02991476c 8
Xach 0:82a02991476c 9 class SerialBuffered : public Serial {
Xach 0:82a02991476c 10 public:
Xach 0:82a02991476c 11 SerialBuffered( size_t bufferSize, PinName tx, PinName rx );
Xach 0:82a02991476c 12 virtual ~SerialBuffered();
Xach 0:82a02991476c 13
Xach 0:82a02991476c 14 int getc(); // will block till the next character turns up, or return -1 if there is a timeout
Xach 0:82a02991476c 15
Xach 0:82a02991476c 16 int readable(); // returns 1 if there is a character available to read, 0 otherwise
Xach 0:82a02991476c 17
Xach 0:82a02991476c 18 int strReady(); // returns the number of strings ready
Xach 0:82a02991476c 19
Xach 0:82a02991476c 20
Xach 0:82a02991476c 21
Xach 0:82a02991476c 22
Xach 0:82a02991476c 23 void setTimeout( float seconds ); // maximum time in seconds that getc() should block
Xach 0:82a02991476c 24 // while waiting for a character
Xach 0:82a02991476c 25 // Pass -1 to disable the timeout.
Xach 0:82a02991476c 26
Xach 0:82a02991476c 27 size_t readBytes( uint8_t *bytes, size_t requested ); // read requested bytes into a buffer,
Xach 0:82a02991476c 28 // return number actually read,
Xach 0:82a02991476c 29 // which may be less than requested if there has been a timeout
Xach 0:82a02991476c 30
Xach 0:82a02991476c 31 void startReadStrings( char term);
Xach 0:82a02991476c 32 void stopReadStrings();
Xach 0:82a02991476c 33 char* getString();
Xach 0:82a02991476c 34 int stringsAvailable();
Xach 0:82a02991476c 35 private:
Xach 0:82a02991476c 36
Xach 0:82a02991476c 37 void handleInterrupt();
Xach 0:82a02991476c 38
Xach 0:82a02991476c 39
Xach 0:82a02991476c 40 uint8_t *m_buff; // points at a circular buffer, containing data from m_contentStart, for m_contentSize bytes, wrapping when you get to the end
Xach 0:82a02991476c 41 uint16_t m_contentStart; // index of first bytes of content
Xach 0:82a02991476c 42 uint16_t m_contentEnd; // index of bytes after last byte of content
Xach 0:82a02991476c 43 uint16_t m_buffSize;
Xach 0:82a02991476c 44 float m_timeout;
Xach 0:82a02991476c 45 Timer m_timer;
Xach 0:82a02991476c 46 int unreadStrings;
Xach 0:82a02991476c 47 char term;
Xach 0:82a02991476c 48 bool ReadStrings;
Xach 0:82a02991476c 49 char *str_buff[STRING_BUFFERS];
Xach 0:82a02991476c 50 int str_buff_pos;
Xach 0:82a02991476c 51 int str_wr_buff_pos;
Xach 0:82a02991476c 52 };