Nicolas Borla / Mbed OS BBR_1Ebene
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         bool            dataRecived;
00034         float           gainG;
00035         float           gain_dG;
00036         float           offsetX;
00037         float           offsetY;
00038         
00039     private:
00040         
00041         static const uint32_t   STACK_SIZE = 2048 ;      // stack size of thread, given in [bytes]
00042         static const float      PERIOD;                 // the period of the timer interrupt, given in [s]
00043         static const char       DELIM;
00044         
00045         RawSerial&      serial;
00046         string          input;
00047         string          output;
00048         vector<string>  tokens;
00049         Signal          signal;
00050         Thread          thread;
00051         Ticker          ticker;
00052         bool            sendData;
00053         int             runCount;
00054 
00055         void            sendSignal();
00056         void            run();
00057         void            splitString();
00058 };
00059 
00060 #endif /* SERIAL_COM_H_ */
00061 
00062