hexagram/include/hexagram/can.h

48 lines
1.3 KiB
C

#ifndef _HEXAGRAM_CAN_H
#define _HEXAGRAM_CAN_H
#include <stdint.h>
#include <sys/types.h>
#include <linux/can.h>
#define HEXAGRAM_CAN_DUMP_MAGIC "CAAN"
#define HEXAGRAM_CAN_DUMP_ENDIAN 0x0a0b0c0d
#define HEXAGRAM_CAN_DUMP_ENDIAN_SWAPPED 0x0d0c0b0a
#define HEXAGRAM_CAN_DUMP_TYPE_UNKNOWN 0
#define HEXAGRAM_CAN_DUMP_TYPE_SOCKETCAN 29
#define HEXAGRAM_CAN_DUMP_TSRESOL_USEC 6
typedef struct _hexagram_can_dump {
char magic[4];
uint32_t endian;
uint8_t type,
tsresol;
char iface[38];
} hexagram_can_dump;
typedef struct _hexagram_can_frame {
uint32_t timestamp_hi,
timestamp_lo;
struct can_frame frame;
} hexagram_can_frame;
typedef struct _hexagram_can_stream hexagram_can_stream;
hexagram_can_stream *hexagram_can_stream_open_fd(int fd);
hexagram_can_stream *hexagram_can_stream_create_file(const char *file,
const char *iface);
void hexagram_can_stream_destroy(hexagram_can_stream *stream);
int hexagram_can_stream_read(hexagram_can_stream *stream,
uint32_t *timestamp_hi,
uint32_t *timestamp_lo,
struct can_frame *frame);
int hexagram_can_stream_write(hexagram_can_stream *stream,
struct can_frame *frame);
#endif /* _HEXAGRAM_CAN_H */