struct-frame 0.0.22__tar.gz → 0.0.23__tar.gz

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.

Files changed (31) hide show
  1. {struct_frame-0.0.22 → struct_frame-0.0.23}/PKG-INFO +1 -1
  2. {struct_frame-0.0.22 → struct_frame-0.0.23}/pyproject.toml +1 -1
  3. struct_frame-0.0.23/src/struct_frame/boilerplate/c/struct_frame_cpp.h +42 -0
  4. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/c/struct_frame_parser.h +3 -1
  5. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/c/struct_frame_types.h +1 -2
  6. {struct_frame-0.0.22 → struct_frame-0.0.23}/.clang-format +0 -0
  7. {struct_frame-0.0.22 → struct_frame-0.0.23}/.gitignore +0 -0
  8. {struct_frame-0.0.22 → struct_frame-0.0.23}/DEVGUIDE.md +0 -0
  9. {struct_frame-0.0.22 → struct_frame-0.0.23}/LICENSE +0 -0
  10. {struct_frame-0.0.22 → struct_frame-0.0.23}/README.md +0 -0
  11. {struct_frame-0.0.22 → struct_frame-0.0.23}/TODO +0 -0
  12. {struct_frame-0.0.22 → struct_frame-0.0.23}/biostream.proto +0 -0
  13. {struct_frame-0.0.22 → struct_frame-0.0.23}/index.ts +0 -0
  14. {struct_frame-0.0.22 → struct_frame-0.0.23}/main.c +0 -0
  15. {struct_frame-0.0.22 → struct_frame-0.0.23}/myl_vehicle.proto +0 -0
  16. {struct_frame-0.0.22 → struct_frame-0.0.23}/package-lock.json +0 -0
  17. {struct_frame-0.0.22 → struct_frame-0.0.23}/package.json +0 -0
  18. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/main.py +0 -0
  19. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/__init__.py +0 -0
  20. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/__main__.py +0 -0
  21. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/base.py +0 -0
  22. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/c/struct_frame.h +0 -0
  23. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/c/struct_frame_gen.h +0 -0
  24. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/ts/struct_frame.ts +0 -0
  25. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/ts/struct_frame_gen.ts +0 -0
  26. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/ts/struct_frame_parser.ts +0 -0
  27. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/boilerplate/ts/struct_frame_types.ts +0 -0
  28. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/c_gen.py +0 -0
  29. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/generate.py +0 -0
  30. {struct_frame-0.0.22 → struct_frame-0.0.23}/src/struct_frame/ts_gen.py +0 -0
  31. {struct_frame-0.0.22 → struct_frame-0.0.23}/tsconfig.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: struct-frame
3
- Version: 0.0.22
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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "struct-frame"
7
- version = "0.0.22"
7
+ version = "0.0.23"
8
8
  authors = [
9
9
  { name="Rijesh Augustine", email="rijesh@mylonics.com" },
10
10
  ]
@@ -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, false, 0, 0, false, {0, 0}};
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]; \
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes