From a7e337c459b2b7284757127b64235579b061561c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 25 Mar 2013 21:33:29 +0100 Subject: cethcan: skeleton --- cethcan/cethcan.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 cethcan/cethcan.h (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h new file mode 100644 index 0000000..1ac898f --- /dev/null +++ b/cethcan/cethcan.h @@ -0,0 +1,60 @@ +#ifndef _CETHCAN_H +#define _CETHCAN_H + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +extern struct event_base *ev_base; +extern json_t *config; + +struct can_user; + +struct can_message { + struct can_user *origin; + + uint32_t daddr; + + uint32_t flags; +#define CAN_MSGF_RTR (1 << 0) + + size_t dlc; + uint8_t bytes[8]; +}; + +typedef void (*can_handler)(void *arg, struct can_message *msg); + +struct can_user { + struct can_user *next; + + const char *name; + + void *arg; + can_handler handler; +}; + +extern void can_register(struct can_user *user); +extern struct can_user *can_register_alloc(void *arg, can_handler handler, + const char *fmt, ...); +extern void can_broadcast(struct can_user *origin, struct can_message *msg); +extern void can_init(void); + +#endif /* _CETHCAN_H */ -- cgit v1.2.1 From f5c47e42e40e980c51fa561ca8bb0beb421ae0c0 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 25 Mar 2013 22:08:41 +0100 Subject: cethcan: more code --- cethcan/cethcan.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index 1ac898f..477221e 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -23,8 +23,16 @@ #include #include +#define lprintf(...) do { \ + struct timeval tv; struct tm tm; char tvbuf[64]; \ + gettimeofday(&tv, NULL); localtime_r(&tv.tv_sec, &tm); \ + strftime(tvbuf, sizeof(tvbuf), "%Y-%m-%d %H:%M:%S", &tm); \ + fprintf(stderr, "%s.%03d ", tvbuf, tv.tv_usec / 1000); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + } while (0) + extern struct event_base *ev_base; -extern json_t *config; struct can_user; @@ -57,4 +65,6 @@ extern struct can_user *can_register_alloc(void *arg, can_handler handler, extern void can_broadcast(struct can_user *origin, struct can_message *msg); extern void can_init(void); +extern int ether_init(json_t *config); + #endif /* _CETHCAN_H */ -- cgit v1.2.1 From 1b5e4f4ba195ad4ed02cfac6129c386c4aeaf7cd Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 25 Mar 2013 23:01:50 +0100 Subject: cethcan: more code --- cethcan/cethcan.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index 477221e..292b5c9 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -23,6 +23,8 @@ #include #include +#include "protocol.h" + #define lprintf(...) do { \ struct timeval tv; struct tm tm; char tvbuf[64]; \ gettimeofday(&tv, NULL); localtime_r(&tv.tv_sec, &tm); \ @@ -66,5 +68,6 @@ extern void can_broadcast(struct can_user *origin, struct can_message *msg); extern void can_init(void); extern int ether_init(json_t *config); +extern int light_init_conf(json_t *config); #endif /* _CETHCAN_H */ -- cgit v1.2.1 From a69a211a4a95e5c4ac0055a8f2de8ec1c56a7d1a Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 25 Mar 2013 23:19:42 +0100 Subject: cethcan: more code --- cethcan/cethcan.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index 292b5c9..aa03d8b 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -69,5 +69,6 @@ extern void can_init(void); extern int ether_init(json_t *config); extern int light_init_conf(json_t *config); +extern void http_init(void); #endif /* _CETHCAN_H */ -- cgit v1.2.1 From ac8beb0cb06e8aef35d9cfa134111e5c6ae09935 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Mon, 25 Mar 2013 23:29:15 +0100 Subject: cethcan: json output --- cethcan/cethcan.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index aa03d8b..64d185b 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -50,7 +50,12 @@ struct can_message { uint8_t bytes[8]; }; +enum json_subtype { + JSON_NORMAL = 0, +}; + typedef void (*can_handler)(void *arg, struct can_message *msg); +typedef void (*json_handler)(void *arg, json_t *json, enum json_subtype type); struct can_user { struct can_user *next; @@ -59,12 +64,14 @@ struct can_user { void *arg; can_handler handler; + json_handler json; }; extern void can_register(struct can_user *user); extern struct can_user *can_register_alloc(void *arg, can_handler handler, const char *fmt, ...); extern void can_broadcast(struct can_user *origin, struct can_message *msg); +extern void can_json(json_t *json, enum json_subtype type); extern void can_init(void); extern int ether_init(json_t *config); -- cgit v1.2.1 From d18e85802a7878450d84bb9190cce0e368c55515 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 26 Mar 2013 21:26:32 +0100 Subject: cethcan: long poll --- cethcan/cethcan.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index 64d185b..fd821fc 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -52,6 +52,7 @@ struct can_message { enum json_subtype { JSON_NORMAL = 0, + JSON_LONGPOLL = 1, }; typedef void (*can_handler)(void *arg, struct can_message *msg); @@ -74,6 +75,8 @@ extern void can_broadcast(struct can_user *origin, struct can_message *msg); extern void can_json(json_t *json, enum json_subtype type); extern void can_init(void); +extern void json_bump_longpoll(void); + extern int ether_init(json_t *config); extern int light_init_conf(json_t *config); extern void http_init(void); -- cgit v1.2.1 From cd4484ab068678edfa9335a1c6d7c91b93793970 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 1 Jun 2013 00:00:46 +0200 Subject: socketcan v0 --- cethcan/cethcan.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cethcan/cethcan.h') diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index fd821fc..4326429 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -77,6 +77,7 @@ extern void can_init(void); extern void json_bump_longpoll(void); +extern int socan_init(json_t *config); extern int ether_init(json_t *config); extern int light_init_conf(json_t *config); extern void http_init(void); -- cgit v1.2.1