Final version
This commit is contained in:
parent
3ec3db11c9
commit
a452f2e27c
56
Makefile
56
Makefile
@ -6,21 +6,45 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# select one of the following or edit for your environment
|
# Edit the paths to match your environment
|
||||||
|
# Currently supported:
|
||||||
|
# Windows (we prefer Cygwin)
|
||||||
|
# GNU/Linux
|
||||||
#
|
#
|
||||||
|
LINUX_CXX := /usr/local/bin/cross-pi0/bin/arm-linux-gnueabihf-gcc
|
||||||
|
WIN_CXX := D:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
|
||||||
|
|
||||||
#CXX := /usr/local/arm/bin/arm-unknown-linux-gnueabi-gcc
|
# RTES related stuff for upload
|
||||||
CXX := D:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
|
SCP := scp
|
||||||
|
PIUSER := root
|
||||||
|
PI := 192.168.0.1
|
||||||
|
RTES_PATH := /usr/local/bin/
|
||||||
|
|
||||||
CXXFLAGS := -std=c11 -Wall -Wextra -Werror
|
# === Compilation related stuff ===
|
||||||
CXXFEXTR := -c -fmessage-length=0
|
CXXFLAGS := -std=c11 -Wall -Wextra -Werror
|
||||||
LDFLAGS := -lm -lpthread
|
CXXFEXTR := -c -fmessage-length=0
|
||||||
BUILD := ./bin
|
LDFLAGS := -lm -lpthread
|
||||||
OBJ_DIR := $(BUILD)/obj
|
BUILD := ./bin
|
||||||
APP_DIR := $(BUILD)
|
OBJ_DIR := $(BUILD)/obj
|
||||||
TARGET := rtes_final
|
APP_DIR := $(BUILD)
|
||||||
SRC := $(wildcard src/*.c)
|
TARGET := rtes_final
|
||||||
|
SRC := $(wildcard src/*.c)
|
||||||
|
|
||||||
|
# === OS selection ===
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
# Windows, select exe path
|
||||||
|
CXX := $(WIN_CXX)
|
||||||
|
else
|
||||||
|
# Linux filter [currently only GNU/Linux]
|
||||||
|
UNAME := $(shell uname)
|
||||||
|
ifeq ($(UNAME),Linux)
|
||||||
|
CXX := $(LINUX_CXX)
|
||||||
|
else
|
||||||
|
ERR := $(error Not supporting OS)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# === MakeFile body ===
|
||||||
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: %.c
|
$(OBJ_DIR)/%.o: %.c
|
||||||
@ -34,6 +58,10 @@ $(APP_DIR)/$(TARGET): $(OBJECTS)
|
|||||||
# === Rules ===
|
# === Rules ===
|
||||||
rtes_final: build $(APP_DIR)/$(TARGET)
|
rtes_final: build $(APP_DIR)/$(TARGET)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-@rm -rvf $(OBJ_DIR)/*
|
||||||
|
-@rm -rvf $(APP_DIR)/*
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@mkdir -p $(APP_DIR)
|
@mkdir -p $(APP_DIR)
|
||||||
@mkdir -p $(OBJ_DIR)
|
@mkdir -p $(OBJ_DIR)
|
||||||
@ -45,11 +73,7 @@ release: CXXFLAGS += -O2
|
|||||||
release: rtes_final
|
release: rtes_final
|
||||||
|
|
||||||
upload:
|
upload:
|
||||||
scp $(BUILD)/$(TARGET) root@192.168.0.1:/root/
|
$(SCP) $(BUILD)/$(TARGET) $(PIUSER)@$(PI):$(RTES_PATH)
|
||||||
|
|
||||||
clean:
|
|
||||||
-@rm -rvf $(OBJ_DIR)/*
|
|
||||||
-@rm -rvf $(APP_DIR)/*
|
|
||||||
|
|
||||||
all: clean release upload
|
all: clean release upload
|
||||||
|
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
|
|
||||||
Statistics
|
Statistics
|
||||||
total messages: 483
|
============
|
||||||
duplicate messages: 277
|
total messages: 483
|
||||||
messages for me: 122
|
duplicate messages: 277
|
||||||
messages by me: 43
|
messages for me: 122
|
||||||
In messages direct for me: 33
|
messages by me: 43
|
||||||
Out direct messages: 35
|
In messages direct for me: 33
|
||||||
Average message size: 28.6562
|
Out direct messages: 35
|
||||||
Average time to me: 67.4166
|
Average message size: 28.6562
|
||||||
Device 7700 found on 0, last: 0
|
Average time to me: 67.4166
|
||||||
Device 8261 found on 1570210285, last: 1570211945
|
|
||||||
Device 8765 found on 0, last: 0
|
Device timestamps
|
||||||
Device 8844 found on 1570209288, last: 1570217684
|
===================
|
||||||
Device 8880 found on 1570209288, last: 1570216562
|
Device 7700 found on 0, last: 0
|
||||||
Device 8861 found on 1570209288, last: 1570216904
|
Device 8261 found on 1570210285, last: 1570211945
|
||||||
Device 8877 found on 0, last: 0
|
Device 8765 found on 0, last: 0
|
||||||
Device 8941 found on 1570209289, last: 1570217461
|
Device 8844 found on 1570209288, last: 1570217684
|
||||||
Device 8934 found on 0, last: 0
|
Device 8880 found on 1570209288, last: 1570216562
|
||||||
Device 8997 found on 0, last: 0
|
Device 8861 found on 1570209288, last: 1570216904
|
||||||
|
Device 8877 found on 0, last: 0
|
||||||
|
Device 8941 found on 1570209289, last: 1570217461
|
||||||
|
Device 8934 found on 0, last: 0
|
||||||
|
Device 8997 found on 0, last: 0
|
||||||
|
Binary file not shown.
BIN
report/resources/rtes_listener.png
Executable file
BIN
report/resources/rtes_listener.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
BIN
report/resources/stats.ods
Executable file
BIN
report/resources/stats.ods
Executable file
Binary file not shown.
BIN
report_rtes_Choutouridis_8997.pdf
Executable file
BIN
report_rtes_Choutouridis_8997.pdf
Executable file
Binary file not shown.
@ -205,7 +205,10 @@ static void client (void) {
|
|||||||
msg_t msg; // new message buffer
|
msg_t msg; // new message buffer
|
||||||
while (true) {
|
while (true) {
|
||||||
// Idle until the time comes
|
// Idle until the time comes
|
||||||
sleep (settings.msgInterval + (rand()%(5*settings.msgInterval)));
|
sleep (
|
||||||
|
settings.msgIntervalMin +
|
||||||
|
(rand() % (settings.msgIntervalMax - settings.msgIntervalMin))
|
||||||
|
);
|
||||||
memset ((void*)&msg, 0, sizeof (msg)); // create a new message
|
memset ((void*)&msg, 0, sizeof (msg)); // create a new message
|
||||||
cMsg_make (&msg.cMsg);
|
cMsg_make (&msg.cMsg);
|
||||||
msg.sender = settings.me;
|
msg.sender = settings.me;
|
||||||
|
44
src/main.c
44
src/main.c
@ -30,21 +30,22 @@ stats_t stats; //!< Statistical data
|
|||||||
/*!
|
/*!
|
||||||
* CLI short options
|
* CLI short options
|
||||||
*/
|
*/
|
||||||
const char *short_opt = "v:i:m:p:s:w:th";
|
const char *short_opt = "v:i:m:M:p:s:w:th";
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* CLI long options
|
* CLI long options
|
||||||
*/
|
*/
|
||||||
const struct option long_opt[] = {
|
const struct option long_opt[] = {
|
||||||
{"outlevel", required_argument, NULL, 'v'},
|
{"outlevel", required_argument, NULL, 'v'},
|
||||||
{"interval", required_argument, NULL, 'i'},
|
{"interval", required_argument, NULL, 'i'},
|
||||||
{"msginterval", required_argument, NULL, 'm'},
|
{"msgintervalmin", required_argument, NULL, 'm'},
|
||||||
{"pingtimeout",required_argument, NULL, 'p'},
|
{"msgintervalmax", required_argument, NULL, 'M'},
|
||||||
{"sendtimeout",required_argument, NULL, 's'},
|
{"pingtimeout", required_argument, NULL, 'p'},
|
||||||
{"who", required_argument, NULL, 'w'},
|
{"sendtimeout", required_argument, NULL, 's'},
|
||||||
{"tracktime", no_argument, NULL, 't'},
|
{"who", required_argument, NULL, 'w'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"tracktime", no_argument, NULL, 't'},
|
||||||
{NULL, 0, NULL, 0}
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -71,21 +72,24 @@ int parse_args (settings_t *s, int argc, char const *argv[]) {
|
|||||||
if (s->outLevel < OUTLEVEL_0) s->outLevel = OUTLEVEL_0;
|
if (s->outLevel < OUTLEVEL_0) s->outLevel = OUTLEVEL_0;
|
||||||
break;
|
break;
|
||||||
case 'i': s->seekerInterval = atoi (optarg); break;
|
case 'i': s->seekerInterval = atoi (optarg); break;
|
||||||
case 'm': s->msgInterval = atoi (optarg); break;
|
case 'm': s->msgIntervalMin = atoi (optarg); break;
|
||||||
|
case 'M': s->msgIntervalMax = atoi (optarg); break;
|
||||||
case 'p': s->pingTimeout = atoi (optarg); break;
|
case 'p': s->pingTimeout = atoi (optarg); break;
|
||||||
case 's': s->sendTimeout.tv_sec = atoi (optarg); break;
|
case 's': s->sendTimeout.tv_sec = atoi (optarg); break;
|
||||||
case 'w': s->me = atoi (optarg); break;
|
case 'w': s->me = atoi (optarg); break;
|
||||||
case 't': s->trackTime = true; break;
|
case 't': s->trackTime = true; break;
|
||||||
case 'h':
|
case 'h':
|
||||||
printf ("Syntax:\nrtes_final [-t] [-v num] [-i num] [-p num] [-s num] [-w num]\n\n");
|
printf ("Syntax:\n");
|
||||||
printf ("-v, --outlevel num: Change the verbosity of the program, num can be 0, 1 or 2\n");
|
printf ("rtes_final [-t] [-h] [-v num] [-i num] [-m num] [-M num] [-p num] [-s num] [-w num]\n\n");
|
||||||
printf ("-i, --interval sec: Set the interval of the seeker in [sec]\n");
|
printf ("-v, --outlevel num: Change the verbosity of the program, num can be 0, 1 or 2\n");
|
||||||
printf ("-m, --msginterval sec: Set the interval of the client in [sec]\n");
|
printf ("-i, --interval sec: Set the interval of the seeker in [sec]\n");
|
||||||
printf ("-p, --pingtimeout sec: Set the ping timeout in [sec]\n");
|
printf ("-m, --msgintervalmin sec: Set the interval of the client in [sec]\n");
|
||||||
printf ("-s, --sendtimeout sec: Set the connect/send timeout in [sec]\n");
|
printf ("-M, --msgintervalmax sec: Set the interval of the client in [sec]\n");
|
||||||
printf ("-w, --who AEM: Select the AEM of the device\n");
|
printf ("-p, --pingtimeout sec: Set the ping timeout in [sec]\n");
|
||||||
printf ("-t, --tracktime: Enables time tracking in statistics\n");
|
printf ("-s, --sendtimeout sec: Set the connect/send timeout in [sec]\n");
|
||||||
printf ("-h, --help: Print this and exit\n");
|
printf ("-w, --who AEM: Select the AEM of the device\n");
|
||||||
|
printf ("-t, --tracktime: Enables time tracking in statistics\n");
|
||||||
|
printf ("-h, --help: Print this and exit\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
case ':':
|
case ':':
|
||||||
default:
|
default:
|
||||||
|
@ -17,14 +17,13 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* AEM list
|
* Hard-coded AEM list
|
||||||
*/
|
*/
|
||||||
#define AEMLIST_SIZE (6)
|
|
||||||
|
|
||||||
#define AEMLIST_0 { 7700, 8261, 8765, 8844, 8880, 8861, 8877, 8941, 8934, 8997 }
|
#define AEMLIST_0 { 7700, 8261, 8765, 8844, 8880, 8861, 8877, 8941, 8934, 8997 }
|
||||||
#define AEMLIST_1 { 8918, 8929, 8997, 8880, 8844, 8861 }
|
#define AEMLIST_1 { 8918, 8929, 8997, 8880, 8844, 8861 }
|
||||||
|
|
||||||
#define AEMLIST AEMLIST_1
|
#define AEMLIST AEMLIST_0
|
||||||
|
#define AEMLIST_SIZE (10)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* General options
|
* General options
|
||||||
@ -32,7 +31,7 @@
|
|||||||
//! @{
|
//! @{
|
||||||
#define MSG_TEXT_SIZE 256 //!< Maximum size of each message
|
#define MSG_TEXT_SIZE 256 //!< Maximum size of each message
|
||||||
#define MSG_LIST_SIZE 2000 //!< Maximum size of message history buffer
|
#define MSG_LIST_SIZE 2000 //!< Maximum size of message history buffer
|
||||||
#define DEVICE_LIST_SIZE 100 //!< Maximum size of the device list
|
#define DEVICE_LIST_SIZE 200 //!< Maximum number of the device in listener's queue
|
||||||
|
|
||||||
#define MSG_DELIMITER '_' //!< Message delimiter
|
#define MSG_DELIMITER '_' //!< Message delimiter
|
||||||
#define ADHOC_NET_A 10 //!< [A.B.C.D]
|
#define ADHOC_NET_A 10 //!< [A.B.C.D]
|
||||||
@ -71,7 +70,7 @@ typedef aem_t devAEM_t; //!< device as AEM type
|
|||||||
* device as IP type
|
* device as IP type
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t A, B, C, D;
|
uint16_t A, B, C, D; //!< IP octets
|
||||||
}devIP_t;
|
}devIP_t;
|
||||||
|
|
||||||
typedef double fpdata_t; //!< Select floating point data type for the application
|
typedef double fpdata_t; //!< Select floating point data type for the application
|
||||||
@ -79,15 +78,16 @@ typedef double fpdata_t; //!< Select floating point data type for the
|
|||||||
// Syntactic sugar types
|
// Syntactic sugar types
|
||||||
typedef struct sockaddr_in sockaddr_in_t; //!< internet socket address type definition
|
typedef struct sockaddr_in sockaddr_in_t; //!< internet socket address type definition
|
||||||
typedef struct sockaddr sockaddr_t; //!< general socket address type definition
|
typedef struct sockaddr sockaddr_t; //!< general socket address type definition
|
||||||
typedef struct timeval timeval_t;
|
typedef struct timeval timeval_t; //!< general timeval type definition
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* AEM list for our mesh network
|
* AEM list for our mesh network
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
devAEM_t dev;
|
devAEM_t dev; //!< The device
|
||||||
bool_t onRange;
|
bool_t onRange; //!< Flag to indicate if the device is on range
|
||||||
tstamp_t begin;
|
tstamp_t begin; //!< First time we had answer from the device on ping
|
||||||
tstamp_t end;
|
tstamp_t end; //!< Last time we had answer from the device on ping
|
||||||
} devList_t;
|
} devList_t;
|
||||||
|
|
||||||
extern devList_t devList[];
|
extern devList_t devList[];
|
||||||
@ -199,6 +199,9 @@ typedef struct {
|
|||||||
|
|
||||||
extern stats_t stats;
|
extern stats_t stats;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Verbose level enumerator for settings
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OUTLEVEL_0, //!< Output only results [default]
|
OUTLEVEL_0, //!< Output only results [default]
|
||||||
OUTLEVEL_1, //!< Output results and every message also
|
OUTLEVEL_1, //!< Output results and every message also
|
||||||
@ -206,24 +209,32 @@ typedef enum {
|
|||||||
}outLevel_en;
|
}outLevel_en;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Application settings
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
devAEM_t me;
|
devAEM_t me; //!< Who Am I
|
||||||
uint16_t port;
|
uint16_t port; //!< Application port
|
||||||
time_t seekerInterval;
|
time_t seekerInterval; //!< sleep time for seeker
|
||||||
time_t msgInterval;
|
time_t msgIntervalMin; //!< minimum sleep time for client
|
||||||
outLevel_en outLevel;
|
time_t msgIntervalMax; //!< maximum sleep time for client
|
||||||
time_t pingTimeout;
|
outLevel_en outLevel; //!< Verbose level
|
||||||
timeval_t sendTimeout;
|
time_t pingTimeout; //!< Ping timeout
|
||||||
bool_t trackTime;
|
timeval_t sendTimeout; //!< Send and select timeout
|
||||||
|
bool_t trackTime; //!< Track message timing flag
|
||||||
}settings_t;
|
}settings_t;
|
||||||
|
|
||||||
extern settings_t settings;
|
extern settings_t settings;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Helper macro to setup default settings to application
|
||||||
|
*/
|
||||||
#define settings_init(s) s = { \
|
#define settings_init(s) s = { \
|
||||||
.me = 8997, \
|
.me = 8997, \
|
||||||
.port = 2288, \
|
.port = 2288, \
|
||||||
.seekerInterval = 30, \
|
.seekerInterval = 30, \
|
||||||
.msgInterval = 60, \
|
.msgIntervalMin = 60, \
|
||||||
|
.msgIntervalMax = 300, \
|
||||||
.outLevel = OUTLEVEL_1, \
|
.outLevel = OUTLEVEL_1, \
|
||||||
.pingTimeout = 1, \
|
.pingTimeout = 1, \
|
||||||
.sendTimeout = {4, 0}, \
|
.sendTimeout = {4, 0}, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user