NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
pdo.c
Go to the documentation of this file.
1
13#include "canfestival.h"
14#include "sysdep.h"
15#include "pdo.h"
16#include "objacces.h"
17
28UNS8 buildPDO (CO_Data * d, UNS8 numPdo, Message * pdo)
29{
30 const indextable *TPDO_com = d->objdict + d->firstIndex->PDO_TRS + numPdo;
31 const indextable *TPDO_map = d->objdict + d->firstIndex->PDO_TRS_MAP + numPdo;
32
33 UNS8 prp_j = 0x00;
34 UNS8 offset = 0x00;
35 const UNS8 *pMappingCount = (UNS8 *) TPDO_map->pSubindex[0].pObject;
36
37 pdo->cob_id = UNS16_LE(*(UNS32*)TPDO_com->pSubindex[1].pObject & 0x7FF);
38 pdo->rtr = NOT_A_REQUEST;
39
40 MSG_WAR (0x3009, " PDO CobId is : ",
41 *(UNS32 *) TPDO_com->pSubindex[1].pObject);
42 MSG_WAR (0x300D, " Number of objects mapped : ", *pMappingCount);
43
44 do
45 {
46 UNS8 dataType; /* Unused */
47 UNS8 tmp[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; /* temporary space to hold bits */
48
49 /* pointer for the var which holds the mapping parameter of an mapping entry */
50 UNS32 *pMappingParameter =
51 (UNS32 *) TPDO_map->pSubindex[prp_j + 1].pObject;
52 UNS16 index = (UNS16) ((*pMappingParameter) >> 16);
53 UNS32 Size = (UNS32) (*pMappingParameter & (UNS32) 0x000000FF); /* Size in bits */
54
55 /* get variable only if Size != 0 and Size is lower than remaining bits in the PDO */
56 if (Size && ((offset + Size) <= 64))
57 {
58 UNS32 ByteSize = 1 + ((Size - 1) >> 3); /*1->8 => 1 ; 9->16 => 2, ... */
59 UNS8 subIndex =
60 (UNS8) (((*pMappingParameter) >> (UNS8) 8) & (UNS32) 0x000000FF);
61
62 MSG_WAR (0x300F, " got mapping parameter : ", *pMappingParameter);
63 MSG_WAR (0x3050, " at index : ", TPDO_map->index);
64 MSG_WAR (0x3051, " sub-index : ", prp_j + 1);
65
66 if (getODentry (d, index, subIndex, tmp, &ByteSize, &dataType, 0) !=
68 {
69 MSG_ERR (0x1013,
70 " Couldn't find mapped variable at index-subindex-size : ",
71 (UNS16) (*pMappingParameter));
72 return 0xFF;
73 }
74 /* copy bit per bit in little endian */
75 CopyBits (Size, ((UNS8 *) tmp), 0, 0,
76 (UNS8 *) & pdo->data[offset >> 3], offset % 8, 0);
77
78 offset += Size;
79 }
80 prp_j++;
81 }
82 while (prp_j < *pMappingCount);
83
84 pdo->len = 1 + ((offset - 1) >> 3);
85
86 MSG_WAR (0x3015, " End scan mapped variable", 0);
87
88 return 0;
89}
90
103{
104 UNS32 *pwCobId;
105 UNS16 offset = d->firstIndex->PDO_RCV;
106 UNS16 lastIndex = d->lastIndex->PDO_RCV;
107
108 /* Sending the request only if the cobid have been found on the PDO
109 receive */
110 /* part dictionary */
111
112 MSG_WAR (0x3930, "sendPDOrequest RPDO Index : ", RPDOIndex);
113
114 if (offset && RPDOIndex >= 0x1400)
115 {
116 offset += RPDOIndex - 0x1400;
117 if (offset <= lastIndex)
118 {
119 /* get the CobId */
120 pwCobId = d->objdict[offset].pSubindex[1].pObject;
121
122 MSG_WAR (0x3930, "sendPDOrequest cobId is : ", *pwCobId);
123 {
124 Message pdo;
125 pdo.cob_id = UNS16_LE(*pwCobId);
126 pdo.rtr = REQUEST;
127 pdo.len = 0;
128 return canSend (d->canHandle, &pdo);
129 }
130 }
131 }
132 MSG_ERR (0x1931, "sendPDOrequest : RPDO Index not found : ", RPDOIndex);
133 return 0xFF;
134}
135
145{
146 UNS8 numPdo;
147 UNS8 numMap; /* Number of the mapped varable */
148 UNS8 *pMappingCount = NULL; /* count of mapped objects... */
149 /* pointer to the var which is mapped to a pdo... */
150 /* void * pMappedAppObject = NULL; */
151 /* pointer fo the var which holds the mapping parameter of an
152 mapping entry */
153 UNS32 *pMappingParameter = NULL;
154 UNS8 *pTransmissionType = NULL; /* pointer to the transmission
155 type */
156 UNS32 *pwCobId = NULL;
157 UNS8 Size;
158 UNS8 offset;
159 UNS8 status;
160 UNS32 objDict;
161 UNS16 offsetObjdict;
162 UNS16 lastIndex;
163
164 status = state2;
165
166 MSG_WAR (0x3935, "proceedPDO, cobID : ", (UNS16_LE(m->cob_id) & 0x7ff));
167 offset = 0x00;
168 numPdo = 0;
169 numMap = 0;
170 if ((*m).rtr == NOT_A_REQUEST)
171 { /* The PDO received is not a
172 request. */
173
174 offsetObjdict = d->firstIndex->PDO_RCV;
175 lastIndex = d->lastIndex->PDO_RCV;
176
177 /* study of all the PDO stored in the dictionary */
178 if (offsetObjdict)
179 while (offsetObjdict <= lastIndex)
180 {
181
182 switch (status)
183 {
184
185 case state2:
186 /* get CobId of the dictionary correspondant to the received
187 PDO */
188 pwCobId =
189 d->objdict[offsetObjdict].pSubindex[1].pObject;
190 /* check the CobId coherance */
191 /*pwCobId is the cobId read in the dictionary at the state 3
192 */
193 if (*pwCobId == UNS16_LE(m->cob_id))
194 {
195 /* The cobId is recognized */
196 status = state4;
197 MSG_WAR (0x3936, "cobId found at index ",
198 0x1400 + numPdo);
199 break;
200 }
201 else
202 {
203 /* cobId received does not match with those write in the
204 dictionnary */
205 numPdo++;
206 offsetObjdict++;
207 status = state2;
208 break;
209 }
210
211 case state4: /* Get Mapped Objects Number */
212 /* The cobId of the message received has been found in the
213 dictionnary. */
214 offsetObjdict = d->firstIndex->PDO_RCV_MAP;
215 lastIndex = d->lastIndex->PDO_RCV_MAP;
216 pMappingCount =
217 (UNS8 *) (d->objdict + offsetObjdict +
218 numPdo)->pSubindex[0].pObject;
219 numMap = 0;
220 while (numMap < *pMappingCount)
221 {
222 UNS8 tmp[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
223 UNS32 ByteSize;
224 pMappingParameter =
225 (UNS32 *) (d->objdict + offsetObjdict +
226 numPdo)->pSubindex[numMap + 1].pObject;
227 if (pMappingParameter == NULL)
228 {
229 MSG_ERR (0x1937, "Couldn't get mapping parameter : ",
230 numMap + 1);
231 return 0xFF;
232 }
233 /* Get the addresse of the mapped variable. */
234 /* detail of *pMappingParameter : */
235 /* The 16 hight bits contains the index, the medium 8 bits
236 contains the subindex, */
237 /* and the lower 8 bits contains the size of the mapped
238 variable. */
239
240 Size = (UNS8) (*pMappingParameter & (UNS32) 0x000000FF);
241
242 /* set variable only if Size != 0 and
243 * Size is lower than remaining bits in the PDO */
244 if (Size && ((offset + Size) <= (m->len << 3)))
245 {
246 /* copy bit per bit in little endian */
247 CopyBits (Size, (UNS8 *) & m->data[offset >> 3],
248 offset % 8, 0, ((UNS8 *) tmp), 0, 0);
249 /*1->8 => 1 ; 9->16 =>2, ... */
250 ByteSize = (UNS32)(1 + ((Size - 1) >> 3));
251
252 objDict =
253 setODentry (d, (UNS16) ((*pMappingParameter) >> 16),
254 (UNS8) (((*pMappingParameter) >> 8) &
255 0xFF), tmp, &ByteSize, 0);
256
257 if (objDict != OD_SUCCESSFUL)
258 {
259 MSG_ERR (0x1938,
260 "error accessing to the mapped var : ",
261 numMap + 1);
262 MSG_WAR (0x2939, " Mapped at index : ",
263 (*pMappingParameter) >> 16);
264 MSG_WAR (0x2940, " subindex : ",
265 ((*pMappingParameter) >> 8) & 0xFF);
266 return 0xFF;
267 }
268
269 MSG_WAR (0x3942,
270 "Variable updated by PDO cobid : ",
271 UNS16_LE(m->cob_id));
272 MSG_WAR (0x3943, " Mapped at index : ",
273 (*pMappingParameter) >> 16);
274 MSG_WAR (0x3944, " subindex : ",
275 ((*pMappingParameter) >> 8) & 0xFF);
276 offset += Size;
277 }
278 numMap++;
279 } /* end loop while on mapped variables */
280
281 return 0;
282
283 } /* end switch status */
284 } /* end while */
285 } /* end if Donnees */
286 else if ((*m).rtr == REQUEST)
287 {
288 MSG_WAR (0x3946, "Receive a PDO request cobId : ", UNS16_LE(m->cob_id));
289 status = state1;
290 offsetObjdict = d->firstIndex->PDO_TRS;
291 lastIndex = d->lastIndex->PDO_TRS;
292 if (offsetObjdict)
293 while (offsetObjdict <= lastIndex)
294 {
295 /* study of all PDO stored in the objects dictionary */
296
297 switch (status)
298 {
299
300 case state1: /* check the CobId */
301 /* get CobId of the dictionary which match to the received PDO
302 */
303 pwCobId =
304 (d->objdict +
305 offsetObjdict)->pSubindex[1].pObject;
306 if (*pwCobId == UNS16_LE(m->cob_id))
307 {
308 status = state4;
309 break;
310 }
311 else
312 {
313 numPdo++;
314 offsetObjdict++;
315 }
316 status = state1;
317 break;
318
319
320 case state4: /* check transmission type */
321 pTransmissionType =
322 (UNS8 *) d->objdict[offsetObjdict].pSubindex[2].pObject;
323 /* If PDO is to be sampled and send on RTR, do it */
324 if ((*pTransmissionType == TRANS_RTR))
325 {
326 status = state5;
327 break;
328 }
329 /* RTR_SYNC means data prepared at SYNC, transmitted on RTR */
330 else if ((*pTransmissionType == TRANS_RTR_SYNC))
331 {
332 if (d->PDO_status[numPdo].
333 transmit_type_parameter & PDO_RTR_SYNC_READY)
334 {
335 /*Data ready, just send */
336 canSend (d->canHandle,
337 &d->PDO_status[numPdo].last_message);
338 return 0;
339 }
340 else
341 {
342 /* if SYNC did never occur, transmit current data */
343 /* DS301 do not tell what to do in such a case... */
344 MSG_ERR (0x1947,
345 "Not ready RTR_SYNC TPDO send current data : ",
346 UNS16_LE(m->cob_id));
347 status = state5;
348 }
349 break;
350 }
351 else if ((*pTransmissionType == TRANS_EVENT_PROFILE) ||
352 (*pTransmissionType == TRANS_EVENT_SPECIFIC))
353 {
354 /* Zap all timers and inhibit flag */
355 d->PDO_status[numPdo].event_timer =
356 DelAlarm (d->PDO_status[numPdo].event_timer);
357 d->PDO_status[numPdo].inhibit_timer =
358 DelAlarm (d->PDO_status[numPdo].inhibit_timer);
359 d->PDO_status[numPdo].transmit_type_parameter &=
360 ~PDO_INHIBITED;
361 /* Call PDOEventTimerAlarm for this TPDO,
362 * this will trigger emission et reset timers */
363 PDOEventTimerAlarm (d, numPdo);
364 return 0;
365 }
366 else
367 {
368 /* The requested PDO is not to send on request. So, does
369 nothing. */
370 MSG_WAR (0x2947, "PDO is not to send on request : ",
371 UNS16_LE(m->cob_id));
372 return 0xFF;
373 }
374
375 case state5: /* build and send requested PDO */
376 {
377 Message pdo;
378 if (buildPDO (d, numPdo, &pdo))
379 {
380 MSG_ERR (0x1948, " Couldn't build TPDO n�", numPdo);
381 return 0xFF;
382 }
383 canSend (d->canHandle, &pdo);
384 return 0;
385 }
386 } /* end switch status */
387 } /* end while */
388 } /* end if Requete */
389
390 return 0;
391}
392
404void CopyBits (UNS8 NbBits, UNS8 * SrcByteIndex, UNS8 SrcBitIndex,
405 UNS8 SrcBigEndian, UNS8 * DestByteIndex, UNS8 DestBitIndex,
406 UNS8 DestBigEndian)
407{
408 /* This loop copy as many bits that it can each time, crossing */
409 /* successively bytes */
410 // boundaries from LSB to MSB.
411 while (NbBits > 0)
412 {
413 /* Bit missalignement between src and dest */
414 INTEGER8 Vect = DestBitIndex - SrcBitIndex;
415
416 /* We can now get src and align it to dest */
417 UNS8 Aligned =
418 Vect > 0 ? *SrcByteIndex << Vect : *SrcByteIndex >> -Vect;
419
420 /* Compute the nb of bit we will be able to copy */
421 UNS8 BoudaryLimit = (Vect > 0 ? 8 - DestBitIndex : 8 - SrcBitIndex);
422 UNS8 BitsToCopy = BoudaryLimit > NbBits ? NbBits : BoudaryLimit;
423
424 /* Create a mask that will serve in: */
425 UNS8 Mask =
426 ((0xff << (DestBitIndex + BitsToCopy)) |
427 (0xff >> (8 - DestBitIndex)));
428
429 /* - Filtering src */
430 UNS8 Filtered = Aligned & ~Mask;
431
432 /* - and erase bits where we write, preserve where we don't */
433 *DestByteIndex &= Mask;
434
435 /* Then write. */
436 *DestByteIndex |= Filtered;
437
438 /*Compute next time cursors for src */
439 if ((SrcBitIndex += BitsToCopy) > 7) /* cross boundary ? */
440 {
441 SrcBitIndex = 0; /* First bit */
442 SrcByteIndex += (SrcBigEndian ? -1 : 1); /* Next byte */
443 }
444
445
446 /*Compute next time cursors for dest */
447 if ((DestBitIndex += BitsToCopy) > 7)
448 {
449 DestBitIndex = 0; /* First bit */
450 DestByteIndex += (DestBigEndian ? -1 : 1); /* Next byte */
451 }
452
453 /*And decrement counter. */
454 NbBits -= BitsToCopy;
455 }
456
457}
458
469{
470 /* Calls _sendPDOevent specifying it is not a sync event */
471 return _sendPDOevent (d, 0);
472}
473
474
482{
483 /* This is needed to avoid deletion of re-attribuated timer */
484 d->PDO_status[pdoNum].event_timer = TIMER_NONE;
485 /* force emission of PDO by artificially changing last emitted */
486 d->PDO_status[pdoNum].last_message.cob_id = 0;
487 _sendPDOevent (d, 0); /* not a Sync Event */
488}
489
497{
498 /* This is needed to avoid deletion of re-attribuated timer */
499 d->PDO_status[pdoNum].inhibit_timer = TIMER_NONE;
500 /* Remove inhibit flag */
501 d->PDO_status[pdoNum].transmit_type_parameter &= ~PDO_INHIBITED;
502 _sendPDOevent (d, 0); /* not a Sync Event */
503}
504
512UNS8 _sendPDOevent (CO_Data * d, UNS8 isSyncEvent)
513{
514 UNS8 pdoNum = 0x00; /* number of the actual processed pdo-nr. */
515 UNS8 *pTransmissionType = NULL;
516 UNS8 status = state3;
517 UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
518 UNS16 offsetObjdictMap = d->firstIndex->PDO_TRS_MAP;
519 UNS16 lastIndex = d->lastIndex->PDO_TRS;
520
521 /* study all PDO stored in the objects dictionary */
522 if (offsetObjdict)
523 {
524 Message pdo;/* = Message_Initializer;*/
525 memset(&pdo, 0, sizeof(pdo));
526 while (offsetObjdict <= lastIndex)
527 {
528 switch (status)
529 {
530 case state3:
531
532 if ( /* bSubCount always 5 with objdictedit -> check disabled */
533 /*d->objdict[offsetObjdict].bSubCount < 5 ||*/
534 /* check if TPDO is not valid */
535 *(UNS32 *) d->objdict[offsetObjdict].pSubindex[1].
536 pObject & 0x80000000)
537 {
538 MSG_WAR (0x3960, "Not a valid PDO ", 0x1800 + pdoNum);
539 /*Go next TPDO */
540 status = state11;
541 break;
542 }
543 /* get the PDO transmission type */
544 pTransmissionType =
545 (UNS8 *) d->objdict[offsetObjdict].pSubindex[2].pObject;
546 MSG_WAR (0x3962, "Reading PDO at index : ", 0x1800 + pdoNum);
547
548 /* check if transmission type is SYNCRONOUS */
549 /* message transmited every n SYNC with n=TransmissionType */
550 if (isSyncEvent &&
551 (*pTransmissionType >= TRANS_SYNC_MIN) &&
552 (*pTransmissionType <= TRANS_SYNC_MAX) &&
553 (++d->PDO_status[pdoNum].transmit_type_parameter ==
554 *pTransmissionType))
555 {
556 /*Reset count of SYNC */
557 d->PDO_status[pdoNum].transmit_type_parameter = 0;
558 MSG_WAR (0x3964, " PDO is on SYNCHRO. Trans type : ",
559 *pTransmissionType);
560 memset(&pdo, 0, sizeof(pdo));
561 /*{
562 Message msg_init = Message_Initializer;
563 pdo = msg_init;
564 }*/
565 if (buildPDO (d, pdoNum, &pdo))
566 {
567 MSG_ERR (0x1906, " Couldn't build TPDO number : ",
568 pdoNum);
569 status = state11;
570 break;
571 }
572 status = state5;
573
574 /* If transmission RTR, with data sampled on SYNC */
575 }
576 else if (isSyncEvent && (*pTransmissionType == TRANS_RTR_SYNC))
577 {
578 if (buildPDO
579 (d, pdoNum, &d->PDO_status[pdoNum].last_message))
580 {
581 MSG_ERR (0x1966, " Couldn't build TPDO number : ",
582 pdoNum);
583 d->PDO_status[pdoNum].transmit_type_parameter &=
584 ~PDO_RTR_SYNC_READY;
585 }
586 else
587 {
588 d->PDO_status[pdoNum].transmit_type_parameter |=
589 PDO_RTR_SYNC_READY;
590 }
591 status = state11;
592 break;
593 /* If transmission on Event and not inhibited, check for changes */
594 }
595 else
596 if ((isSyncEvent
597 && (*pTransmissionType == TRANS_SYNC_ACYCLIC))
598 ||
599 ((*pTransmissionType == TRANS_EVENT_PROFILE
600 || *pTransmissionType == TRANS_EVENT_SPECIFIC)
601 && !(d->PDO_status[pdoNum].
602 transmit_type_parameter & PDO_INHIBITED)))
603 {
604 MSG_WAR (0x3968, " PDO is on EVENT. Trans type : ",
605 *pTransmissionType);
606 memset(&pdo, 0, sizeof(pdo));
607 /*{
608 Message msg_init = Message_Initializer;
609 pdo = msg_init;
610 }*/
611 if (buildPDO (d, pdoNum, &pdo))
612 {
613 MSG_ERR (0x3907, " Couldn't build TPDO number : ",
614 pdoNum);
615 status = state11;
616 break;
617 }
618
619 /*Compare new and old PDO */
620 if (d->PDO_status[pdoNum].last_message.cob_id == pdo.cob_id
621 && d->PDO_status[pdoNum].last_message.len == pdo.len
622 && memcmp(d->PDO_status[pdoNum].last_message.data,
623 pdo.data, 8) == 0
624 )
625 {
626 /* No changes -> go to next pdo */
627 status = state11;
628
629 }
630 else
631 {
632
633 TIMEVAL EventTimerDuration;
634 TIMEVAL InhibitTimerDuration;
635
636 MSG_WAR (0x306A, "Changes TPDO number : ", pdoNum);
637 /* Changes detected -> transmit message */
638 EventTimerDuration =
639 *(UNS16 *) d->objdict[offsetObjdict].pSubindex[5].
640 pObject;
641 InhibitTimerDuration =
642 *(UNS16 *) d->objdict[offsetObjdict].pSubindex[3].
643 pObject;
644
645 status = state5;
646
647 /* Start both event_timer and inhibit_timer */
648 if (EventTimerDuration)
649 {
650 DelAlarm (d->PDO_status[pdoNum].event_timer);
651 d->PDO_status[pdoNum].event_timer =
652 SetAlarm (d, pdoNum, &PDOEventTimerAlarm,
653 MS_TO_TIMEVAL (EventTimerDuration), 0);
654 }
655
656 if (InhibitTimerDuration)
657 {
658 DelAlarm (d->PDO_status[pdoNum].inhibit_timer);
659 d->PDO_status[pdoNum].inhibit_timer =
660 SetAlarm (d, pdoNum, &PDOInhibitTimerAlarm,
661 US_TO_TIMEVAL (InhibitTimerDuration *
662 100), 0);
663 /* and inhibit TPDO */
664 d->PDO_status[pdoNum].transmit_type_parameter |=
665 PDO_INHIBITED;
666 }
667
668 }
669 }
670 else
671 {
672 MSG_WAR (0x306C,
673 " PDO is not on EVENT or synchro or not at this SYNC. Trans type : ",
674 *pTransmissionType);
675 status = state11;
676 }
677 break;
678 case state5: /*Send the pdo */
679
680 /*store_as_last_message */
681 d->PDO_status[pdoNum].last_message = pdo;
682 MSG_WAR (0x396D, "sendPDO cobId :", UNS16_LE(pdo.cob_id));
683 MSG_WAR (0x396E, " Nb octets : ", pdo.len);
684
685 canSend (d->canHandle, &pdo);
686 status = state11;
687 break;
688 case state11: /*Go to next TPDO */
689 pdoNum++;
690 offsetObjdict++;
691 offsetObjdictMap++;
692 MSG_WAR (0x3970, "next pdo index : ", pdoNum);
693 status = state3;
694 break;
695
696 default:
697 MSG_ERR (0x1972, "Unknown state has been reached : %d", status);
698 return 0xFF;
699
700
701 } /* end switch case */
702 } /* end while */
703 }
704 return 0;
705}
706
716 const indextable * OD_entry,
717 UNS8 bSubindex)
718{
719 /* If PDO are actives */
720 if (d->CurrentCommunicationState.csPDO)
721 switch (bSubindex)
722 {
723 case 2: /* Changed transmition type */
724 case 3: /* Changed inhibit time */
725 case 5: /* Changed event time */
726 {
727 const indextable *TPDO_com = d->objdict + d->firstIndex->PDO_TRS;
728 UNS8 numPdo = OD_entry - TPDO_com; /* number of the actual processed pdo-nr. */
729
730 /* Zap all timers and inhibit flag */
731 d->PDO_status[numPdo].event_timer =
732 DelAlarm (d->PDO_status[numPdo].event_timer);
733 d->PDO_status[numPdo].inhibit_timer =
734 DelAlarm (d->PDO_status[numPdo].inhibit_timer);
735 d->PDO_status[numPdo].transmit_type_parameter = 0;
736 /* Call PDOEventTimerAlarm for this TPDO, this will trigger emission et reset timers */
737 PDOEventTimerAlarm (d, numPdo);
738 return 0;
739 }
740
741 default: /* other subindex are ignored */
742 break;
743 }
744 return 0;
745}
746
752void PDOInit (CO_Data * d)
753{
754 /* For each TPDO mapping parameters */
755 UNS16 pdoIndex = 0x1800; /* OD index of TDPO */
756
757 UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
758 UNS16 lastIndex = d->lastIndex->PDO_TRS;
759 if (offsetObjdict)
760 while (offsetObjdict <= lastIndex)
761 {
762 /* Assign callbacks to sensible TPDO mapping subindexes */
763 UNS32 errorCode;
764 ODCallback_t *CallbackList;
765 /* Find callback list */
766 scanIndexOD (d, pdoIndex, &errorCode, &CallbackList);
767 if (errorCode == OD_SUCCESSFUL && CallbackList)
768 {
769 /*Assign callbacks to corresponding subindex */
770 /* Transmission type */
771 CallbackList[2] = &TPDO_Communication_Parameter_Callback;
772 /* Inhibit time */
773 CallbackList[3] = &TPDO_Communication_Parameter_Callback;
774 /* Event timer */
775 CallbackList[5] = &TPDO_Communication_Parameter_Callback;
776 }
777 pdoIndex++;
778 offsetObjdict++;
779 }
780
781 /* Trigger a non-sync event */
782 //_sendPDOevent (d, 0);
783}
784
790void PDOStop (CO_Data * d)
791{
792 /* For each TPDO mapping parameters */
793 UNS8 pdoNum = 0x00; /* number of the actual processed pdo-nr. */
794 UNS16 offsetObjdict = d->firstIndex->PDO_TRS;
795 UNS16 lastIndex = d->lastIndex->PDO_TRS;
796 if (offsetObjdict)
797 while (offsetObjdict <= lastIndex)
798 {
799 /* Delete TPDO timers */
800 d->PDO_status[pdoNum].event_timer =
801 DelAlarm (d->PDO_status[pdoNum].event_timer);
802 d->PDO_status[pdoNum].inhibit_timer =
803 DelAlarm (d->PDO_status[pdoNum].inhibit_timer);
804 /* Reset transmit type parameter */
805 d->PDO_status[pdoNum].transmit_type_parameter = 0;
806 d->PDO_status[pdoNum].last_message.cob_id = 0;
807 pdoNum++;
808 offsetObjdict++;
809 }
810}
811/* used only for RunEMGTask to send PDO messages */
812
820void sendPdo(CO_Data * d, UNS32 pdoNum, Message * pdo)
821{
822
823 /*store_as_last_message */
824
825 d->PDO_status[pdoNum].last_message = *pdo;
826
827 /* cob_id and len are set up in emgTask.c InitParams */
828 canSend (d->canHandle, pdo);
829
830}
831
832
833
834
835
#define UNS8
Unsigned int8 representation in CANFest.
Definition applicfg.h:25
#define UNS16
Unsigned int16 representation in CANFest.
Definition applicfg.h:26
#define MSG_WAR(num, str, val)
Definition of MSG_WAR.
Definition applicfg.h:64
#define INTEGER8
Signed int8 representation in CANFest.
Definition applicfg.h:15
#define UNS32
Unsigned int32 representation in CANFest.
Definition applicfg.h:27
#define MSG_ERR(num, str, val)
Definition of MSG_ERR.
Definition applicfg.h:52
#define REQUEST
Definition def.h:41
#define OD_SUCCESSFUL
Definition def.h:16
UNS8 processPDO(CO_Data *d, Message *m)
Compute a PDO frame reception bus_id is hardware dependant.
Definition pdo.c:144
UNS32 TPDO_Communication_Parameter_Callback(CO_Data *d, const indextable *OD_entry, UNS8 bSubindex)
<BRIEF> TPDO_Communication_Parameter_Callback
Definition pdo.c:715
void PDOInit(CO_Data *d)
Initialize PDO feature.
Definition pdo.c:752
void PDOInhibitTimerAlarm(CO_Data *d, UNS32 pdoNum)
Inhibit timer for PDO event.
Definition pdo.c:496
void PDOStop(CO_Data *d)
Stop PDO feature.
Definition pdo.c:790
UNS8 sendPDOrequest(CO_Data *d, UNS16 RPDOIndex)
Transmit a PDO request frame on the network to the slave.
Definition pdo.c:102
UNS8 buildPDO(CO_Data *d, UNS8 numPdo, Message *pdo)
Copy all the data to transmit in process_var Prepare the PDO defined at index to be sent *pwCobId : r...
Definition pdo.c:28
UNS8 _sendPDOevent(CO_Data *d, UNS8 isSyncEvent)
Function iterates on all TPDO and look TPDO transmit type and content change before sending it.
Definition pdo.c:512
UNS8 sendPDOevent(CO_Data *d)
Used by the application to signal changes in process data that could be mapped to some TPDO....
Definition pdo.c:468
void CopyBits(UNS8 NbBits, UNS8 *SrcByteIndex, UNS8 SrcBitIndex, UNS8 SrcBigEndian, UNS8 *DestByteIndex, UNS8 DestBitIndex, UNS8 DestBigEndian)
copy bit per bit in little endian
Definition pdo.c:404
void PDOEventTimerAlarm(CO_Data *d, UNS32 pdoNum)
Set timer for PDO event.
Definition pdo.c:481
void sendPdo(CO_Data *d, UNS32 pdoNum, Message *pdo)
<BRIEF> sendPDO
Definition pdo.c:820
TIMER_HANDLE SetAlarm(CO_Data *d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)
Set an alarm to execute a callback function when expired.
Definition timer.c:37
TIMER_HANDLE DelAlarm(TIMER_HANDLE handle)
Delete an alarm before expiring.
Definition timer.c:83
const indextable * scanIndexOD(CO_Data *d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback)
Scan the index of object dictionary. Used only by setODentry and getODentry.
Definition objacces.c:343
Definition can.h:13
UNS16 cob_id
Definition can.h:14
UNS8 data[8]
Definition can.h:17
UNS8 rtr
Definition can.h:15
UNS8 len
Definition can.h:16
This structure contains all necessary informations to define a CANOpen node.
Definition data.h:44