Zoltan Hudak / mbedPi
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Serial.h Source File

Serial.h

00001 #ifndef _SERIAL_H_
00002 #define _SERIAL_H_
00003 
00004 #include "BCM2835.h"
00005 
00006 class   Serial
00007 {
00008 public:
00009     Serial();
00010     void    baud(int serialSpeed);
00011     int     readable();
00012     char    read();
00013     int     readBytes(char message[], int size);
00014     int     readBytesUntil(char character, char buffer[], int length);
00015     bool    find(const char* target);
00016     bool    findUntil(const char* target, const char* terminal);
00017     long    parseInt();
00018     float   parseFloat();
00019     char    peek();
00020     void    printf(const char* format, ...);
00021     int     write(uint8_t message);
00022     int     write(const char* message);
00023     int     write(char* message, int size);
00024     void    flush();
00025     void    setTimeout(long millis);
00026     void    close();
00027 private:
00028     int             sd, status;
00029     const char*     serialPort;
00030     unsigned char   c;
00031     struct termios  options;
00032     int             speed;
00033     long            timeOut;
00034     timespec        time1, time2;
00035     timespec        timeDiff(timespec start, timespec close);
00036     char*           int2bin(int i);
00037     char*           int2hex(int i);
00038     char*           int2oct(int i);
00039 };
00040 
00041 #endif  // _SERIAL_H_
00042