-
Notifications
You must be signed in to change notification settings - Fork 17
/
jsd_error_cirq.h
65 lines (54 loc) · 1.51 KB
/
jsd_error_cirq.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef JSD_ERROR_CIRQ_H_
#define JSD_ERROR_CIRQ_H_
#include "ethercat.h"
#include "jsd/jsd_include_defs.h"
#include <stdbool.h>
#define JSD_ERROR_CIRQ_LEN (8)
typedef struct {
ec_errort buffer[JSD_ERROR_CIRQ_LEN];
uint16_t r;
uint16_t w;
char name[JSD_NAME_LEN];
pthread_mutex_t mutex;
} jsd_error_cirq_t;
/**
* @brief Initializes a new error circular queue with name
*
* @param self error circular queue context
* @param name name of the queue for error tracking
* @return void
*/
void jsd_error_cirq_init(jsd_error_cirq_t* self, const char* name);
/**
* @brief Checks if the queue is empty
*
* real-time safe, thread-safe
*
* Note: You probably do not need to call this directly. Instead,
* call the pop() function and check the return status there.
*
* @param self error circular queue context
* @return true if empty
*/
bool jsd_error_cirq_is_empty(jsd_error_cirq_t* self);
/**
* @brief Pops a value from the error circular queue
*
* real-time safe, thread-safe
*
* @param self error circular queue context
* @param error_out the new error, NULL if queue was empty
* @return true if error_out contains good data
*/
bool jsd_error_cirq_pop(jsd_error_cirq_t* self, ec_errort* error_out);
/**
* @brief Pushes a new error to the circular queue
*
* real-time safe, thread-safe
*
* @param self error circular queue context
* @param error the new error to be added to queue
* @return void
*/
void jsd_error_cirq_push(jsd_error_cirq_t* self, ec_errort error);
#endif