DESERT 4.0.0
uwmdriver.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
39#ifndef UWMDRIVER_H
40#define UWMDRIVER_H
41
42#include "uwmconnector.h"
43#include "uwminterpreter.h"
44
45#include <cmath>
46#include <cstring>
47#include <fcntl.h>
48#include <fstream>
49#include <iostream>
50#include <sstream>
51#include <stdio.h>
52#include <stdlib.h>
53#include <string.h>
54#include <sys/stat.h>
55#include <sys/types.h>
56#include <unistd.h>
57
58#define MAX_LOG_LEVEL 2
59
74
76
78
80
81// Forward declaration(s)
82class UWMPhy_modem;
83class UWMcodec;
84
94{
95public:
103
107 ~UWMdriver();
108
109 virtual void modemSetID() = 0;
110
116 virtual void start() = 0;
117
123 virtual void stop() = 0;
124
132 virtual void modemTx() = 0;
144
152 inline void
153 setID(int ID_)
154 {
155 ID = ID_;
156 }
157
168 void resetModemStatus();
169
182 void updateTx(int, std::string);
183
200 void updateRx(int, int, std::string);
201
208 int
210 {
211 return ID;
212 }
213
221 {
222 return status;
223 }
224
235 std::string
237 {
238 return payload_rx;
239 }
240
251 int
253 {
254 return src;
255 }
256
267 int
269 {
270 return dstPktRx;
271 }
272
278 inline log_level_t
280 {
281 return (log_level_t) debug_;
282 }
283
288 inline void
289 setModemID(bool set)
290 {
291 SetModemID = set;
292 }
297 inline bool
299 {
300 return SetModemID;
301 }
302
303 inline void
304 setResetModemQueue(bool reset_m_queue)
305 {
306 ResetModemQueue = reset_m_queue;
307 }
308
309 inline bool
311 {
312 return ResetModemQueue;
313 }
321
328 std::string getLogFile();
329
331 log_level_t log_level, std::string module, std::string message);
332
333protected:
344 int ID;
356 // TX VARIABLES (variables for the next packet to be transmitted)
357 std::string payload_tx;
361 int dest;
367 // RX VARIABLES (variables reffering to the last received packet)
368 std::string payload_rx;
377 int src;
393 int debug_;
395 std::ofstream outLog;
410
417 virtual void modemTxManager() = 0;
418};
419#endif /* UWMDRIVER_H */
@ LOG_LEVEL_DEBUG
Definition uwmdriver.h:75
@ LOG_LEVEL_ERROR
Definition uwmdriver.h:75
@ LOG_LEVEL_INFO
Definition uwmdriver.h:75
enum MODEM_STATES modem_state_t
Definition uwmdriver.h:79
enum LOG_LEVEL log_level_t
Definition uwmdriver.h:77
@ MODEM_RESET
Definition uwmdriver.h:68
@ MODEM_CHANGE_POWER_LEVEL
Definition uwmdriver.h:71
@ MODEM_QUIT
Definition uwmdriver.h:72
@ MODEM_IDLE
Definition uwmdriver.h:61
@ MODEM_RX
Definition uwmdriver.h:63
@ MODEM_MULTIPATH
Definition uwmdriver.h:70
@ MODEM_IDLE_RX
Definition uwmdriver.h:64
@ MODEM_CFG
Definition uwmdriver.h:65
@ MODEM_TX_PAUSED
Definition uwmdriver.h:66
@ MODEM_NOISE
Definition uwmdriver.h:69
@ MODEM_TX
Definition uwmdriver.h:62
@ MODEM_TX_RX
Definition uwmdriver.h:67
LOG_LEVEL
Definition uwmdriver.h:75
enum MODEM_STATES modem_state_t
Definition uwmdriver.h:79
enum LOG_LEVEL log_level_t
Definition uwmdriver.h:77
MODEM_STATES
Definition uwmdriver.h:60
Definition uwmphy_modem.h:85
Definition uwmconnector.h:79
Definition uwmdriver.h:94
void updateRx(int, int, std::string)
Definition uwmdriver.cpp:100
void updateTx(int, std::string)
Definition uwmdriver.cpp:93
log_level_t getLogLevel()
Definition uwmdriver.cpp:81
std::string payload_tx
Definition uwmdriver.h:357
UWMconnector * pmConnector
Definition uwmdriver.h:340
bool getModemID()
Definition uwmdriver.h:298
int getSrc()
Definition uwmdriver.h:252
modem_state_t getStatus()
Definition uwmdriver.h:220
int getDstPktRx()
Definition uwmdriver.h:268
virtual void stop()=0
virtual void modemTxManager()=0
std::string getLogFile()
Definition uwmdriver.cpp:75
bool getResetModemQueue()
Definition uwmdriver.h:310
int dest
Definition uwmdriver.h:361
virtual void modemSetID()=0
int debug_
Definition uwmdriver.h:393
bool SetModemID
Definition uwmdriver.h:391
void printOnLog(log_level_t log_level, std::string module, std::string message)
virtual void modemTx()=0
int src
Definition uwmdriver.h:377
virtual void start()=0
void setResetModemQueue(bool reset_m_queue)
Definition uwmdriver.h:304
int ID
Definition uwmdriver.h:344
UWMinterpreter * pmInterpreter
Definition uwmdriver.h:337
void setModemID(bool set)
Definition uwmdriver.h:289
void setConnections(UWMinterpreter *, UWMconnector *)
Definition uwmdriver.cpp:65
int dstPktRx
Definition uwmdriver.h:385
virtual modem_state_t updateStatus()=0
bool ResetModemQueue
Definition uwmdriver.h:397
void resetModemStatus()
Definition uwmdriver.cpp:87
UWMPhy_modem * pmModem
Definition uwmdriver.h:334
int getID()
Definition uwmdriver.h:209
std::string getRxPayload()
Definition uwmdriver.h:236
log_level_t getDebug()
Definition uwmdriver.h:279
std::ofstream outLog
Definition uwmdriver.h:395
modem_state_t status
Definition uwmdriver.h:350
std::string payload_rx
Definition uwmdriver.h:368
void setID(int ID_)
Definition uwmdriver.h:153
~UWMdriver()
Definition uwmdriver.cpp:60
Definition uwminterpreter.h:57
log_level
Definition uw-csma-ca.h:86