asrt
Automated System Runtime Testing library
Loading...
Searching...
No Matches
diag_proto.h
1
11#ifndef ASRT_DIAG_PROTO_H
12#define ASRT_DIAG_PROTO_H
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#include "../asrtl/chann.h"
19#include "../asrtl/status.h"
20#include "../asrtl/util.h"
21
22enum asrt_diag_message_id_e
23{
24 ASRT_DIAG_MSG_RECORD = 0x01, // reactor -> controller
25};
26
27typedef uint8_t asrt_diag_message_id;
28
30{
31 struct asrt_span spans[2]; // [0] = file, [1] = extra (optional)
32 uint8_t hdr[6];
33 struct asrt_send_req req;
34};
35
37static inline struct asrt_send_req* asrt_msg_rtoc_diag_record(
38 struct asrt_diag_record_msg* msg,
39 char const* file,
40 uint32_t line,
41 char const* extra )
42{
43 uint8_t* p = msg->hdr;
44 *p++ = ASRT_DIAG_MSG_RECORD;
45 asrt_add_u32( &p, line );
46 size_t file_len = strlen( file );
47 if ( file_len > UINT8_MAX ) {
48 file = "filename too long";
49 file_len = strlen( file );
50 }
51 *p++ = (uint8_t) file_len;
52
53 msg->spans[0] =
54 ( struct asrt_span ){ .b = (uint8_t*) file, .e = (uint8_t*) file + file_len };
55 uint32_t rest_count = 1;
56 if ( extra ) {
57 msg->spans[1] = ( struct asrt_span ){
58 .b = (uint8_t*) extra, .e = (uint8_t*) extra + strlen( extra ) };
59 rest_count = 2;
60 }
61 msg->req.buff = ( struct asrt_span_span ){
62 .b = msg->hdr,
63 .e = msg->hdr + sizeof msg->hdr,
64 .rest = msg->spans,
65 .rest_count = rest_count,
66 };
67 return &msg->req;
68}
69
70#ifdef __cplusplus
71}
72#endif
73
74#endif // ASRT_DIAG_PROTO_H
Definition: diag_proto.h:30
An outgoing message request placed in a module's send queue.
Definition: chann.h:64
struct asrt_span_span buff
Message payload (scatter-gather).
Definition: chann.h:65
Scatter-gather buffer: a primary byte range [b, e) followed by rest_count additional spans.
Definition: span.h:37
uint32_t rest_count
Number of entries in rest.
Definition: span.h:41
uint8_t * b
Primary buffer start.
Definition: span.h:38
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee ...
Definition: span.h:23
uint8_t * b
Pointer to the first byte.
Definition: span.h:24
uint8_t * e
One-past-the-end pointer.
Definition: span.h:25