remove payload type
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 8 Apr 2025 00:47:42 +0000 (02:47 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 8 Apr 2025 00:48:00 +0000 (02:48 +0200)
morep_valid.c
payload.c [deleted file]
payload.h [deleted file]
script-lo.eth
script-rx.eth
script-tx.eth

index cb7ef92dc3679ed1fe9094153316b71efddc2e91..a11181280be78e4b9576caf4566a1789d580349f 100644 (file)
@@ -38,8 +38,6 @@ int stop = 0;
 
 DECLARE_VERBOSE_LEVEL (morep, INFO);
 
-#define MODERAW
-
 #define BUFMAX 4096
 
 void sig_handler (int sig)
@@ -292,14 +290,6 @@ int main (int argc, char **argv)
         /* get values */
         char *tmp = line + offset;
         uint8_t msgtype;
-#ifdef MODERAW
-        PAYLOAD_t payload= {0};
-        if (parse_payload (tmp, &payload) != 0) {
-            VERBOSE (morep, WARNING, PRINTF ("can't parse line '%s'\n", line));
-            continue;
-        }
-        msgtype = payload.msgtype;
-#else /* ! MODERAW */
         TEST_CHARS (tmp, " \t", 0);
         if (strncmp (tmp, "MSG", 3) != 0) {
             VERBOSE (morep, WARNING, PRINTF ("can't parse line '%s' (%s)\n", line, tmp));
@@ -318,7 +308,6 @@ int main (int argc, char **argv)
             VERBOSE (morep, WARNING, PRINTF ("can't parse line '%s'\n", line));
             continue;
         }
-#endif /* MODERAW */
         VERBOSE (morep, TRACE, PRINTF ("payload length: %d\n", payload.data_len));
 
         /* transmit */
@@ -335,31 +324,15 @@ int main (int argc, char **argv)
 
             /* check msg type */
             if (rxmsgtype != msgtype) {
-                VERBOSE (morep, WARNING, PRINTF ("R%04x SEQ=%d MSG=%d: expected msgtype %04x\n", rxmsgtype, seqnum, rxmsgtype, msgtype));
+                VERBOSE (morep, WARNING, PRINTF ("R%sx SEQ=%d MSG=%d: expected msgtype %d\n", comm->etype, seqnum, rxmsgtype, msgtype));
             }
             /* check payload */
-            else {
-                int ok = (rxlen == payload.data_len);
-                i = -1;
-                for (i = 0; ok && (i < rxlen); i++) {
-                    ok = (rxpayload[i] == payload.data[i]);
-                }
-                if (!ok) {
-                    VERBOSE (morep, WARNING, PRINTF ("R%04x SEQ=%d MSG=%d: payloads differed at %d/%d\n", rxmsgtype, seqnum, rxmsgtype, i, rxlen));
-                }
+            else if ((rxlen != payload.data_len) ||
+                    ((memcmp (rxpayload, payload.data, rxlen) != 0))) {
+                VERBOSE (morep, WARNING, PRINTF ("R%s SEQ=%d MSG=%d: payloads differed %d/%d\n", comm->etype, seqnum, rxmsgtype, payload.data_len, rxlen));
             }
             if (log) {
-#ifdef MODERAW
-                char buffer[64 + sizeof (payload.data)] = {0};
-                PAYLOAD_t _rxpayload;
-                _rxpayload.msgtype = rxmsgtype;
-                _rxpayload.data_len = rxlen;
-                memcpy (_rxpayload.data, rxpayload, rxlen);
-                format_payload (&_rxpayload, buffer, sizeof (buffer));
-                fprintf (log, "R%s %s\n", comm->etype, buffer);
-#else /* ! MODERAW */
                 print_message (log, comm->etype, 0, rxmsgtype, seqnum, rxpayload, rxlen);
-#endif /* MODERAW */
            }
         }
     }
