summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2020-07-02 12:20:09 +0200
committernorly <ny-git@enpas.org>2020-07-02 12:20:43 +0200
commitdf725c1e1086d45aebe9d78df0d156e618d61986 (patch)
tree2a164184026dc4986164725e6a4a097804b12147
parentca26ded5703d8e5f7e1a3ddd4949b05ed32a66e8 (diff)
Import last changes from 2017-03-26, including MDI hack
-rw-r--r--vw-nm.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/vw-nm.c b/vw-nm.c
index e5872a7..329f95e 100644
--- a/vw-nm.c
+++ b/vw-nm.c
@@ -30,7 +30,8 @@
-static void nm_update_my_next_id(struct NM_Main *nm) {
+static void nm_update_my_next_id(struct NM_Main *nm)
+{
unsigned id = nm->my_id;
do {
@@ -53,6 +54,28 @@ static void nm_update_my_next_id(struct NM_Main *nm) {
+
+static unsigned nm_num_active_nodes(struct NM_Main *nm)
+{
+ unsigned id = 0;
+ unsigned active = 0;
+
+ for (id = 0; id < nm->max_nodes; id++) {
+ NM_State state;
+
+ state = nm->nodes[id].state & NM_MAIN_MASK;
+
+ if (state == NM_MAIN_ON || state == NM_MAIN_LOGIN) {
+ /* We skip limp home nodes */
+ active++;
+ }
+ }
+
+ return active;
+}
+
+
+
static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame)
{
NM_ID sender, next;
@@ -152,6 +175,15 @@ static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame)
* round.
*/
+ /* HACK:
+ * Special case: The Media-In's NM implementation
+ * doesn't auto-switch to NM_ON. Let's say hello,
+ * even if it ends up being a little late.
+ */
+ if (nm_num_active_nodes(nm) >= 2) {
+ nm_set_timer_normal(nm);
+ }
+
/* Nothing else to do. */
break;
case NM_MAIN_LIMPHOME: