Add README.md and COPYING
[revag-nm.git] / revag-nm.h
1 #ifndef __REVAG_NM_H__
2 #define __REVAG_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         /* How many times have we been alone when we reset? */
49         int lonely_resets;
50 };
51
52
53
54
55 /* OSEK/VDX NM: T_Typ
56  *
57  * This timeout is ~50 ms in:
58  *  - 0x19 (RCD 310, Bosch)
59  *
60  * and ~45ms in:
61  *  - 0x0b Instrument cluster?
62  *  - 0x15 MDI
63  *  - 0x1A Phone
64  */
65 #define NM_USECS_NORMAL_TURN 50000
66
67
68 /* OSEK/VDX NM: T_Max
69  *
70  * This timeout is 140 ms in:
71  *  - 0x19 (RCD 310, Bosch)
72  */
73 #define NM_USECS_NODE_AWOL 140000
74
75
76 /* OSEK/VDX NM: T_Error
77  *
78  * This timeout is 500 ms in:
79  *  - 0x19 (RCD 310, Bosch)
80  */
81 #define NM_USECS_LIMPHOME 500000
82
83
84 #endif /* __REVAG_NM_H__ */