From: Mazet Laurent Date: Thu, 27 Mar 2025 21:58:46 +0000 (+0100) Subject: working on real interfaces X-Git-Tag: v1.0~83 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=fb29ffc525ed220735f0e524bcc7304834c983fa;p=morep.git working on real interfaces --- 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-tx.eth b/script-tx.eth new file mode 100644 index 0000000..70a7af1 --- /dev/null +++ b/script-tx.eth @@ -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 index a358ada..0000000 --- a/script.eth +++ /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"