From: norly Date: Sat, 18 Mar 2017 20:38:58 +0000 (+0100) Subject: Handle NM_MAIN_ON messages when we just logged in X-Git-Url: https://git.enpas.org/?p=revag-nm.git;a=commitdiff_plain;h=bdcc8461047c57f5ac9504c3bdd23afd10b9e5df Handle NM_MAIN_ON messages when we just logged in --- diff --git a/vw-nm.c b/vw-nm.c index 689cf69..2b9bccf 100644 --- a/vw-nm.c +++ b/vw-nm.c @@ -115,14 +115,20 @@ static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame) } else if (next == nm->nodes[nm->my_id].next) { /* where nm->nodes[nm->my_id].next == nm->my_id */ - /* TODO: Is this a case we need to handle? */ - /* It can happen when: * - our sent frames don't go anywhere * - we just logged in and immediately * afterwards another ECU sent a regular - * NM frame without knowing that we exist. + * NM frame. + */ + + /* Let's handle this just like a LOGIN, since + * we're learning about a new device. + * See case NM_MAIN_LOGIN below for details. */ + + nm_update_my_next_id(nm); + nm->nodes[nm->my_id].state = NM_MAIN_ON; } else if (next == nm->my_id) { /* It's our turn. * Reset the timeout so anyone we missed @@ -142,8 +148,6 @@ static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame) case NM_MAIN_LOGIN: /* Note: sender != nm->my_id */ - printf("Handling LOGIN\n"); - nm_update_my_next_id(nm); /* We're not alone anymore, so let's change state. */