From fb29ffc525ed220735f0e524bcc7304834c983fa Mon Sep 17 00:00:00 2001 From: Mazet Laurent Date: Thu, 27 Mar 2025 22:58:46 +0100 Subject: [PATCH] working on real interfaces --- morep_valid.c | 19 ++++++++++--------- script-rx.eth | 12 ++++++++++++ script.eth => script-tx.eth | 6 +++--- 3 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 script-rx.eth rename script.eth => script-tx.eth (61%) diff --git a/morep_valid.c b/morep_valid.c index 54fe897..83c7121 100644 --- a/morep_valid.c +++ b/morep_valid.c @@ -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 index 0000000..a83129f --- /dev/null +++ b/script-rx.eth @@ -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.eth b/script-tx.eth similarity index 61% rename from script.eth rename to script-tx.eth index a358ada..70a7af1 100644 --- a/script.eth +++ b/script-tx.eth @@ -1,12 +1,12 @@ # Test script T0808 MSG=42 PAYLOAD="Hello_world" -R0808 MSG=43 PAYLOAD="Bye" +R0809 MSG=43 PAYLOAD="Bye" SLEEP 1000 T0808 MSG=24 PAYLOAD=42796520776f726c64 -R0808 MSG=25 PAYLOAD=48656c6c6f +R0809 MSG=25 PAYLOAD=48656c6c6f T0808 MSG=10 PAYLOAD=@makefile -R0808 MSG=11 PAYLOAD="OK" +R0809 MSG=11 PAYLOAD="OK" -- 2.30.2