diff --git a/payload.c b/payload.c
deleted file mode 100644 (file)
index 88ad718..0000000
--- a/payload.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  File name        : payload.c
-  Projet           : MERLIN
-  Date of creation : 2025/04/07
-  Version          : 1.0
-  Copyright        : Thales SIX
-  Author           : Laurent Mazet <laurent.mazet@thalesgroup.com>
-
-  Description      : This file contains definition of a raw payloaddata type
-
-  History          :
-  - initial version
-*/
-
-#include <stdint.h>
-
-#include "parse.h"
-
-#include "payload.h"
-
-int parse_payload (char *line, PAYLOAD_t *out)
-{
-    BEGIN_PARSE (line)
-    PARSE_INT ("MSG", out->msgtype)
-    PARSE_ARRAY ("PAYLOAD", out->data)
-    END_PARSE ()
-}
-
-int format_payload (PAYLOAD_t *in, char *buffer, int maxlen)
-{
-    BEGIN_FORMAT (buffer, maxlen)
-    FORMAT_INT ("MSG", in->msgtype)
-    FORMAT_ARRAY ("PAYLOAD", in->data)
-    END_FORMAT ()
-}
-
-int serial_payload (PAYLOAD_t *in, uint8_t *buffer, int maxlen)
-{
-    BEGIN_SERIAL (buffer, maxlen)
-    SERIAL_INT (in->msgtype)
-    SERIAL_ARRAY (in->data)
-    END_SERIAL ()
-}
-
-/* vim: set ts=4 sw=4 si et: */
diff --git a/payload.h b/payload.h
deleted file mode 100644 (file)
index f21cecd..0000000
--- a/payload.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-  File name        : payload.h
-  Projet           : MERLIN
-  Date of creation : 2025/04/07
-  Version          : 1.0
-  Copyright        : Thales SIX
-  Author           : Laurent Mazet <laurent.mazet@thalesgroup.com>
-
-  Description      : This file contains definition of a raw paylad
-
-  History          :
-  - initial version
-*/
-
-#ifndef __PAYLOAD_H__
-#define __PAYLOAD_H__
-
-#include <stdint.h>
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/**
-   @ingroup MESSAGES
-
-   Raw data type
-*/
-typedef struct {
-    uint8_t msgtype; /**< message type */
-    int data_len; /**< data length*/
-    uint8_t data[1496]; /**< data message */
-} PAYLOAD_t;
-
-/**
-   @ingroup MESSAGES
-
-   Parse a string containing a raw payload
-
-   @param line string to analyse
-   @param out output structure
-*/
-int parse_payload (char *line, PAYLOAD_t *out);
-
-/**
-   @ingroup MESSAGES
-
-   Format payload into a string
-
-   @param in input structure
-   @param buffer output string
-   @param maxlen buffer limit
-*/
-int format_payload (PAYLOAD_t *in, char *buffer, int maxlen);
-
-/**
-   @ingroup MESSAGES
-
-   Serialize payload into a network stream
-
-   @param in input structure
-   @param buffer network stream
-   @param maxlen buffer limit
-*/
-int serial_payload (PAYLOAD_t *in, uint8_t *buffer, int maxlen);
-
-__END_DECLS
-
-#endif /* __PAYLOAD_H__ */
-
-/* vim: set ts=4 sw=4 si et: */
index 87df396ef181164cfa9626ebb726c1b9aec24386..515b72962e3d7a48d00d7decc6740c9812dafe67 100644 (file)
@@ -1,12 +1,12 @@
 # Test script
 
-T0808 MSG=42 PAYLOAD="Hello_world"
-R0808 MSG=42 PAYLOAD="Hello_world"
+T0808 MSG=42 DATA="Hello_world"
+R0808 MSG=42 DATA="Hello_world"
 
 SLEEP 1000
 
-T0808 MSG=24 PAYLOAD=42796520776f726c64
-R0808 MSG=24 PAYLOAD=42796520776f726c64
+T0808 MSG=24 DATA=42796520776f726c64
+R0808 MSG=24 DATA=42796520776f726c64
 
-T0808 MSG=10 PAYLOAD=@makefile
-R0808 MSG=10 PAYLOAD=@makefile
+T0808 MSG=10 DATA=@makefile
+R0808 MSG=10 DATA=@makefile
index a83129f723ca4ac7427605eced1491b07f5d8ca0..4d2c191a40b8750e76ac7f882beb55efd8bb4d4f 100644 (file)
@@ -1,12 +1,12 @@
 # Test script
 
-R0808 MSG=42 PAYLOAD="Hello_world"
-T0809 MSG=43 PAYLOAD="Bye"
+R0808 MSG=42 DATA="Hello_world"
+T0809 MSG=43 DATA="Bye"
 
 SLEEP 1000
 
-R0808 MSG=24 PAYLOAD=42796520776f726c64
-T0809 MSG=25 PAYLOAD=48656c6c6f
+R0808 MSG=24 DATA=42796520776f726c64
+T0809 MSG=25 DATA=48656c6c6f
 
-R0808 MSG=10 PAYLOAD=@makefile
-T0809 MSG=11 PAYLOAD="OK"
+R0808 MSG=10 DATA=@makefile
+T0809 MSG=11 DATA="OK"
index 70a7af10320769fbc2934ee5a84ab826cbc4fa92..c09411d2d3394de08cc224ec6f359d7c64052e99 100644 (file)
@@ -1,12 +1,12 @@
 # Test script
 
-T0808 MSG=42 PAYLOAD="Hello_world"
-R0809 MSG=43 PAYLOAD="Bye"
+T0808 MSG=42 DATA="Hello_world"
+R0809 MSG=43 DATA="Bye"
 
 SLEEP 1000
 
-T0808 MSG=24 PAYLOAD=42796520776f726c64
-R0809 MSG=25 PAYLOAD=48656c6c6f
+T0808 MSG=24 DATA=42796520776f726c64
+R0809 MSG=25 DATA=48656c6c6f
 
-T0808 MSG=10 PAYLOAD=@makefile
-R0809 MSG=11 PAYLOAD="OK"
+T0808 MSG=10 DATA=@makefile
+R0809 MSG=11 DATA="OK"