summaryrefslogtreecommitdiff
path: root/cethcan
diff options
context:
space:
mode:
Diffstat (limited to 'cethcan')
-rw-r--r--cethcan/can.c10
-rw-r--r--cethcan/cethcan.h2
-rw-r--r--cethcan/cethcan.json4
-rw-r--r--cethcan/main.c7
-rwxr-xr-xcethcan/start19
5 files changed, 35 insertions, 7 deletions
diff --git a/cethcan/can.c b/cethcan/can.c
index 5145871..39da3f1 100644
--- a/cethcan/can.c
+++ b/cethcan/can.c
@@ -40,10 +40,12 @@ void can_broadcast(struct can_user *origin, struct can_message *msg)
lprintf("invalid CAN message (DLC = %zu)", msg->dlc);
return;
}
- for (size_t i = 0; i < msg->dlc; i++)
- sprintf(buf + 3 * i, " %02x", msg->bytes[i]);
- lprintf("%s: %08x (%zu)%s", origin->name,
- (unsigned)msg->daddr, msg->dlc, buf);
+ if (verbosity >= 1) {
+ for (size_t i = 0; i < msg->dlc; i++)
+ sprintf(buf + 3 * i, " %02x", msg->bytes[i]);
+ lprintf("%s: %08x (%zu)%s", origin->name,
+ (unsigned)msg->daddr, msg->dlc, buf);
+ }
for (u = users; u; u = u->next)
if (u != origin)
diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h
index ab5edde..5b42f54 100644
--- a/cethcan/cethcan.h
+++ b/cethcan/cethcan.h
@@ -27,6 +27,8 @@
#include "protocol.h"
+extern int verbosity;
+
#define lprintf(...) do { \
struct timeval tv; struct tm tm; char tvbuf[64]; \
gettimeofday(&tv, NULL); localtime_r(&tv.tv_sec, &tm); \
diff --git a/cethcan/cethcan.json b/cethcan/cethcan.json
index 25aaea8..ae84cb4 100644
--- a/cethcan/cethcan.json
+++ b/cethcan/cethcan.json
@@ -18,9 +18,9 @@
{ "addr": 1098, "name": "dali.hacklab.west.outer" }
],
"beans": [
- { "addr": 256, "name": "door.right", "values": [ "open", "closed" ] },
+ { "addr": 256, "name": "toilet.lock", "values": [ "open", "closed" ] },
{ "addr": 257, "name": "door.left", "values": [ "open", "closed" ] },
- { "addr": 258, "name": "door.light", "values": [ "triggered", "normal" ] },
+ { "addr": 258, "name": "door.right", "values": [ "open", "closed" ] },
{ "addr": 259, "name": "door.lock", "values": [ "open", "closed" ] }
],
"espnet": [ {
diff --git a/cethcan/main.c b/cethcan/main.c
index 961c543..2b9154e 100644
--- a/cethcan/main.c
+++ b/cethcan/main.c
@@ -2,6 +2,8 @@
struct event_base *ev_base;
+int verbosity = 0;
+
int main(int argc, char **argv)
{
int optch = 0;
@@ -11,11 +13,14 @@ int main(int argc, char **argv)
struct sigaction sa;
do {
- optch = getopt(argc, argv, "c:");
+ optch = getopt(argc, argv, "vc:");
switch (optch) {
case 'c':
cfgfile = optarg;
break;
+ case 'v':
+ verbosity++;
+ break;
case -1:
break;
}
diff --git a/cethcan/start b/cethcan/start
new file mode 100755
index 0000000..33a9be2
--- /dev/null
+++ b/cethcan/start
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+sleep 1
+
+/sbin/modprobe c_can_platform
+/sbin/modprobe can-raw
+
+sleep 1
+
+/sbin/ip link set can0 down
+/sbin/ip link set can0 type can tq 1500 prop-seg 2 phase-seg1 1 phase-seg2 2 sjw 1
+# /sbin/ip link set can0 type can bitrate 111111
+/sbin/ip link set can0 type can restart-ms 100 listen-only off berr-reporting on
+/sbin/ip link set can0 promisc on up
+
+sleep 1
+
+exec /root/spaceautomation/cethcan/cethcan
+