serialcomm.hpp
Go to the documentation of this file.
00001 /*
00002  * serialcomm.hpp
00003  *
00004  *  Created on: June 05, 2012
00005  *      Author: mwalecki
00006  */
00007 
00008 #ifndef ELEKTRON_HPP_
00009 #define ELEKTRON_HPP_
00010 
00011 #include <stdint.h>
00012 #include <termios.h>
00013 #include <cstdlib>
00014 #include <cstdio>
00015 #include <unistd.h>
00016 #include <fcntl.h>
00017 #include <sys/time.h>
00018 #include <sys/types.h>
00019 #include <sys/stat.h>
00020 #include <string>
00021 #include <fstream>
00022 #include <inttypes.h>
00023 
00024 // baudrate
00025 #define DEFAULT_BAUD B57600
00026 // port
00027 #define DEFAULT_PORT = "/dev/ttyACM0"
00028 
00029 
00030 
00031 class SerialComm {
00032 public:
00033         SerialComm(const std::string& port, int baud = DEFAULT_BAUD);
00034         ~SerialComm();
00035         
00036         int write(uint8_t* buf, int len);
00037         int read(uint8_t* buf, int len);
00038         uint8_t readOneByte();
00039         bool isConnected();
00040         
00041 
00042 private:
00043         int fd;
00044         struct termios oldtio;
00045         bool connected;
00046         fd_set rfds;
00047         struct timeval tv;
00048         
00049 };
00050 
00051 #endif /* ELEKTRON_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


elektron_base
Author(s): Konrad Banachowicz
autogenerated on Thu Nov 14 2013 11:57:04