From: Mazet Laurent Date: Tue, 8 Apr 2025 00:47:42 +0000 (+0200) Subject: remove payload type X-Git-Tag: v1.0~62 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=5b6749875da769c301a87706397c361e44918c88;p=morep.git remove payload type --- diff --git a/morep_valid.c b/morep_valid.c index cb7ef92..a111812 100644 --- a/morep_valid.c +++ b/morep_valid.c @@ -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 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 - - Description : This file contains definition of a raw payloaddata type - - History : - - initial version -*/ - -#include - -#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 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 - - Description : This file contains definition of a raw paylad - - History : - - initial version -*/ - -#ifndef __PAYLOAD_H__ -#define __PAYLOAD_H__ - -#include -#include - -__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: */ diff --git a/script-lo.eth b/script-lo.eth index 87df396..515b729 100644 --- a/script-lo.eth +++ b/script-lo.eth @@ -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 diff --git a/script-rx.eth b/script-rx.eth index a83129f..4d2c191 100644 --- a/script-rx.eth +++ b/script-rx.eth @@ -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" diff --git a/script-tx.eth b/script-tx.eth index 70a7af1..c09411d 100644 --- a/script-tx.eth +++ b/script-tx.eth @@ -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"