BA / SerialCom

Fork of OmniWheels by Gustav Atmel

SerialServerSend.h

Committer:
gustavatmel
Date:
2018-05-01
Revision:
1:9c5af431a1f1

File content as of revision 1:9c5af431a1f1:

/*
 * SerialServer.h
 * Copyright (c) 2017, ZHAW
 * All rights reserved.
 *
 *  Created on: 05.06.2017
 *      Author: Marcel Honegger
 */

#ifndef SERIAL_SERVER_SEND_H_
#define SERIAL_SERVER_SEND_H_

#include <cstdlib>
#include <string>
#include <mbed.h>
#include "Signal.h"

using namespace std;



/**
 * This class implements a communication server using a serial interface.
 */
class SerialServerSend {
    
    public:
        
                    SerialServerSend(RawSerial& serial);
        virtual     ~SerialServerSend();
       
    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 int32_t    DATA_SIZE = 8;          // size of data message, without hex encoding and termination, in [bytes]
        static const int32_t    MESSAGE_SIZE = 315+1;    // size of entire message, incl. termination, given in [bytes]
        
        RawSerial&      serial;
        string          input;
        string          output;
        Signal          signal;
        Thread          thread;
        Ticker          ticker;

        void        sendSignal();
        void        run();
};

#endif /* SERIAL_SERVER_H_ */