projects
/
revag-nm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8bcbe0b
)
Timers: Simplify reset and reset out of limp home
author
norly
<ny-git@enpas.org>
Sun, 19 Mar 2017 00:22:14 +0000
(
01:22
+0100)
committer
norly
<ny-git@enpas.org>
Sun, 19 Mar 2017 00:22:14 +0000
(
01:22
+0100)
vw-nm-tools.h
patch
|
blob
|
history
vw-nm.c
patch
|
blob
|
history
diff --git
a/vw-nm-tools.h
b/vw-nm-tools.h
index f4126a69f06e3c99eb19409b153841567ddd127f..44d5a1b39c1c7cd39878e0695d69fd7d0a9889f7 100644
(file)
--- a/
vw-nm-tools.h
+++ b/
vw-nm-tools.h
@@
-121,14
+121,12
@@
static void nm_set_timer_awol(struct NM_Main *nm)
nm->timer_reason = NM_TIMER_AWOL;
}
nm->timer_reason = NM_TIMER_AWOL;
}
-/*
static void nm_set_timer_limphome(struct NM_Main *nm)
{
nm->tv.tv_sec = 0;
nm->tv.tv_usec = NM_USECS_LIMPHOME;
nm->timer_reason = NM_TIMER_LIMPHOME;
}
static void nm_set_timer_limphome(struct NM_Main *nm)
{
nm->tv.tv_sec = 0;
nm->tv.tv_usec = NM_USECS_LIMPHOME;
nm->timer_reason = NM_TIMER_LIMPHOME;
}
-*/
@@
-147,7
+145,7
@@
static void nm_reset(struct NM_Main *nm)
nm->nodes[nm->my_id].next = nm->my_id;
nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
nm->nodes[nm->my_id].next = nm->my_id;
nm->nodes[nm->my_id].state = NM_MAIN_LOGIN;
- nm_set_timer_no
rmal
(nm);
+ nm_set_timer_no
w
(nm);
}
}
diff --git
a/vw-nm.c
b/vw-nm.c
index 5c15071e3b7b47727bf988ce64d4bbed0b874d9b..a181fce00866871671c1bd9f3dca7cdac0c15b08 100644
(file)
--- a/
vw-nm.c
+++ b/
vw-nm.c
@@
-78,6
+78,14
@@
static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame)
return;
}
return;
}
+ /* If we're currently stuck in Limp Home mode, and we can see
+ * someone else's messages, reset and re-login.
+ */
+ if (nm->nodes[nm->my_id].state == NM_MAIN_LIMPHOME) {
+ nm_reset(nm);
+ return;
+ }
+
nm->nodes[sender].next = next;
nm->nodes[sender].state = state;
nm->nodes[sender].next = next;
nm->nodes[sender].state = state;
@@
-146,6
+154,7
@@
static void nm_handle_can_frame(struct NM_Main *nm, struct can_frame *frame)
/* Nothing else to do. */
break;
case NM_MAIN_LIMPHOME:
/* Nothing else to do. */
break;
case NM_MAIN_LIMPHOME:
+ /* Nothing we can do. Poor guy. */
break;
}
break;
}
@@
-170,25
+179,28
@@
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)
{
static void nm_timeout_callback(struct NM_Main *nm, struct can_frame *frame)
{
+ nm_buildframe(nm, frame);
+
switch(nm->timer_reason) {
case NM_TIMER_NOW:
switch(nm->timer_reason) {
case NM_TIMER_NOW:
+ /* We're due to log in */
+
+ /* We're going to be ready, let's
+ * change state (RCD 310 behavior)
+ */
+ nm->nodes[nm->my_id].state = NM_MAIN_ON;
+ nm_set_timer_normal(nm);
+ break;
case NM_TIMER_NORMAL:
/* We're due to send our own ring message */
switch(nm->nodes[nm->my_id].state & NM_MAIN_MASK) {
case NM_MAIN_ON:
break;
case NM_TIMER_NORMAL:
/* We're due to send our own ring message */
switch(nm->nodes[nm->my_id].state & NM_MAIN_MASK) {
case NM_MAIN_ON:
break;
- case NM_MAIN_LOGIN:
- /* We're going to be ready, let's
- * change state (RCD 310 behavior)
- */
- nm->nodes[nm->my_id].state = NM_MAIN_ON;
- break;
default:
default:
- printf("BUG: TIMER_NORMAL expired in
unknown NM_MAI
N state\n");
+ printf("BUG: TIMER_NORMAL expired in
non-O
N state\n");
break;
}
nm_set_timer_awol(nm);
break;
}
nm_set_timer_awol(nm);
- nm_buildframe(nm, frame);
break;
case NM_TIMER_AWOL:
/* The network is silent because a node disappeared
break;
case NM_TIMER_AWOL:
/* The network is silent because a node disappeared
@@
-198,11
+210,9
@@
static void nm_timeout_callback(struct NM_Main *nm, struct can_frame *frame)
nm_reset(nm);
break;
case NM_TIMER_LIMPHOME:
nm_reset(nm);
break;
case NM_TIMER_LIMPHOME:
- /* TODO */
+ nm_set_timer_limphome(nm);
break;
}
break;
}
-
- nm_buildframe(nm, frame);
}
}
@@
-275,14
+285,6
@@
int main(int argc, char **argv)
s = net_init(argv[1]);
s = net_init(argv[1]);
- /* Stir up the hornet's nest */
- if (1) {
- struct can_frame frame;
-
- nm_buildframe(nm, &frame);
- can_tx(s, &frame);
- }
-
while (1) {
int retval;
while (1) {
int retval;