Mario Bambagini / ssWi

Dependents:   rover_car rover_pc supervisor watering_unit ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ssWiChannel.hpp Source File

ssWiChannel.hpp

Go to the documentation of this file.
00001 /** \file ssWiChannel.hpp
00002  *  \brief Abstract class for the communication channel
00003  *
00004  */
00005 
00006 #ifndef __SHARED_SLOTTED_WIRELESS_CHANNEL_HPP__
00007 #define __SHARED_SLOTTED_WIRELESS_CHANNEL_HPP__
00008 
00009 
00010 #include "ssWi.hpp"
00011 
00012 
00013 /** \brief Abstract class for a communication channel
00014  *
00015  */
00016 class ssWiChannel
00017 {
00018 
00019 protected:
00020 
00021     /** \brief Initialize the protocol
00022      *
00023      * \param c ssWi channel
00024      * \param TXRate how may times trans every second
00025      * \param RXRate how may time rx every second
00026      * \return true if the channel is ready, false otherwise
00027      */
00028     bool _init (ssWiChannel* c, int TXRate, int RXRate) {
00029         return ssWi_init(c, TXRate, RXRate);
00030     }
00031 
00032 public:
00033 
00034     /** \brief Initialize ssWi on this channel
00035      *
00036      *  \param TXRate number of transmissions per second
00037      *  \param RXRate number of receptions per second
00038      *  \return true if ssWi has been initialized succefully, false otherwise
00039      */
00040     virtual bool init (int TXRate, int RXRate) = 0;
00041 
00042     /** \brief read from the socket
00043      *
00044      *  \param msg buffer where to write the read message
00045      *  \return the number of read bytes
00046      */
00047     virtual int read (char* msg) = 0;
00048 
00049     /** \brief write to the socket
00050      *
00051      *  \param msg buffer with the message to send
00052      *  \param n number of bytes to send
00053      */
00054     virtual void write (const char* msg, int n) = 0;
00055 
00056 };
00057 
00058 #endif //__SHARED_SLOTTED_WIRELESS_CHANNEL_HPP__