mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
improved initialization of nodes and message
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@165 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
78f2c519b1
commit
a628d8bc5c
5 changed files with 16 additions and 26 deletions
|
@ -21,6 +21,12 @@
|
|||
#include "msg.h"
|
||||
#include "tc.h"
|
||||
|
||||
/** Static node initialization */
|
||||
#define NODE_INIT(n) { \
|
||||
.sd = -1, \
|
||||
.name = n \
|
||||
}
|
||||
|
||||
/** The datastructure for a node.
|
||||
*
|
||||
* Every entity which exchanges messages is represented by a node.
|
||||
|
|
|
@ -41,11 +41,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
int rate = atoi(argv[2]);
|
||||
struct msg msg = {
|
||||
.length = atoi(argv[1]),
|
||||
.sequence = 0,
|
||||
.data = { 0 }
|
||||
};
|
||||
struct msg m = MSG_INIT(atoi(argv[1]));
|
||||
|
||||
/* Setup signals */
|
||||
struct sigaction sa_tick = {
|
||||
|
@ -61,7 +57,7 @@ int main(int argc, char *argv[])
|
|||
struct sigevent sev = {
|
||||
.sigev_notify = SIGEV_SIGNAL,
|
||||
.sigev_signo = SIG,
|
||||
.sigev_value.sival_ptr = &msg
|
||||
.sigev_value.sival_ptr = &m
|
||||
};
|
||||
|
||||
double period = 1.0 / rate;
|
||||
|
|
|
@ -31,11 +31,6 @@ void quit(int sig, siginfo_t *si, void *ptr)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct node n = {
|
||||
.name ="node"
|
||||
};
|
||||
struct msg m;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s LOCAL\n", argv[0]);
|
||||
printf(" LOCAL is a IP:PORT combination of the local host\n\n");
|
||||
|
@ -44,6 +39,9 @@ int main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
struct node n = NODE_INIT("remote");
|
||||
struct msg m;
|
||||
|
||||
/* Setup signals */
|
||||
struct sigaction sa_quit = {
|
||||
.sa_flags = SA_SIGINFO,
|
||||
|
|
|
@ -41,14 +41,8 @@ int main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
struct node n = {
|
||||
.name = "node"
|
||||
};
|
||||
struct msg m = {
|
||||
.version = MSG_VERSION,
|
||||
.type = MSG_TYPE_DATA,
|
||||
.length = atoi(argv[1])
|
||||
};
|
||||
struct node n = NODE_INIT("remote");
|
||||
struct msg m = MSG_INIT(atoi(argv[1]));
|
||||
|
||||
/* Setup signals */
|
||||
struct sigaction sa_quit = {
|
||||
|
|
|
@ -28,10 +28,6 @@ void quit(int sig, siginfo_t *si, void *ptr)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct node n;
|
||||
|
||||
memset(&n, 0, sizeof(struct node));
|
||||
|
||||
if (argc != 4) {
|
||||
printf("Usage: %s TEST LOCAL REMOTE\n", argv[0]);
|
||||
printf(" TEST has to be 'latency' for now\n");
|
||||
|
@ -42,6 +38,8 @@ int main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
struct node n = NODE_INIT("remote");
|
||||
|
||||
/* Setup signals */
|
||||
struct sigaction sa_quit = {
|
||||
.sa_flags = SA_SIGINFO,
|
||||
|
@ -65,9 +63,7 @@ int main(int argc, char *argv[])
|
|||
debug(1, "We sent to %s:%u", inet_ntoa(n.remote.sin_addr), ntohs(n.remote.sin_port));
|
||||
|
||||
if (!strcmp(argv[1], "latency")) {
|
||||
struct msg m = {
|
||||
.sequence = 0
|
||||
};
|
||||
struct msg m = MSG_INIT(sizeof(struct timespec) / sizeof(float));
|
||||
struct timespec *ts1 = (struct timespec *) &m.data;
|
||||
struct timespec *ts2 = malloc(sizeof(struct timespec));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue