2016-05-25 17:37:40 +02:00
|
|
|
#ifndef SERIALQUEUE_H
|
|
|
|
#define SERIALQUEUE_H
|
|
|
|
|
2021-02-10 17:09:47 +01:00
|
|
|
#include <stdint.h> // uint8_t
|
2016-05-25 17:37:40 +02:00
|
|
|
#include "list.h" // struct list_head
|
2021-02-18 04:20:47 +01:00
|
|
|
#include "msgblock.h" // MESSAGE_MAX
|
2016-05-25 17:37:40 +02:00
|
|
|
|
2018-02-12 00:49:27 +01:00
|
|
|
#define MAX_CLOCK 0x7fffffffffffffffLL
|
|
|
|
#define BACKGROUND_PRIORITY_CLOCK 0x7fffffff00000000LL
|
2016-05-25 17:37:40 +02:00
|
|
|
|
2021-02-10 17:09:47 +01:00
|
|
|
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];
|
|
|
|
};
|
|
|
|
|
2016-05-25 17:37:40 +02:00
|
|
|
struct pull_queue_message {
|
|
|
|
uint8_t msg[MESSAGE_MAX];
|
|
|
|
int len;
|
|
|
|
double sent_time, receive_time;
|
2020-02-15 02:47:08 +01:00
|
|
|
uint64_t notify_id;
|
2016-05-25 17:37:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct serialqueue;
|
2021-02-07 22:03:39 +01:00
|
|
|
struct serialqueue *serialqueue_alloc(int serial_fd, char serial_fd_type
|
|
|
|
, int client_id);
|
2016-05-25 17:37:40 +02:00
|
|
|
void serialqueue_exit(struct serialqueue *sq);
|
2016-11-29 22:22:54 +01:00
|
|
|
void serialqueue_free(struct serialqueue *sq);
|
2016-05-25 17:37:40 +02:00
|
|
|
struct command_queue *serialqueue_alloc_commandqueue(void);
|
2016-11-30 07:58:45 +01:00
|
|
|
void serialqueue_free_commandqueue(struct command_queue *cq);
|
2021-02-10 17:09:47 +01:00
|
|
|
void serialqueue_add_fastreader(struct serialqueue *sq, struct fastreader *fr);
|
|
|
|
void serialqueue_rm_fastreader(struct serialqueue *sq, struct fastreader *fr);
|
2016-05-25 17:37:40 +02:00
|
|
|
void serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
|
|
|
|
, struct list_head *msgs);
|
2021-02-18 01:58:47 +01:00
|
|
|
void serialqueue_send_one(struct serialqueue *sq, struct command_queue *cq
|
|
|
|
, struct queue_message *qm);
|
2016-05-25 17:37:40 +02:00
|
|
|
void serialqueue_send(struct serialqueue *sq, struct command_queue *cq
|
2020-02-15 02:47:08 +01:00
|
|
|
, uint8_t *msg, int len, uint64_t min_clock
|
|
|
|
, uint64_t req_clock, uint64_t notify_id);
|
2016-05-25 17:37:40 +02:00
|
|
|
void serialqueue_pull(struct serialqueue *sq, struct pull_queue_message *pqm);
|
2022-07-26 02:50:19 +02:00
|
|
|
void serialqueue_set_wire_frequency(struct serialqueue *sq, double frequency);
|
2019-04-21 18:03:16 +02:00
|
|
|
void serialqueue_set_receive_window(struct serialqueue *sq, int receive_window);
|
2017-06-28 02:08:18 +02:00
|
|
|
void serialqueue_set_clock_est(struct serialqueue *sq, double est_freq
|
2021-02-16 01:18:51 +01:00
|
|
|
, double conv_time, uint64_t conv_clock
|
|
|
|
, uint64_t last_clock);
|
|
|
|
void serialqueue_get_clock_est(struct serialqueue *sq
|
|
|
|
, struct clock_estimate *ce);
|
2016-05-25 17:37:40 +02:00
|
|
|
void serialqueue_get_stats(struct serialqueue *sq, char *buf, int len);
|
|
|
|
int serialqueue_extract_old(struct serialqueue *sq, int sentq
|
|
|
|
, struct pull_queue_message *q, int max);
|
|
|
|
|
|
|
|
#endif // serialqueue.h
|