aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper/serialqueue.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-02-10 11:09:47 -0500
committerKevin O'Connor <kevin@koconnor.net>2021-06-09 18:58:35 -0400
commitc53e8c7d4a945fee54f6ad575381cebec2a87c6f (patch)
treee42b3f40c9eed0be3e6dbe3969300abd5bffba7e /klippy/chelper/serialqueue.h
parent620f77ddb79de683befb458f43c30435759ac0e2 (diff)
downloadkutter-c53e8c7d4a945fee54f6ad575381cebec2a87c6f.tar.gz
kutter-c53e8c7d4a945fee54f6ad575381cebec2a87c6f.tar.xz
kutter-c53e8c7d4a945fee54f6ad575381cebec2a87c6f.zip
serialqueue: Add "fast reader" support
Add ability to run C code directly from the low-level socket reading thread. This enables host based low-latency handlers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/serialqueue.h')
-rw-r--r--klippy/chelper/serialqueue.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/klippy/chelper/serialqueue.h b/klippy/chelper/serialqueue.h
index 62e70403..9e66e7f5 100644
--- a/klippy/chelper/serialqueue.h
+++ b/klippy/chelper/serialqueue.h
@@ -1,12 +1,23 @@
#ifndef SERIALQUEUE_H
#define SERIALQUEUE_H
+#include <stdint.h> // uint8_t
#include "list.h" // struct list_head
#include "msgblock.h" // MESSAGE_MAX
#define MAX_CLOCK 0x7fffffffffffffffLL
#define BACKGROUND_PRIORITY_CLOCK 0x7fffffff00000000LL
+struct fastreader;
+typedef void (*fastreader_cb)(struct fastreader *fr, uint8_t *data, int len);
+
+struct fastreader {
+ struct list_node node;
+ fastreader_cb func;
+ int prefix_len;
+ uint8_t prefix[MESSAGE_MAX];
+};
+
struct pull_queue_message {
uint8_t msg[MESSAGE_MAX];
int len;
@@ -21,6 +32,8 @@ void serialqueue_exit(struct serialqueue *sq);
void serialqueue_free(struct serialqueue *sq);
struct command_queue *serialqueue_alloc_commandqueue(void);
void serialqueue_free_commandqueue(struct command_queue *cq);
+void serialqueue_add_fastreader(struct serialqueue *sq, struct fastreader *fr);
+void serialqueue_rm_fastreader(struct serialqueue *sq, struct fastreader *fr);
void serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
, struct list_head *msgs);
void serialqueue_send(struct serialqueue *sq, struct command_queue *cq