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
SerialServerSend.h@1:9c5af431a1f1, 2018-05-01 (annotated)
- Committer:
- gustavatmel
- Date:
- Tue May 01 15:47:08 2018 +0000
- Revision:
- 1:9c5af431a1f1
sdf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gustavatmel | 1:9c5af431a1f1 | 1 | /* |
gustavatmel | 1:9c5af431a1f1 | 2 | * SerialServer.h |
gustavatmel | 1:9c5af431a1f1 | 3 | * Copyright (c) 2017, ZHAW |
gustavatmel | 1:9c5af431a1f1 | 4 | * All rights reserved. |
gustavatmel | 1:9c5af431a1f1 | 5 | * |
gustavatmel | 1:9c5af431a1f1 | 6 | * Created on: 05.06.2017 |
gustavatmel | 1:9c5af431a1f1 | 7 | * Author: Marcel Honegger |
gustavatmel | 1:9c5af431a1f1 | 8 | */ |
gustavatmel | 1:9c5af431a1f1 | 9 | |
gustavatmel | 1:9c5af431a1f1 | 10 | #ifndef SERIAL_SERVER_SEND_H_ |
gustavatmel | 1:9c5af431a1f1 | 11 | #define SERIAL_SERVER_SEND_H_ |
gustavatmel | 1:9c5af431a1f1 | 12 | |
gustavatmel | 1:9c5af431a1f1 | 13 | #include <cstdlib> |
gustavatmel | 1:9c5af431a1f1 | 14 | #include <string> |
gustavatmel | 1:9c5af431a1f1 | 15 | #include <mbed.h> |
gustavatmel | 1:9c5af431a1f1 | 16 | #include "Signal.h" |
gustavatmel | 1:9c5af431a1f1 | 17 | |
gustavatmel | 1:9c5af431a1f1 | 18 | using namespace std; |
gustavatmel | 1:9c5af431a1f1 | 19 | |
gustavatmel | 1:9c5af431a1f1 | 20 | |
gustavatmel | 1:9c5af431a1f1 | 21 | |
gustavatmel | 1:9c5af431a1f1 | 22 | /** |
gustavatmel | 1:9c5af431a1f1 | 23 | * This class implements a communication server using a serial interface. |
gustavatmel | 1:9c5af431a1f1 | 24 | */ |
gustavatmel | 1:9c5af431a1f1 | 25 | class SerialServerSend { |
gustavatmel | 1:9c5af431a1f1 | 26 | |
gustavatmel | 1:9c5af431a1f1 | 27 | public: |
gustavatmel | 1:9c5af431a1f1 | 28 | |
gustavatmel | 1:9c5af431a1f1 | 29 | SerialServerSend(RawSerial& serial); |
gustavatmel | 1:9c5af431a1f1 | 30 | virtual ~SerialServerSend(); |
gustavatmel | 1:9c5af431a1f1 | 31 | |
gustavatmel | 1:9c5af431a1f1 | 32 | private: |
gustavatmel | 1:9c5af431a1f1 | 33 | |
gustavatmel | 1:9c5af431a1f1 | 34 | static const uint32_t STACK_SIZE = 2048; // stack size of thread, given in [bytes] |
gustavatmel | 1:9c5af431a1f1 | 35 | static const float PERIOD; // the period of the timer interrupt, given in [s] |
gustavatmel | 1:9c5af431a1f1 | 36 | static const int32_t DATA_SIZE = 8; // size of data message, without hex encoding and termination, in [bytes] |
gustavatmel | 1:9c5af431a1f1 | 37 | static const int32_t MESSAGE_SIZE = 315+1; // size of entire message, incl. termination, given in [bytes] |
gustavatmel | 1:9c5af431a1f1 | 38 | |
gustavatmel | 1:9c5af431a1f1 | 39 | RawSerial& serial; |
gustavatmel | 1:9c5af431a1f1 | 40 | string input; |
gustavatmel | 1:9c5af431a1f1 | 41 | string output; |
gustavatmel | 1:9c5af431a1f1 | 42 | Signal signal; |
gustavatmel | 1:9c5af431a1f1 | 43 | Thread thread; |
gustavatmel | 1:9c5af431a1f1 | 44 | Ticker ticker; |
gustavatmel | 1:9c5af431a1f1 | 45 | |
gustavatmel | 1:9c5af431a1f1 | 46 | void sendSignal(); |
gustavatmel | 1:9c5af431a1f1 | 47 | void run(); |
gustavatmel | 1:9c5af431a1f1 | 48 | }; |
gustavatmel | 1:9c5af431a1f1 | 49 | |
gustavatmel | 1:9c5af431a1f1 | 50 | #endif /* SERIAL_SERVER_H_ */ |