DEV: Small changes and some report

This commit is contained in:
Christos Houtouridis 2019-10-09 00:18:55 +03:00
parent 79da59f1af
commit 3ec3db11c9
9 changed files with 26 additions and 32 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
report/resources/print.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -205,7 +205,7 @@ static void client (void) {
msg_t msg; // new message buffer
while (true) {
// Idle until the time comes
sleep (settings.msgInterval + (rand()%settings.msgRand));
sleep (settings.msgInterval + (rand()%(5*settings.msgInterval)));
memset ((void*)&msg, 0, sizeof (msg)); // create a new message
cMsg_make (&msg.cMsg);
msg.sender = settings.me;

View File

@ -345,7 +345,7 @@ bool_t cMsg_equal (cMsg_t* m1, cMsg_t* m2) {
if (m1->from != m2->from) return false;
if (m1->to != m2->to) return false;
if (m1->ts != m2->ts) return false;
if (strncmp (m1->text, m2->text, sizeof(m1->text)))
if (strncmp (m1->text, m2->text, strlen(m1->text)))
return false;
return true;
}

View File

@ -34,17 +34,11 @@ static void listen_handler (devAEM_t dev, char_t* buffer, size_t size) {
mIter_t myCopy = msgList_find (&msgList, &msg); // try to find message in msgList
if (myCopy == -1) {
// We don't have a copy, accept and store it
msgList_add (&msgList, &msg);
mIter_t slot = msgList_add (&msgList, &msg);
msgList_release ();
statsUpdateIn (&msg, false); // message process
log_msg_in (&msg); // log
}
else {
// We have a copy
msgList_release ();
statsUpdateIn (&msg, true); // message process
log_debug ("Debug: Duplicate message from: %d\n", msg.sender);
}
// Processing...
devList_acquire();
dIter_t d = devList_getIter (dev);
@ -53,10 +47,17 @@ static void listen_handler (devAEM_t dev, char_t* buffer, size_t size) {
msgList_acquire ();
// Do not echo message to sender, he already has it
msgList.m[myCopy].recipients[d] = true;
msgList.m[slot].recipients[d] = true;
// don't push back message to creator, he already has it
msgList.m[myCopy].recipients[f] = true;
msgList.m[slot].recipients[f] = true;
msgList_release ();
}
else {
// We have a copy
msgList_release ();
statsUpdateIn (&msg, true); // message process
log_debug ("Debug: Duplicate message from: %d\n", msg.sender);
}
}
/*!

View File

@ -30,7 +30,7 @@ stats_t stats; //!< Statistical data
/*!
* CLI short options
*/
const char *short_opt = "v:i:p:s:w:th";
const char *short_opt = "v:i:m:p:s:w:th";
/*!
* CLI long options
@ -38,6 +38,7 @@ const char *short_opt = "v:i:p:s:w:th";
const struct option long_opt[] = {
{"outlevel", required_argument, NULL, 'v'},
{"interval", required_argument, NULL, 'i'},
{"msginterval", required_argument, NULL, 'm'},
{"pingtimeout",required_argument, NULL, 'p'},
{"sendtimeout",required_argument, NULL, 's'},
{"who", required_argument, NULL, 'w'},
@ -70,6 +71,7 @@ int parse_args (settings_t *s, int argc, char const *argv[]) {
if (s->outLevel < OUTLEVEL_0) s->outLevel = OUTLEVEL_0;
break;
case 'i': s->seekerInterval = atoi (optarg); break;
case 'm': s->msgInterval = atoi (optarg); break;
case 'p': s->pingTimeout = atoi (optarg); break;
case 's': s->sendTimeout.tv_sec = atoi (optarg); break;
case 'w': s->me = atoi (optarg); break;
@ -78,6 +80,7 @@ int parse_args (settings_t *s, int argc, char const *argv[]) {
printf ("Syntax:\nrtes_final [-t] [-v num] [-i num] [-p num] [-s num] [-w num]\n\n");
printf ("-v, --outlevel num: Change the verbosity of the program, num can be 0, 1 or 2\n");
printf ("-i, --interval sec: Set the interval of the seeker in [sec]\n");
printf ("-m, --msginterval sec: Set the interval of the client in [sec]\n");
printf ("-p, --pingtimeout sec: Set the ping timeout in [sec]\n");
printf ("-s, --sendtimeout sec: Set the connect/send timeout in [sec]\n");
printf ("-w, --who AEM: Select the AEM of the device\n");

View File

@ -19,20 +19,12 @@
/*!
* AEM list
*/
#define AEMLIST_SIZE (10)
#define AEMLIST_SIZE (6)
#define AEMLIST { \
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 AEMLIST_1
/*!
* General options
@ -219,7 +211,6 @@ typedef struct {
uint16_t port;
time_t seekerInterval;
time_t msgInterval;
time_t msgRand;
outLevel_en outLevel;
time_t pingTimeout;
timeval_t sendTimeout;
@ -233,11 +224,10 @@ extern settings_t settings;
.port = 2288, \
.seekerInterval = 30, \
.msgInterval = 60, \
.msgRand = 240, \
.outLevel = OUTLEVEL_1, \
.pingTimeout = 1, \
.sendTimeout = {4, 0}, \
.trackTime = true \
.trackTime = false \
}
//! @}