Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
Diff: SerialCom.h
- Revision:
- 2:798925c9e4a8
- Parent:
- 1:9c5af431a1f1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialCom.h Tue May 01 15:55:34 2018 +0000 @@ -0,0 +1,54 @@ +/* + * SerialServer.h + * Copyright (c) 2017, ZHAW + * All rights reserved. + * + * Created on: 05.06.2017 + * Author: Marcel Honegger + */ + +#ifndef SERIAL_COM_H_ +#define SERIAL_COM_H_ + +#include <cstdlib> +#include <string> +#include <vector> +#include <mbed.h> +#include "Signal.h" + +using namespace std; + + + +/** + * This class implements a communication server using a serial interface. + */ +class SerialCom { + + public: + + SerialCom(RawSerial& serial); + virtual ~SerialCom(); + + private: + + static const uint32_t STACK_SIZE = 2048 ; // stack size of thread, given in [bytes] + static const float PERIOD; // the period of the timer interrupt, given in [s] + static const char DELIM; + + RawSerial& serial; + string input; + string output; + vector<string> tokens; + Signal signal; + Thread thread; + Ticker ticker; + bool sendData; + int runCount; + + void sendSignal(); + void run(); + void splitString(); +}; + +#endif /* SERIAL_COM_H_ */