source: trunk/MagicSoft/Cosy/incl/nmtm.h@ 770

Last change on this file since 770 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 6.5 KB
Line 
1/*-----------------------------------------------------------------------------
2nmtm.h -- NMT Master Interface
3
4Copyright (c) 1994 JANZ Computer AG
5All Rights Reserved
6
7Created 95/02/23 by Soenke Hansen
8Version 1.16 of 99/10/26
9
10Prototype declarations of functions defined in nmtm.c.
11
12-----------------------------------------------------------------------------*/
13
14
15#ifndef nmtm_DEFINED
16#define nmtm_DEFINED
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#include "defs.h"
23#include "msg.h"
24#include "cal.h"
25#include "nmts.h"
26
27/*--------- Indication and Confirmation Primitives --------------------------*/
28
29/* Origin of status/error confirmation */
30#define NMTM_LOCAL 0 /* on NMT Master */
31#define NMTM_REMOTE 1 /* on NMT Slave */
32
33/* NMT error code for locally generated errors */
34#define LOC_ERR 1
35
36/* Components of service confirmation message (spec == M_NMTM_*) */
37#define nmtm_nid u.m2.b[0] /* Node ID */
38#define nmtm_org u.m2.b[1] /* origin (local or remote) */
39#define nmtm_err u.m2.b[2] /* error code */
40#define nmtm_errs u.m2.b[3] /* error specifier */
41#define nmtm_xpct u.m2.b[4] /* toggle/state expected */
42#define nmtm_download u.m2.b[4] /* download expected by slave*/
43#define nmtm_real u.m2.b[5] /* toggle/state real */
44
45#define NMTM_TIMEOUT_ERROR TIMEOUT_ERR /* value of nmtm_errs */
46#define NMTM_TOGGLE_ERROR TOGGLE_ERR /* value of nmtm_errs */
47#define NMTM_STATE_ERROR STATE_ERR /* value of nmtm_errs */
48
49
50/* Components of configuration message (spec == M_NMTM_*) */
51#define nmtm_conf_nid u.m2.b[0] /* Node ID */
52#define nmtm_conf_subspec_lo u.m2.b[1] /* subspec lo */
53#define nmtm_conf_subspec_hi u.m2.b[2] /* subspec hi */
54#define nmtm_conf_errspec u.m2.b[3] /* error specifier */
55#define nmtm_conf_fail_reason u.m1.w[3] /* failure reason */
56#define nmtm_conf_verify_result u.m1.w[3] /* verify result */
57#define nmtm_conf_verify_reason u.m1.w[4] /* verify failure reason */
58#define nmtm_conf_appl_spec_a u.m1.w[4] /* application specific a */
59#define nmtm_conf_appl_spec_b u.m1.w[5] /* application specific b */
60#define nmtm_conf_appl_spec_c u.m1.w[6] /* application specific c */
61#define nmtm_conf_appl_spec_d u.m1.w[7] /* application specific d */
62/*--------- Remote Node Objects ---------------------------------------------*/
63
64/* Remote Node type definition */
65struct rnode {
66 NmtAddr addr; /* NMT Address */
67 int state; /* remote node state */
68 WORD_t ugt; /* guard time in 100 usecs */
69 WORD_t userGuardId; /* user def. guard ID at CANopen remote nodes */
70 BYTE_t nclass; /* node class */
71 BYTE_t flags; /* flags related to error control */
72 OBJECT obj; /* associated CAL object */
73 BYTE_t type; /* CANopen (1) / CAL (0) node */
74 BYTE_t guardErrType; /* flags related to guard error type */
75 BYTE_t xpctTogState; /* rnode expected state/togglebit */
76 BYTE_t realTogState; /* rnodes real state/togglebit */
77 BYTE_t downloadRqd; /* rnode requires download if set 1 */
78};
79
80#define NIL_RNODE (struct rnode *)0
81
82/* Table of all Remote Nodes */
83extern struct rnode *RemoteNodes[];
84
85/* Remote Node States */
86#define RN_NON_EXISTENT (-1)
87#define RN_DISCONNECTED 0
88#define RN_CONNECTED PREPARING
89#define RN_PREPARED PREPARED
90#define RN_OPERATIONAL OPERATIONAL
91#define RN_PRE_OPERATIONAL PRE_OPERATIONAL
92
93/*--------- Some guarding stuff -------------------------------------------*/
94
95/* Values for error control flags */
96#define ARRIVED 0x01 /* guarding COB from remote node arrived */
97#define RAISED 0x02 /* timeout error raised at current grd period */
98#define INDICATED 0x04 /* timeout error occ. and was ind. to user */
99#define INHIBIT_GUARD 0x08 /* Node guarding was inhibited */
100#define STATE_CH_RAISED 0x10 /* signals a state change error */
101#define STATE_CH_INDICATED 0x20 /* state change error was indicated...*/
102#define TOGGLE_RAISED 0x40 /* signals a toggle error */
103/* TOGGLE (0x80) from bit-representation (see below) is used */
104/* for error control, too. */
105
106/* Values for error report flags */
107#define TIMEOUT_ERR 0x01 /* error reported to user was timeout-error */
108#define TOGGLE_ERR 0x02 /* error reported to user was tgl.-bit-error */
109#define STATE_ERR 0x04 /* error reported to user was state-error */
110
111/* guarding protocols bit representation */
112#define TOGGLE 0x80 /* toggle bit of guarding protocol */
113#define STATE_MASK 0x7f /* state relevant bits of guarding prot. */
114
115/*--------- Prototypes ------------------------------------------------------*/
116
117/* Create and initialize the NMT Master. */
118extern void InitNmtM(WORD_t, WORD_t, int, void (*)());
119
120/* Configure NMT master. */
121extern void ConfigNmtM(WORD_t, WORD_t, int, WORD_t);
122
123/* Remove the NMT Master. Free the resources it holds. */
124extern void DeleteNmtM(void);
125
126/* Add Remote Node service */
127extern int CreateRemoteNode(NmtAddr *);
128extern int AddRemoteNode(NmtAddr *);
129
130/* Add Remote CANopen Node service */
131extern int CreateRemoteCOPNode(NmtAddr *, WORD_t, BYTE_t);
132extern int CreateRemoteCOPNodeDefGuardId(NmtAddr *, WORD_t, BYTE_t, WORD_t);
133extern int AddRemoteCOPNode(NmtAddr *, WORD_t, BYTE_t);
134extern int AddRemoteCOPNodeDefGuardId(NmtAddr *, WORD_t, BYTE_t, WORD_t);
135
136/* Request Guarding the CANopen Remote Nodes */
137extern int GuardingRemoteCOPNodeReq(int);
138
139/* Remove Remote Node service */
140extern void RemoveRemoteNode(NmtAddr *);
141
142/* Get a remote node state */
143extern int GetRemoteNodeState(NmtAddr *);
144
145/* Request Connect Remote Node */
146extern int ConnectRemoteNodeReq(NmtAddr *, int);
147
148/* Request Prepare Remote Node */
149extern int PrepareRemoteNodeReq(int);
150
151/* Request enter pre-operational state of Remote Node */
152extern int EnterPreOperationalStateReq(int);
153
154/* Request Reset_Node state of Remote Node */
155extern int ResetNodeReq(int);
156
157/* Request Reset_Communication state of Remote Node */
158extern int ResetCommunicationReq(int);
159
160/* Request Start Remote Node */
161extern int StartRemoteNodeReq(int);
162
163/* Request Stop Remote Node */
164extern int StopRemoteNodeReq(int);
165
166/* Request Disconnect Remote Node */
167extern int DisconnectRemoteNodeReq(int);
168
169/* Request Identify Remote Nodes */
170extern int IdentifyRemoteNodesReq(int, int);
171
172/* Request Initiate Config Download */
173extern int ConfDownloadStartReq(int, int, int, int, BYTE_t *);
174
175/* Response Continue Config Download */
176extern int ConfDownloadContReq(int, int, int, BYTE_t *);
177
178/* Request Abort Configuration */
179extern int NmAbortConfigTransferReq(int, int, int);
180
181/* Request Verify Configuration */
182extern int NmVerifyConfigTransferReq(int, int);
183
184#if DEBUG>0
185extern void guard_node(int);
186#endif
187
188#ifdef __cplusplus
189}
190#endif
191
192#endif /* !nmtm_DEFINED */
Note: See TracBrowser for help on using the repository browser.