From 7dec04edfcac6f6547017d0a55b99d41120e0e6b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 30 Oct 2016 17:10:20 -0400 Subject: [PATCH] added new setting to example config, updated documentation --- doc/nodes/Socket.md | 30 +++++++++++++++++++++++++++++- etc/example.conf | 3 +++ lib/nodes/socket.c | 12 ++++++++++-- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/doc/nodes/Socket.md b/doc/nodes/Socket.md index 486453be8..5f6c43bf9 100644 --- a/doc/nodes/Socket.md +++ b/doc/nodes/Socket.md @@ -38,6 +38,24 @@ See below for a more detailed description of this feature. #### `layer` *("udp" | "ip" | "eth")* +Select the network layer which should be used for the socket. Please note that `eth` can only be used locally in a LAN as it contains no routing information for the internet. + +#### `header` *("default" | "none" | "fake")* + +The socket node-type supports multiple protocols: + +- The `default` VILLASnode header includes a couple of fields like the origin timestamp, number of values and the endianess of the transported data. The packet format is described in the following section called "Packet Format". +- It is also possible to just send raw data by omitting the header completely (`none`). Each value is expected to take 4 bytes. It can be either a single precission floating point number (`float`) or a 32 bit unsigned integer (`uint32_t`). This protocol is used by RTDS' GTNET-SKT card. +- The `fake` setting is very similar to the `none` setting. Only the first three values will have a special interpretation: + - Sequence no. (`uint32_t`) + - Timestamp seconds (Unix epoch, `uint32_t`) + - Timestamp nano-seconds (Unix epoch, `uint32_t`) + +#### `endian` *("big" | "network" | "little")* + +This setting is only valid for the `none` and `fake` protocols. +It select the endianes which is used for outgoing and incoming data. + ### Example nodes = { @@ -52,7 +70,17 @@ See below for a more detailed description of this feature. # ip Send / recv IP packets # eth Send / recv raw Ethernet frames (IEEE802.3) - + header = "gtnet-skt:fake", # Header can be one of: + # default | villas Use VILLASnode protocol (see struct msg) (default) + # none | gtnet-skt Use no header, send raw data as used by RTDS GTNETv2-SKT + # fake | gtnet-skt:fake Same as 'none', but use first three data values as + # sequence, seconds & nanoseconds timestamp + # In this mode values are uint32_t not floats! + + endian = "network", # Endianess of header and data: + # big | network Use big endianess. Also know as network byte order (default) + # little Use little endianess. + local = "127.0.0.1:12001", # This node only received messages on this IP:Port pair remote = "127.0.0.1:12000" # This node sents outgoing messages to this IP:Port pair diff --git a/etc/example.conf b/etc/example.conf index 7f5ce6753..9294330d9 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -39,6 +39,9 @@ nodes = { # sequence, seconds & nanoseconds timestamp # In this mode values are uint32_t not floats! + endian = "network", # Endianess of header and data: + # big | network Use big endianess. Also know as network byte order (default) + # little Use little endianess. local = "127.0.0.1:12001", # This node only received messages on this IP:Port pair remote = "127.0.0.1:12000" # This node sents outgoing messages to this IP:Port pair diff --git a/lib/nodes/socket.c b/lib/nodes/socket.c index 9ab1bf712..265da681e 100644 --- a/lib/nodes/socket.c +++ b/lib/nodes/socket.c @@ -102,7 +102,7 @@ int socket_deinit() char * socket_print(struct node *n) { struct socket *s = n->_vd; - char *layer = NULL, *header = NULL, *buf; + char *layer = NULL, *header = NULL, *endian = NULL, *buf; switch (s->layer) { case SOCKET_LAYER_UDP: layer = "udp"; break; @@ -115,11 +115,19 @@ char * socket_print(struct node *n) case SOCKET_HEADER_FAKE: header = "fake"; break; case SOCKET_HEADER_DEFAULT: header = "default"; break; } + + if (s->header == SOCKET_HEADER_DEFAULT) + endian = "auto"; + else + switch (s->endian) { + case MSG_ENDIAN_LITTLE: endian = "little"; break; + case MSG_ENDIAN_BIG: endian = "big"; break; + } char *local = socket_print_addr((struct sockaddr *) &s->local); char *remote = socket_print_addr((struct sockaddr *) &s->remote); - buf = strf("layer=%s, header=%s, local=%s, remote=%s", layer, header, local, remote); + buf = strf("layer=%s, header=%s, endian=%s, local=%s, remote=%s", layer, header, endian, local, remote); free(local); free(remote);