Nicolas Borla
/
BBR_1Ebene
BBR 1 Ebene
SerialCom.h@0:fbdae7e6d805, 2018-05-14 (annotated)
- Committer:
- borlanic
- Date:
- Mon May 14 11:29:06 2018 +0000
- Revision:
- 0:fbdae7e6d805
BBR
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:fbdae7e6d805 | 1 | /* |
borlanic | 0:fbdae7e6d805 | 2 | * SerialServer.h |
borlanic | 0:fbdae7e6d805 | 3 | * Copyright (c) 2017, ZHAW |
borlanic | 0:fbdae7e6d805 | 4 | * All rights reserved. |
borlanic | 0:fbdae7e6d805 | 5 | * |
borlanic | 0:fbdae7e6d805 | 6 | * Created on: 05.06.2017 |
borlanic | 0:fbdae7e6d805 | 7 | * Author: Marcel Honegger |
borlanic | 0:fbdae7e6d805 | 8 | */ |
borlanic | 0:fbdae7e6d805 | 9 | |
borlanic | 0:fbdae7e6d805 | 10 | #ifndef SERIAL_COM_H_ |
borlanic | 0:fbdae7e6d805 | 11 | #define SERIAL_COM_H_ |
borlanic | 0:fbdae7e6d805 | 12 | |
borlanic | 0:fbdae7e6d805 | 13 | #include <cstdlib> |
borlanic | 0:fbdae7e6d805 | 14 | #include <string> |
borlanic | 0:fbdae7e6d805 | 15 | #include <vector> |
borlanic | 0:fbdae7e6d805 | 16 | #include <mbed.h> |
borlanic | 0:fbdae7e6d805 | 17 | #include "Signal.h" |
borlanic | 0:fbdae7e6d805 | 18 | |
borlanic | 0:fbdae7e6d805 | 19 | using namespace std; |
borlanic | 0:fbdae7e6d805 | 20 | |
borlanic | 0:fbdae7e6d805 | 21 | |
borlanic | 0:fbdae7e6d805 | 22 | |
borlanic | 0:fbdae7e6d805 | 23 | /** |
borlanic | 0:fbdae7e6d805 | 24 | * This class implements a communication server using a serial interface. |
borlanic | 0:fbdae7e6d805 | 25 | */ |
borlanic | 0:fbdae7e6d805 | 26 | class SerialCom { |
borlanic | 0:fbdae7e6d805 | 27 | |
borlanic | 0:fbdae7e6d805 | 28 | public: |
borlanic | 0:fbdae7e6d805 | 29 | |
borlanic | 0:fbdae7e6d805 | 30 | SerialCom(RawSerial& serial); |
borlanic | 0:fbdae7e6d805 | 31 | virtual ~SerialCom(); |
borlanic | 0:fbdae7e6d805 | 32 | |
borlanic | 0:fbdae7e6d805 | 33 | bool dataRecived; |
borlanic | 0:fbdae7e6d805 | 34 | float gainG; |
borlanic | 0:fbdae7e6d805 | 35 | float gain_dG; |
borlanic | 0:fbdae7e6d805 | 36 | float offsetX; |
borlanic | 0:fbdae7e6d805 | 37 | float offsetY; |
borlanic | 0:fbdae7e6d805 | 38 | |
borlanic | 0:fbdae7e6d805 | 39 | private: |
borlanic | 0:fbdae7e6d805 | 40 | |
borlanic | 0:fbdae7e6d805 | 41 | static const uint32_t STACK_SIZE = 2048 ; // stack size of thread, given in [bytes] |
borlanic | 0:fbdae7e6d805 | 42 | static const float PERIOD; // the period of the timer interrupt, given in [s] |
borlanic | 0:fbdae7e6d805 | 43 | static const char DELIM; |
borlanic | 0:fbdae7e6d805 | 44 | |
borlanic | 0:fbdae7e6d805 | 45 | RawSerial& serial; |
borlanic | 0:fbdae7e6d805 | 46 | string input; |
borlanic | 0:fbdae7e6d805 | 47 | string output; |
borlanic | 0:fbdae7e6d805 | 48 | vector<string> tokens; |
borlanic | 0:fbdae7e6d805 | 49 | Signal signal; |
borlanic | 0:fbdae7e6d805 | 50 | Thread thread; |
borlanic | 0:fbdae7e6d805 | 51 | Ticker ticker; |
borlanic | 0:fbdae7e6d805 | 52 | bool sendData; |
borlanic | 0:fbdae7e6d805 | 53 | int runCount; |
borlanic | 0:fbdae7e6d805 | 54 | |
borlanic | 0:fbdae7e6d805 | 55 | void sendSignal(); |
borlanic | 0:fbdae7e6d805 | 56 | void run(); |
borlanic | 0:fbdae7e6d805 | 57 | void splitString(); |
borlanic | 0:fbdae7e6d805 | 58 | }; |
borlanic | 0:fbdae7e6d805 | 59 | |
borlanic | 0:fbdae7e6d805 | 60 | #endif /* SERIAL_COM_H_ */ |
borlanic | 0:fbdae7e6d805 | 61 | |
borlanic | 0:fbdae7e6d805 | 62 |