CORDET Framework - C2 Implementation
CrPsPktServEvtSupp.c
Go to the documentation of this file.
1 
23 #include <Pckt/CrFwPckt.h>
24 #include <CrPsPkt.h>
25 #include <CrPsUserConstants.h>
26 #include <DataPool/CrPsDpServEvt.h>
27 #include <DataPool/CrPsDp.h>
28 
35 CrPsEid_t getEvtEnableCmdEventIdItem(void* p, CrPsNumberU4_t N)
36 {
37  CrPsEid_t ret;
38  uint32_t pos;
39 
40  if(N>0)
41  {
42  N=N-1;
43  }
44  pos = sizeof(TcHeader_t)+sizeof(CrPsNumberU4_t)+(sizeof(CrPsEid_t)*N);
45  memcpy(&ret, &((uint8_t*)p)[pos], sizeof(CrPsEid_t));
46  return __builtin_bswap16(ret);
47 }
48 
55 void setEvtEnableCmdEventIdItem(void* p, CrPsNumberU4_t N, CrPsEid_t src)
56 {
57  uint32_t pos;
58 
59  if(N>0)
60  {
61  N=N-1;
62  }
63  pos = sizeof(TcHeader_t)+sizeof(CrPsNumberU4_t)+(sizeof(CrPsEid_t)*N);
64  src = __builtin_bswap16(src);
65  memcpy(&((uint8_t*)p)[pos], &src, sizeof(CrPsEid_t));
66 }
67 
74 CrPsEid_t getEvtDisableCmdEventIdItem(void* p, CrPsNumberU4_t N)
75 {
76  CrPsEid_t ret;
77  uint32_t pos;
78 
79  if(N>0)
80  {
81  N=N-1;
82  }
83  pos = sizeof(TcHeader_t)+sizeof(CrPsNumberU4_t)+(sizeof(CrPsEid_t)*N);
84  memcpy(&ret, &((uint8_t*)p)[pos], sizeof(CrPsEid_t));
85  return __builtin_bswap16(ret);
86 }
87 
94 void setEvtDisableCmdEventIdItem(void* p, CrPsNumberU4_t N, CrPsEid_t src)
95 {
96  uint32_t pos;
97 
98  if(N>0)
99  {
100  N=N-1;
101  }
102  pos = sizeof(TcHeader_t)+sizeof(CrPsNumberU4_t)+(sizeof(CrPsEid_t)*N);;
103  src = __builtin_bswap16(src);
104  memcpy(&((uint8_t*)p)[pos], &src, sizeof(CrPsEid_t));
105 }
106 
113 CrPsEid_t getEvtRepDisabledRepEventIdItem(void* p, CrPsNumberU4_t N)
114 {
115  CrPsEid_t ret;
116  uint32_t pos;
117 
118  if(N>0)
119  {
120  N=N-1;
121  }
122  pos = sizeof(TmHeader_t)+(sizeof(CrPsEid_t)*N);
123  memcpy(&ret, &((uint8_t*)p)[pos], sizeof(CrPsEid_t));
124  return __builtin_bswap16(ret);
125 }
126 
133 void setEvtRepDisabledRepEventIdItem(void* p, CrPsNumberU4_t N, CrPsEid_t src)
134 {
135  uint32_t pos;
136 
137  if(N>0)
138  {
139  N=N-1;
140  }
141  pos = sizeof(TmHeader_t)+(sizeof(CrPsEid_t)*N);
142  src = __builtin_bswap16(src);
143  memcpy(&((uint8_t*)p)[pos], &src, sizeof(CrPsEid_t));
144 }
145 
152 {
153  size_t s;
154  unsigned int i;
155  CrPsFlag_t isEnabled;
156 
157  /* NOTE: can also be calculated from nOfDisabledEid_x data pool entries */
158 
159  s=sizeof(TmHeader_t) + 2;
160 
161  /* Check for number of disabled EIDs */
162  for (i=0; i<EVT_N_EID; i++)
163  {
164  isEnabled = getDpisEidEnabledItem(i);
165  if (isEnabled == 0)
166  {
167  s += sizeof(CrPsEid_t);
168  }
169  }
170 
171  return s;
172 }
173 
174 
175 /*----------------------------------------------------------------------------*/
176 
void setEvtRepDisabledRepEventIdItem(void *p, CrPsNumberU4_t N, CrPsEid_t src)
Set "EventId" arrayItem in "EvtRepDisabledRep" packet.
CrFwCounterU4_t i
CrPsCmd5EidStart function definitions.
#define EVT_N_EID
Number of event identifiers supported by the application.
Header file to define all user-configurable constants and types for the IASW Application.
void setEvtEnableCmdEventIdItem(void *p, CrPsNumberU4_t N, CrPsEid_t src)
Set "EventId" arrayItem in "EvtEnableCmd" packet.
Interface for accessing data pool items.
Interface for creating and accessing a report or command packet.
CrPsEid_t getEvtDisableCmdEventIdItem(void *p, CrPsNumberU4_t N)
Get "EventId" arrayItem from "EvtDisableCmd" packet.
size_t getEvtRepDisabledSize()
Get the size of a Disabled Event Reporting packet.
uint16_t CrPsEid_t
Type used for Event Id of a Packet.
CrPsEid_t getEvtEnableCmdEventIdItem(void *p, CrPsNumberU4_t N)
Get "EventId" arrayItem from "EvtEnableCmd" packet.
Packet header definitions.
void setEvtDisableCmdEventIdItem(void *p, CrPsNumberU4_t N, CrPsEid_t src)
Set "EventId" arrayItem in "EvtDisableCmd" packet.
Interface for accessing fields in packets of service "ServEvt".
auxiliary Interface for accessing fields in packets of service "ServEvt".
Interface for accessing data pool items.
static CrPsFlag_t getDpisEidEnabledItem(int i)
Gets the value of the i-th element in the datapool array isEidEnabled.
CrPsEid_t getEvtRepDisabledRepEventIdItem(void *p, CrPsNumberU4_t N)
Get "EventId" arrayItem from "EvtRepDisabledRep" packet.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved