2016-05-25 17:37:40 +02:00
|
|
|
#ifndef SERIALQUEUE_H
|
|
|
|
#define SERIALQUEUE_H
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
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);
|
2016-05-25 17:37:40 +02:00
|
|
|
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
|
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);
|
2016-07-11 17:41:49 +02:00
|
|
|
void serialqueue_set_baud_adjust(struct serialqueue *sq, double baud_adjust);
|
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
|
|
|
|
, double last_clock_time, uint64_t last_clock);
|
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
|