Fix times once again...
[revag-nm.git] / vw-nm.h
1 #ifndef __VW_NM_H__
2 #define __VW_NM_H__
3
4 #include <sys/time.h>
5
6
7 enum {
8         /* OSEK/VDX NM Level 0 */
9
10         NM_MAIN_OFF      = 0x00,
11         NM_MAIN_ON       = 0x01,
12         NM_MAIN_LOGIN    = 0x02,
13         NM_MAIN_LIMPHOME = 0x04,
14         NM_MAIN_MASK     = 0x0F,
15
16         NM_SLEEP_CANCEL  = 0x00,
17         NM_SLEEP_REQUEST = 0x10,
18         NM_SLEEP_ACK     = 0x20,
19         NM_SLEEP_MASK    = 0xF0,
20 };
21
22 typedef unsigned char NM_ID;
23 typedef unsigned char NM_State;
24
25 struct NM_Node {
26         NM_ID next;
27         NM_State state;
28 };
29
30
31 enum timer_reason {
32         NM_TIMER_NOW,
33         NM_TIMER_NORMAL,
34         NM_TIMER_AWOL,
35         NM_TIMER_LIMPHOME,
36 };
37
38 struct NM_Main {
39         unsigned max_nodes;
40         struct NM_Node *nodes;
41
42         NM_ID my_id;
43         canid_t can_base;
44
45         struct timeval tv;
46         enum timer_reason timer_reason;
47 };
48
49
50
51
52 /* OSEK/VDX NM: T_Typ
53  *
54  * This timeout is ~50 ms in:
55  *  - 0x19 (RCD 310, Bosch)
56  *
57  * and ~45ms in:
58  *  - 0x0b Instrument cluster?
59  *  - 0x15 MDI
60  *  - 0x1A Phone
61  */
62 #define NM_USECS_NORMAL_TURN 50000
63
64
65 /* OSEK/VDX NM: T_Max
66  *
67  * This timeout is 140 ms in:
68  *  - 0x19 (RCD 310, Bosch)
69  */
70 #define NM_USECS_NODE_AWOL 140000
71
72
73 /* OSEK/VDX NM: T_Error
74  *
75  * This timeout is 500 ms in:
76  *  - 0x19 (RCD 310, Bosch)
77  */
78 #define NM_USECS_LIMPHOME 500000
79
80
81 #endif /* __VW_NM_H__ */