53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
#ifndef _HEXAGRAM_SCHEDULE_H
|
|
#define _HEXAGRAM_SCHEDULE_H
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
#include <sys/time.h>
|
|
#include <time.h>
|
|
#include <signal.h>
|
|
|
|
#include <hexagram/can.h>
|
|
|
|
typedef int (*hexagram_schedule_handler)(struct can_frame *, void *);
|
|
|
|
typedef struct _hexagram_schedule_table_entry {
|
|
time_t interval_us;
|
|
struct can_frame frame;
|
|
hexagram_schedule_handler handler;
|
|
} hexagram_schedule_table_entry;
|
|
|
|
typedef struct _hexagram_schedule_slot {
|
|
time_t interval_us;
|
|
hexagram_schedule_table_entry *entry;
|
|
} hexagram_schedule_slot;
|
|
|
|
typedef struct _hexagram_schedule {
|
|
struct sigevent ev;
|
|
struct itimerspec ts;
|
|
timer_t timer;
|
|
|
|
size_t current,
|
|
count;
|
|
|
|
hexagram_schedule_table_entry *table;
|
|
|
|
void *ctx;
|
|
int error;
|
|
} hexagram_schedule;
|
|
|
|
hexagram_schedule *hexagram_schedule_create(hexagram_schedule_table_entry *table,
|
|
size_t count,
|
|
void *ctx);
|
|
|
|
void hexagram_schedule_destroy(hexagram_schedule *schedule);
|
|
|
|
void hexagram_schedule_reset(hexagram_schedule *schedule);
|
|
|
|
int hexagram_schedule_run(hexagram_schedule *schedule);
|
|
|
|
int hexagram_schedule_stop(hexagram_schedule *schedule);
|
|
|
|
int hexagram_schedule_error(hexagram_schedule *schedule);
|
|
|
|
#endif /* _HEXAGRAM_SCHEDULE_H */
|