BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SerialCom.h Source File

SerialCom.h

00001 /*
00002  * SerialServer.h
00003  * Copyright (c) 2017, ZHAW
00004  * All rights reserved.
00005  *
00006  *  Created on: 05.06.2017
00007  *      Author: Marcel Honegger
00008  */
00009 
00010 #ifndef SERIAL_COM_H_
00011 #define SERIAL_COM_H_
00012 
00013 #include <cstdlib>
00014 #include <string>
00015 #include <vector>
00016 #include <mbed.h>
00017 #include "Signal.h"
00018 
00019 using namespace std;
00020 
00021 
00022 
00023 /**
00024  * This class implements a communication server using a serial interface.
00025  */
00026 class SerialCom {
00027     
00028     public:
00029         
00030                     SerialCom(RawSerial& serial);
00031         virtual     ~SerialCom();
00032         
00033     private:
00034         
00035         static const uint32_t   STACK_SIZE = 2048 ;      // stack size of thread, given in [bytes]
00036         static const float      PERIOD;                 // the period of the timer interrupt, given in [s]
00037         static const char       DELIM;
00038         
00039         RawSerial&      serial;
00040         string          input;
00041         string          output;
00042         vector<string>  tokens;
00043         Signal          signal;
00044         Thread          thread;
00045         Ticker          ticker;
00046         bool            sendData;
00047         int             runCount;
00048 
00049         void            sendSignal();
00050         void            run();
00051         void            splitString();
00052 };
00053 
00054 #endif /* SERIAL_COM_H_ */