working on real interfaces
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Thu, 27 Mar 2025 21:58:46 +0000 (22:58 +0100)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Thu, 27 Mar 2025 21:58:46 +0000 (22:58 +0100)
morep_valid.c
script-rx.eth [new file with mode: 0644]
script-tx.eth [new file with mode: 0644]
script.eth [deleted file]

index 54fe897e9fbf888513596991ca150250d35ae469..83c712194c4975b5969a4d3709c6bd4dc009858d 100644 (file)
@@ -123,7 +123,7 @@ int parse_line (char *line, uint8_t *msgtype, uint8_t **payload)
                 *payload = (uint8_t *) readstream (fid, &rc);
                 fclose (fid);
             } else if (strlen (val) % 2 == 0) {
-                rc = strlen (val) % 2;
+                rc = strlen (val) / 2;
                 uint8_t *buf = *payload = (uint8_t *) calloc (rc / 2, 1);
                 while (*val != '\0') {
                     char digit[3] = {0};
@@ -299,7 +299,7 @@ int main (int argc, char **argv)
         comm_t *comm = NULL;
         for (i = 0; i < nbcomms; i++) {
             comm_t *c = comm_list + i;
-            VERBOSE (morep, DEBUG, PRINTF ("test %c[%s]\n", c->mode ? 'T' : 'R', c->etype));
+            VERBOSE (morep, TRACE, PRINTF ("test %c[%s]\n", c->mode ? 'T' : 'R', c->etype));
             if ((strncmp (pt, c->etype, strlen (c->etype)) == 0) && (c->mode == mode)) {
                 comm = c;
                 pt += strlen (c->etype);
@@ -307,9 +307,10 @@ int main (int argc, char **argv)
             }
         }
         if (comm == NULL) {
-            VERBOSE (morep, WARNING, PRINTF ("no morep found '%s'\n", line));
+            VERBOSE (morep, TRACE, PRINTF ("no morep found '%s'\n", line));
             continue;
         }
+        VERBOSE (morep, DEBUG, PRINTF ("work with %c[%s]\n", comm->mode ? 'T' : 'R', comm->etype));
 
         /* get values */
         uint8_t msgtype = 0;
@@ -323,24 +324,24 @@ int main (int argc, char **argv)
         /* transmit */
         if (mode == 1) {
             int seqnum = MOREP_Send (comm->morep, msgtype, payload, len);
-            VERBOSE (morep, INFO, PRINTF ("S%s seqnum %d\n", comm->etype, seqnum));
+            VERBOSE (morep, INFO, PRINTF ("T%s seqnum=%d msg=%d length=%d\n", comm->etype, seqnum, msgtype, len));
         } else { /* receive */
             uint8_t rxmsgtype = 0;
             uint8_t rxpayload[1496 * 16 - 1] = {0};
             int rxlen = 0;
             int seqnum = MOREP_Receive (comm->morep, &rxmsgtype, rxpayload, &rxlen);
             if (rxmsgtype != msgtype) {
-                VERBOSE (morep, WARNING, PRINTF ("R%04x seqnum %d: expected msgtype %04x\n", rxmsgtype, seqnum, msgtype));
+                VERBOSE (morep, WARNING, PRINTF ("R%04x seqnum=%d: expected msgtype %04x\n", rxmsgtype, seqnum, msgtype));
             } else {
-                int ok = (len == rxlen);
+                int ok = (rxlen == len);
                 i = -1;
-                for (i = 0; ok && (i < len); i++) {
+                for (i = 0; ok && (i < rxlen); i++) {
                     ok = (rxpayload[i] == payload[i]);
                 }
                 if (!ok) {
-                    VERBOSE (morep, WARNING, PRINTF ("R%04x seqnum %d: payload diff at %d/%d\n", rxmsgtype, seqnum, i, rxlen));
+                    VERBOSE (morep, WARNING, PRINTF ("R%04x seqnum=%d: payload diff at %d/%d\n", rxmsgtype, seqnum, i, rxlen));
                 } else {
-                    VERBOSE (morep, INFO, PRINTF ("R%04x seqnum %d\n", rxmsgtype, seqnum));
+                    VERBOSE (morep, INFO, PRINTF ("R%04x seqnum=%d msg=%d length=%d\n", rxmsgtype, seqnum, rxmsgtype, rxlen));
                 }
             }
         }
diff --git a/script-rx.eth b/script-rx.eth
new file mode 100644 (file)
index 0000000..a83129f
--- /dev/null
@@ -0,0 +1,12 @@
+# Test script
+
+R0808 MSG=42 PAYLOAD="Hello_world"
+T0809 MSG=43 PAYLOAD="Bye"
+
+SLEEP 1000
+
+R0808 MSG=24 PAYLOAD=42796520776f726c64
+T0809 MSG=25 PAYLOAD=48656c6c6f
+
+R0808 MSG=10 PAYLOAD=@makefile
+T0809 MSG=11 PAYLOAD="OK"
diff --git a/script-tx.eth b/script-tx.eth
new file mode 100644 (file)
index 0000000..70a7af1
--- /dev/null
@@ -0,0 +1,12 @@
+# Test script
+
+T0808 MSG=42 PAYLOAD="Hello_world"
+R0809 MSG=43 PAYLOAD="Bye"
+
+SLEEP 1000
+
+T0808 MSG=24 PAYLOAD=42796520776f726c64
+R0809 MSG=25 PAYLOAD=48656c6c6f
+
+T0808 MSG=10 PAYLOAD=@makefile
+R0809 MSG=11 PAYLOAD="OK"
diff --git a/script.eth b/script.eth
deleted file mode 100644 (file)
index a358ada..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Test script
-
-T0808 MSG=42 PAYLOAD="Hello_world"
-R0808 MSG=43 PAYLOAD="Bye"
-
-SLEEP 1000
-
-T0808 MSG=24 PAYLOAD=42796520776f726c64
-R0808 MSG=25 PAYLOAD=48656c6c6f
-
-T0808 MSG=10 PAYLOAD=@makefile
-R0808 MSG=11 PAYLOAD="OK"