a

Dependencies:   mbed mbed-rtos

Committer:
alexpirciu
Date:
Thu Mar 28 07:44:42 2019 +0000
Revision:
1:ceee5a608e7c
assa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alexpirciu 1:ceee5a608e7c 1 /**
alexpirciu 1:ceee5a608e7c 2 ******************************************************************************
alexpirciu 1:ceee5a608e7c 3 * @file SerialMonitor.hpp
alexpirciu 1:ceee5a608e7c 4 * @author RBRO/PJ-IU
alexpirciu 1:ceee5a608e7c 5 * @version V1.0.0
alexpirciu 1:ceee5a608e7c 6 * @date day-month-2017
alexpirciu 1:ceee5a608e7c 7 * @brief This file contains the class declaration for the serial communication
alexpirciu 1:ceee5a608e7c 8 * functionality.
alexpirciu 1:ceee5a608e7c 9 ******************************************************************************
alexpirciu 1:ceee5a608e7c 10 */
alexpirciu 1:ceee5a608e7c 11
alexpirciu 1:ceee5a608e7c 12 /* Inclusion guard */
alexpirciu 1:ceee5a608e7c 13 #ifndef SERIAL_MONITOR_HPP
alexpirciu 1:ceee5a608e7c 14 #define SERIAL_MONITOR_HPP
alexpirciu 1:ceee5a608e7c 15
alexpirciu 1:ceee5a608e7c 16 /* The mbed library */
alexpirciu 1:ceee5a608e7c 17 #include <mbed.h>
alexpirciu 1:ceee5a608e7c 18 #include <map>
alexpirciu 1:ceee5a608e7c 19 #include <array>
alexpirciu 1:ceee5a608e7c 20 /* Function objects */
alexpirciu 1:ceee5a608e7c 21 #include <functional>
alexpirciu 1:ceee5a608e7c 22 #include<TaskManager/taskmanager.hpp>
alexpirciu 1:ceee5a608e7c 23 #include <Queue/queue.hpp>
alexpirciu 1:ceee5a608e7c 24
alexpirciu 1:ceee5a608e7c 25
alexpirciu 1:ceee5a608e7c 26 namespace serial{
alexpirciu 1:ceee5a608e7c 27
alexpirciu 1:ceee5a608e7c 28 /**
alexpirciu 1:ceee5a608e7c 29 * @brief It is used for implementing serial communciation.
alexpirciu 1:ceee5a608e7c 30 *
alexpirciu 1:ceee5a608e7c 31 */
alexpirciu 1:ceee5a608e7c 32 class CSerialMonitor : public task::CTask
alexpirciu 1:ceee5a608e7c 33 {
alexpirciu 1:ceee5a608e7c 34 public:
alexpirciu 1:ceee5a608e7c 35 typedef mbed::Callback<void(char const *, char *)> FCallback;
alexpirciu 1:ceee5a608e7c 36 typedef std::map<string,FCallback> CSerialSubscriberMap;
alexpirciu 1:ceee5a608e7c 37
alexpirciu 1:ceee5a608e7c 38 /* Constructor */
alexpirciu 1:ceee5a608e7c 39 CSerialMonitor(Serial& f_serialPort
alexpirciu 1:ceee5a608e7c 40 ,CSerialSubscriberMap f_serialSubscriberMap);
alexpirciu 1:ceee5a608e7c 41 private:
alexpirciu 1:ceee5a608e7c 42 /* Rx callback */
alexpirciu 1:ceee5a608e7c 43 static void RxCallback(void *thisPointer);
alexpirciu 1:ceee5a608e7c 44 /* Tx callback */
alexpirciu 1:ceee5a608e7c 45 static void TxCallback(void *thisPointer);
alexpirciu 1:ceee5a608e7c 46 /* Rx callback actions */
alexpirciu 1:ceee5a608e7c 47 void serialRxCallback();
alexpirciu 1:ceee5a608e7c 48 /* Tx callback actions */
alexpirciu 1:ceee5a608e7c 49 void serialTxCallback();
alexpirciu 1:ceee5a608e7c 50 /* Run method */
alexpirciu 1:ceee5a608e7c 51 virtual void _run();
alexpirciu 1:ceee5a608e7c 52
alexpirciu 1:ceee5a608e7c 53 /* Reference to serial object */
alexpirciu 1:ceee5a608e7c 54 Serial& m_serialPort;
alexpirciu 1:ceee5a608e7c 55 /* Rx buffer */
alexpirciu 1:ceee5a608e7c 56 CQueue<char,255> m_RxBuffer;
alexpirciu 1:ceee5a608e7c 57 /* Tx buffer */
alexpirciu 1:ceee5a608e7c 58 CQueue<char,255> m_TxBuffer;
alexpirciu 1:ceee5a608e7c 59 /* Data buffer */
alexpirciu 1:ceee5a608e7c 60 array<char,256> m_parseBuffer;
alexpirciu 1:ceee5a608e7c 61 /* Parse iterator */
alexpirciu 1:ceee5a608e7c 62 array<char,256>::iterator m_parseIt;
alexpirciu 1:ceee5a608e7c 63 /* Serial subscriber */
alexpirciu 1:ceee5a608e7c 64 CSerialSubscriberMap m_serialSubscriberMap;
alexpirciu 1:ceee5a608e7c 65 };
alexpirciu 1:ceee5a608e7c 66
alexpirciu 1:ceee5a608e7c 67 }; // namespace serial
alexpirciu 1:ceee5a608e7c 68
alexpirciu 1:ceee5a608e7c 69 #endif // SERIAL_MONITOR_HPP
alexpirciu 1:ceee5a608e7c 70