[PATCH v2 0/5] libtest: Add packet processor
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Jan 25 19:22:56 UTC 2024
The RTEMS Test Framework packet processor provides a simple mechanism to
exchange reliable and in-order data through transmitting and receiving
one character at a time.
The packet processor does not buffer data. The processor uses a
stop-and-wait automatic repeat request method. There is at most one packet
in transmission. The data transfer is done using a single character input
and output method. The protocol uses 12-bit sequence numbers, so a host
could use a sliding window method to increase throughput. All integers and
data are base64url encoded. A 24-bit CRC is used to ensure the data
integrity. The '{' character starts a packet. The '}' character terminates
a packet. The '#' character prefixes a 24-bit CRC value. The ':' character
separates fields. The '+' character prefixes data fields. The following
packets are defined:
* hello: {<12-bit seq><12-bit ack>:H#<24-bit CRC>}
* acknowledge: {<12-bit seq><12-bit ack>:A#<24-bit CRC>}
* reject: {<12-bit seq><12-bit ack>
:R:<12-bit seq of rejected packet>#<24-bit CRC>}
* jump: {<12-bit seq><12-bit ack>:J:<64-bit address>#<24-bit CRC>}
* load: {<12-bit seq><12-bit ack>:L:<64-bit load address>:
<64-bit load size in bytes>#<24-bit CRC>+<data to load>#<24-bit CRC>}
* signal: {<12-bit seq><12-bit ack>:S:<64-bit signal number>:
<64-bit signal value>#<24-bit CRC>}
* channel: {<12-bit seq><12-bit ack>:C:<64-bit channel number>:
<64-bit data size in bytes>#<24-bit CRC>+<channel data>#<24-bit CRC>}
The intended use case are boot loaders and test runners. For example, test
runners may interface with an external test server performing equipment
handling on request using the packet processor.
Use T_packet_initialize() to initialize the packet processor. Use
T_packet_process() to drive the packet processing. You can enqueue
packets for transmission with T_packet_enqueue(). You can reliably send
signals with T_packet_send(). You can reliably transmit and receive
channel data with T_packet_channel_push() and
T_packet_channel_exchange().
A simple boot loader could be implemented like this:
#include <bsp.h>
#include <rtems/bspIo.h>
#include <rtems/counter.h>
#include <rtems/test-packet.h>
static void output_char(T_packet_control* self, uint8_t ch) {
(void)self;
rtems_putc(ch);
}
static T_packet_status event_handler(T_packet_control* self,
T_packet_event_control* ctrl,
T_packet_event evt) {
(void)ctrl;
switch (evt) {
case T_PACKET_EVENT_JUMP:
T_packet_output_acknowledge(self);
bsp_restart(T_packet_get_jump_address(self));
break;
case T_PACKET_EVENT_HELLO:
case T_PACKET_EVENT_LOAD_END:
T_packet_output_acknowledge(self);
break;
case T_PACKET_EVENT_OUTPUT_END:
rtems_putc('\n');
break;
default:
break;
}
return T_PACKET_SUCCESSFUL;
}
static uint32_t clock_monotonic(T_packet_control* self) {
(void)self;
return rtems_counter_read();
}
static void Init(rtems_task_argument arg) {
(void)arg;
T_packet_control self;
T_packet_initialize(&self, 0, NULL, output_char, clock_monotonic);
T_packet_event_control event;
T_packet_prepend_event_handler(&self, &event, event_handler);
while (true) {
T_packet_process(&self, getchark());
}
}
v2:
Move things around.
Matthew Joyce (1):
base64: Add decoder
Sebastian Huber (4):
base64: Move base64 encoding support
base64: Make base64 encoding tables public
crc: Add a CRC-24Q implementation
libtest: Add packet processor
cpukit/base64/base64-decode.c | 165 ++++
cpukit/base64/base64-encode.c | 121 +++
cpukit/crc/crc24q.c | 148 +++
cpukit/dev/iobase64.c | 111 ---
cpukit/include/rtems/base64.h | 198 +++++
cpukit/include/rtems/crc.h | 106 +++
cpukit/include/rtems/dev/io.h | 62 --
cpukit/include/rtems/test-packet.h | 810 +++++++++++++++++
cpukit/libtest/gcovdumpinfobase64.c | 6 +-
cpukit/libtest/t-test-hash-sha256.c | 5 +-
cpukit/libtest/t-test-packet.c | 839 ++++++++++++++++++
cpukit/libtrace/record/record-dump-base64.c | 7 +-
cpukit/libtrace/record/record-dump-zbase64.c | 9 +-
cpukit/score/src/hash.c | 4 +-
spec/build/cpukit/librtemscpu.yml | 6 +-
spec/build/cpukit/librtemstest.yml | 2 +
.../build/testsuites/unit/unit-no-clock-0.yml | 4 +
testsuites/sptests/spprintk/init.c | 23 +-
testsuites/unit/tc-base64-decode.c | 180 ++++
testsuites/unit/tc-crc.c | 42 +
testsuites/unit/tc-test-packet.c | 604 +++++++++++++
21 files changed, 3254 insertions(+), 198 deletions(-)
create mode 100644 cpukit/base64/base64-decode.c
create mode 100644 cpukit/base64/base64-encode.c
create mode 100644 cpukit/crc/crc24q.c
delete mode 100644 cpukit/dev/iobase64.c
create mode 100644 cpukit/include/rtems/base64.h
create mode 100644 cpukit/include/rtems/crc.h
create mode 100644 cpukit/include/rtems/test-packet.h
create mode 100644 cpukit/libtest/t-test-packet.c
create mode 100644 testsuites/unit/tc-base64-decode.c
create mode 100644 testsuites/unit/tc-crc.c
create mode 100644 testsuites/unit/tc-test-packet.c
--
2.35.3
More information about the devel
mailing list