summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2017-03-18 22:09:53 +0100
committernorly <ny-git@enpas.org>2017-03-18 22:46:18 +0100
commit4beb79252d1c432feceed2e40429900b9ee0cf48 (patch)
tree4d7c4114b68978166b6ed756652904bd8902f4d5
parent65531f9a117392b6858eec9435830ef168119064 (diff)
More limp home handling
-rw-r--r--vw-nm-tools.h2
-rw-r--r--vw-nm.c17
-rw-r--r--vw-nm.h6
3 files changed, 18 insertions, 7 deletions
diff --git a/vw-nm-tools.h b/vw-nm-tools.h
index e9e26c8..426e778 100644
--- a/vw-nm-tools.h
+++ b/vw-nm-tools.h
@@ -104,7 +104,7 @@ static struct NM_Main* nm_alloc(unsigned node_bits, NM_ID my_id, canid_t can_bas
nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
nm->tv.tv_sec = 0;
- nm->tv.tv_usec = NM_USECS_OTHER_TURN;
+ nm->tv.tv_usec = NM_USECS_NODE_AWOL;
return nm;
}
diff --git a/vw-nm.c b/vw-nm.c
index e656e68..5afa961 100644
--- a/vw-nm.c
+++ b/vw-nm.c
@@ -65,6 +65,15 @@ static void nm_update_my_next_id(struct NM_Main *nm) {
break;
}
} while (id != nm->my_id);
+
+ if (nm->nodes[nm->my_id].next == nm->my_id) {
+ /* Uh oh, we're the only one left. */
+
+ /* TODO */
+ nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
+
+ /* TODO: Timeout 140ms (RCD 310) */
+ }
}
@@ -142,7 +151,7 @@ static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame)
* connectivity.
*/
nm->tv.tv_sec = 0;
- nm->tv.tv_usec = NM_USECS_OTHER_TURN;
+ nm->tv.tv_usec = NM_USECS_NODE_AWOL;
}
break;
case NM_MAIN_LOGIN:
@@ -163,9 +172,11 @@ static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame)
*/
if (next != sender) {
nm->tv.tv_sec = 0;
- nm->tv.tv_usec = NM_USECS_OTHER_TURN;
+ nm->tv.tv_usec = NM_USECS_NODE_AWOL;
}
break;
+ case NM_MAIN_LIMPHOME:
+ nm_update_my_next_id(nm);
}
nm_dump_all(nm);
@@ -190,7 +201,7 @@ static void nm_buildframe(struct NM_Main *nm, struct can_frame *frame)
static void nm_timeout_callback(struct NM_Main *nm, struct can_frame *frame)
{
nm->tv.tv_sec = 0;
- nm->tv.tv_usec = NM_USECS_OTHER_TURN;
+ nm->tv.tv_usec = NM_USECS_NODE_AWOL;
nm_buildframe(nm, frame);
}
diff --git a/vw-nm.h b/vw-nm.h
index 8237dae..01f3c44 100644
--- a/vw-nm.h
+++ b/vw-nm.h
@@ -49,13 +49,13 @@ struct NM_Main {
*
* We may reduce it since we're not on a real-time OS.
*/
-#define NM_USECS_MY_TURN 40000
+#define NM_USECS_MY_TURN 45000
-/* This timeout is 50 ms in:
+/* This timeout is 140 ms in:
* - 0x19 (RCD 310, Bosch)
*/
-#define NM_USECS_OTHER_TURN 50000
+#define NM_USECS_NODE_AWOL 140000
/* This timeout is 500 ms in: