struct-frame 0.0.22__py3-none-any.whl → 0.0.23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of struct-frame might be problematic. Click here for more details.
- struct_frame/boilerplate/c/struct_frame_cpp.h +42 -0
- struct_frame/boilerplate/c/struct_frame_parser.h +3 -1
- struct_frame/boilerplate/c/struct_frame_types.h +1 -2
- {struct_frame-0.0.22.dist-info → struct_frame-0.0.23.dist-info}/METADATA +1 -1
- {struct_frame-0.0.22.dist-info → struct_frame-0.0.23.dist-info}/RECORD +7 -6
- {struct_frame-0.0.22.dist-info → struct_frame-0.0.23.dist-info}/WHEEL +0 -0
- {struct_frame-0.0.22.dist-info → struct_frame-0.0.23.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "struct_frame_parser.h"
|
|
4
|
+
#include "struct_frame_types.h"
|
|
5
|
+
|
|
6
|
+
class StructFrameDevice : public struct_buffer {
|
|
7
|
+
public:
|
|
8
|
+
StructFrameDevice(struct_frame_config config)
|
|
9
|
+
: struct_buffer{config, nullptr, 0, 0, false, 0, LOOKING_FOR_START_BYTE, 0, {false, 0, 0}},
|
|
10
|
+
parser_result_{config, false, 0, 0, false, {0, 0}} {}
|
|
11
|
+
|
|
12
|
+
void Init() { PutArray(struct_buffer::data, struct_buffer::max_size, 0); }
|
|
13
|
+
|
|
14
|
+
void RunRx() {
|
|
15
|
+
uint8_t *buffer;
|
|
16
|
+
size_t buffer_size;
|
|
17
|
+
GetArray(buffer, buffer_size);
|
|
18
|
+
if (buffer && buffer_size) {
|
|
19
|
+
while (!parser_result_.finished) {
|
|
20
|
+
if (parse_buffer(buffer, buffer_size, &parser_result_)) {
|
|
21
|
+
if (parser_result_.valid) {
|
|
22
|
+
HandleResult();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void RunTx() { PutArray(struct_buffer::data, struct_buffer::max_size, struct_buffer::size); }
|
|
30
|
+
|
|
31
|
+
// Put Array must accept the full buffer of data and returns a pointer to either a new buffer or the same buffer
|
|
32
|
+
// that is free
|
|
33
|
+
virtual void PutArray(uint8_t *&buffer, size_t &max_length, size_t length) = 0;
|
|
34
|
+
|
|
35
|
+
// Get array, a pointer to an array and refernce to the array length is pased and mutated by this function
|
|
36
|
+
virtual void GetArray(uint8_t *&buffer, size_t &length) = 0;
|
|
37
|
+
|
|
38
|
+
virtual void HandleResult() = 0;
|
|
39
|
+
|
|
40
|
+
private:
|
|
41
|
+
buffer_parser_result_t parser_result_;
|
|
42
|
+
};
|
|
@@ -63,6 +63,7 @@ static inline bool parse_char(struct_buffer *pb, uint8_t c) {
|
|
|
63
63
|
static inline bool parse_buffer(uint8_t *buffer, size_t size, buffer_parser_result_t *parser_result) {
|
|
64
64
|
enum ParserState state = LOOKING_FOR_START_BYTE;
|
|
65
65
|
parser_functions_t *parse_func_ptr;
|
|
66
|
+
parser_result->finished = false;
|
|
66
67
|
for (size_t i = parser_result->r_loc; i < size; i++) {
|
|
67
68
|
switch (state) {
|
|
68
69
|
case LOOKING_FOR_START_BYTE:
|
|
@@ -81,7 +82,6 @@ static inline bool parse_buffer(uint8_t *buffer, size_t size, buffer_parser_resu
|
|
|
81
82
|
case GETTING_PAYLOAD:
|
|
82
83
|
parser_result->msg_loc = buffer + i;
|
|
83
84
|
parser_result->r_loc = i + parser_result->msg_id_len.len;
|
|
84
|
-
parser_result->found = true;
|
|
85
85
|
if (parse_func_ptr->validate_packet(parser_result->msg_loc, &parser_result->msg_id_len)) {
|
|
86
86
|
parser_result->valid = true;
|
|
87
87
|
return true;
|
|
@@ -95,5 +95,7 @@ static inline bool parse_buffer(uint8_t *buffer, size_t size, buffer_parser_resu
|
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
parser_result->finished = true;
|
|
99
|
+
parser_result->r_loc = 0;
|
|
98
100
|
return false;
|
|
99
101
|
}
|
|
@@ -43,7 +43,6 @@ typedef struct _struct_frame_buffer {
|
|
|
43
43
|
|
|
44
44
|
typedef struct _buffer_parser_result_t {
|
|
45
45
|
struct_frame_config config;
|
|
46
|
-
bool found;
|
|
47
46
|
bool valid;
|
|
48
47
|
uint8_t *msg_loc;
|
|
49
48
|
size_t r_loc;
|
|
@@ -56,7 +55,7 @@ typedef struct _buffer_parser_result_t {
|
|
|
56
55
|
|
|
57
56
|
#define default_parser {0, 0, 0x90}
|
|
58
57
|
|
|
59
|
-
#define zero_initialized_parser_result {default_parser, false,
|
|
58
|
+
#define zero_initialized_parser_result {default_parser, false, 0, 0, false, {0, 0}}
|
|
60
59
|
|
|
61
60
|
#define CREATE_DEFAULT_STRUCT_BUFFER(name, size) \
|
|
62
61
|
uint8_t name##_buffer[size]; \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: struct-frame
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.23
|
|
4
4
|
Summary: A framework for serializing data with headers
|
|
5
5
|
Project-URL: Homepage, https://github.com/mylonics/struct-frame
|
|
6
6
|
Project-URL: Issues, https://github.com/mylonics/struct-frame/issues
|
|
@@ -5,14 +5,15 @@ struct_frame/c_gen.py,sha256=dQw52Zgec38O471KaHuYkRyehcxfjmSOpvhppExgB1c,5969
|
|
|
5
5
|
struct_frame/generate.py,sha256=UkZEZtKfTEmC0lEeInL7F4amCYFx1-bXPg23382rV-Y,11903
|
|
6
6
|
struct_frame/ts_gen.py,sha256=9arnjhgQZqT4F2aTKyFQrHNpn7u-fqX3B-g_17sxIFE,6137
|
|
7
7
|
struct_frame/boilerplate/c/struct_frame.h,sha256=vou8iXsV_4dQBlZRuMNOr1RnuXD1bUJUR4A3dH_uvwM,4564
|
|
8
|
+
struct_frame/boilerplate/c/struct_frame_cpp.h,sha256=gZRNmrQqmzoGkfwlGKh14dfbndkeVhnro11SNPngJng,1387
|
|
8
9
|
struct_frame/boilerplate/c/struct_frame_gen.h,sha256=rsuYGesEv1rWzSU1z6ybG-1e95RuVR7_IiR1mGLhYpQ,14
|
|
9
|
-
struct_frame/boilerplate/c/struct_frame_parser.h,sha256=
|
|
10
|
-
struct_frame/boilerplate/c/struct_frame_types.h,sha256=
|
|
10
|
+
struct_frame/boilerplate/c/struct_frame_parser.h,sha256=5WP-0fH8BbqTeRUdzAye0Qh6gPBNHwVUocB3-gn5MOE,3005
|
|
11
|
+
struct_frame/boilerplate/c/struct_frame_types.h,sha256=5aJUQ_cbVPM9drdRfo1gmN46-PiAtICAZYrpVjmHaJA,1684
|
|
11
12
|
struct_frame/boilerplate/ts/struct_frame.ts,sha256=botKdIKVP7Bi6BJdXfIZaGAmoATnuj54LxZxc4DAWqM,2252
|
|
12
13
|
struct_frame/boilerplate/ts/struct_frame_gen.ts,sha256=pz6QTIWDTIY0rMCFiGNgp3DcfO7cKsmXrx3rj3zgN_U,164
|
|
13
14
|
struct_frame/boilerplate/ts/struct_frame_parser.ts,sha256=6eTbafomqTsX3Fvfn82rxNQMxu4PwTaPug38xw4wrhE,3523
|
|
14
15
|
struct_frame/boilerplate/ts/struct_frame_types.ts,sha256=aBtxVI2lUJKGPTtJAOpbStpS2sXSKvd4XWCIsOnaMk8,2130
|
|
15
|
-
struct_frame-0.0.
|
|
16
|
-
struct_frame-0.0.
|
|
17
|
-
struct_frame-0.0.
|
|
18
|
-
struct_frame-0.0.
|
|
16
|
+
struct_frame-0.0.23.dist-info/METADATA,sha256=hR99Tvri4v-oJ6nFuhoOo8MfsIm91zcCIeCbYO_gk14,704
|
|
17
|
+
struct_frame-0.0.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
struct_frame-0.0.23.dist-info/licenses/LICENSE,sha256=UjbLtGfcHCIqJg9UzEVGoNW8fyX4Ah9ZbsuAmJ_vhmk,1094
|
|
19
|
+
struct_frame-0.0.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|