#ifndef __CAN_DEVIND_H__ #define __CAN_DEVIND_H__ #include #include //exclusively device-independent, portable (shared for PC and MCU) functions are here typedef struct { union { uint8_t byte[8]; uint16_t shorts[4]; uint32_t reg[2]; uint64_t word; } data; uint16_t id; uint8_t length; } CAN_MESSAGE; typedef struct { char *groupname; char *signame; char *unit; union { uint8_t uint8[4]; uint16_t uint16[2]; uint32_t uint32; int8_t int8[4]; int16_t int16[2]; int32_t int32; float floatval; } value; uint16_t group; int16_t pid; int8_t item; int8_t type; } CAN_VALUE; #define MAXSIG 32 #define SIGNAME_LEN 32 #define UNIT_NAME_LEN 8 #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif extern void print_can_message(CAN_MESSAGE *m, FILE *out, uint8_t ond2only); extern void decode_and_output_can_message(CAN_MESSAGE *m, FILE *out); extern void output_can_values(CAN_VALUE *val, int8_t n, FILE *out); extern void output_can_value(CAN_VALUE *val, FILE *out); extern void sprintf_can_value(CAN_VALUE *v, char *line); extern void sprintf_can_name_value(CAN_VALUE *v, char *line); extern int8_t decode_can_message(CAN_MESSAGE *m, CAN_VALUE *v); extern char *dtc2text(uint8_t *code, char *dtc); extern void create_OBD2_query(uint8_t service, uint16_t pid, CAN_MESSAGE *m); extern uint8_t parse_OBD2_reply(const CAN_MESSAGE *m, uint16_t *address, uint8_t *service, uint16_t *pid, uint8_t *abcd); extern int8_t S1pid_is_unsupported(CAN_VALUE *v, uint8_t pid); #if defined(__cplusplus) || defined(c_plusplus) } #endif #endif