106 msg.data[0] |= 0x80 ; |
106 msg.data[0] |= 0x80 ; |
107 d->toggle = 0 ; |
107 d->toggle = 0 ; |
108 } |
108 } |
109 else |
109 else |
110 d->toggle = 1 ; |
110 d->toggle = 1 ; |
111 /*! send the nodeguard response. */ |
111 /* send the nodeguard response. */ |
112 MSG_WAR(0x3130, "Sending NMT Nodeguard to master, state: ", d->nodeState); |
112 MSG_WAR(0x3130, "Sending NMT Nodeguard to master, state: ", d->nodeState); |
113 canSend(d->canHandle,&msg ); |
113 canSend(d->canHandle,&msg ); |
114 } |
114 } |
115 |
115 |
116 }else{ /*! Not a request CAN */ |
116 }else{ /* Not a request CAN */ |
117 |
117 |
118 MSG_WAR(0x3110, "Received NMT nodeId : ", nodeId); |
118 MSG_WAR(0x3110, "Received NMT nodeId : ", nodeId); |
119 /*! the slave's state receievd is stored in the NMTable */ |
119 /* the slave's state receievd is stored in the NMTable */ |
120 /*! The state is stored on 7 bit */ |
120 /* The state is stored on 7 bit */ |
121 d->NMTable[nodeId] = (e_nodeState) ((*m).data[0] & 0x7F) ; |
121 d->NMTable[nodeId] = (e_nodeState) ((*m).data[0] & 0x7F) ; |
122 |
122 |
123 /*! Boot-Up frame reception */ |
123 /* Boot-Up frame reception */ |
124 if ( d->NMTable[nodeId] == Initialisation) |
124 if ( d->NMTable[nodeId] == Initialisation) |
125 { |
125 { |
126 /*! |
126 /* |
127 ** The device send the boot-up message (Initialisation) |
127 ** The device send the boot-up message (Initialisation) |
128 ** to indicate the master that it is entered in |
128 ** to indicate the master that it is entered in |
129 ** pre_operational mode |
129 ** pre_operational mode |
130 ** Because the device enter automaticaly in pre_operational |
130 ** Because the device enter automaticaly in pre_operational |
131 ** mode, |
131 ** mode, |
161 void ProducerHearbeatAlarm(CO_Data* d, UNS32 id) |
161 void ProducerHearbeatAlarm(CO_Data* d, UNS32 id) |
162 { |
162 { |
163 if(*d->ProducerHeartBeatTime) |
163 if(*d->ProducerHeartBeatTime) |
164 { |
164 { |
165 Message msg; |
165 Message msg; |
166 /*! Time expired, the heartbeat must be sent immediately |
166 /* Time expired, the heartbeat must be sent immediately |
167 ** generate the correct node-id: this is done by the offset 1792 |
167 ** generate the correct node-id: this is done by the offset 1792 |
168 ** (decimal) and additionaly |
168 ** (decimal) and additionaly |
169 ** the node-id of this device. |
169 ** the node-id of this device. |
170 */ |
170 */ |
171 |
171 |
172 msg.cob_id.w = *d->bDeviceNodeId + 0x700; |
172 msg.cob_id.w = *d->bDeviceNodeId + 0x700; |
173 msg.len = (UNS8)0x01; |
173 msg.len = (UNS8)0x01; |
174 msg.rtr = 0; |
174 msg.rtr = 0; |
175 msg.data[0] = d->nodeState; /*! No toggle for heartbeat !*/ |
175 msg.data[0] = d->nodeState; /* No toggle for heartbeat !*/ |
176 /*! send the heartbeat */ |
176 /* send the heartbeat */ |
177 MSG_WAR(0x3130, "Producing heartbeat: ", d->nodeState); |
177 MSG_WAR(0x3130, "Producing heartbeat: ", d->nodeState); |
178 canSend(d->canHandle,&msg ); |
178 canSend(d->canHandle,&msg ); |
179 |
179 |
180 }else{ |
180 }else{ |
181 d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer); |
181 d->ProducerHeartBeatTimer = DelAlarm(d->ProducerHeartBeatTimer); |
204 ** @param d |
204 ** @param d |
205 **/ |
205 **/ |
206 void heartbeatInit(CO_Data* d) |
206 void heartbeatInit(CO_Data* d) |
207 { |
207 { |
208 |
208 |
209 UNS8 index; /*! Index to scan the table of heartbeat consumers */ |
209 UNS8 index; /* Index to scan the table of heartbeat consumers */ |
210 RegisterSetODentryCallBack(d, 0x1017, 0x00, &OnHeartbeatProducerUpdate); |
210 RegisterSetODentryCallBack(d, 0x1017, 0x00, &OnHeartbeatProducerUpdate); |
211 |
211 |
212 d->toggle = 0; |
212 d->toggle = 0; |
213 |
213 |
214 for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ ) |
214 for( index = (UNS8)0x00; index < *d->ConsumerHeartbeatCount; index++ ) |
215 { |
215 { |
216 TIMEVAL time = (UNS16) ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ; |
216 TIMEVAL time = (UNS16) ( (d->ConsumerHeartbeatEntries[index]) & (UNS32)0x0000FFFF ) ; |
217 /*! MSG_WAR(0x3121, "should_time : ", should_time ) ; */ |
217 /* MSG_WAR(0x3121, "should_time : ", should_time ) ; */ |
218 if ( time ) |
218 if ( time ) |
219 { |
219 { |
220 d->ConsumerHeartBeatTimers[index] = SetAlarm(d, index, &ConsumerHearbeatAlarm, MS_TO_TIMEVAL(time), 0); |
220 d->ConsumerHeartBeatTimers[index] = SetAlarm(d, index, &ConsumerHearbeatAlarm, MS_TO_TIMEVAL(time), 0); |
221 } |
221 } |
222 } |
222 } |