MCPcopy Create free account
hub / github.com/CANopenNode/CANopenNode / CO_ODF_traceConfig

Function CO_ODF_traceConfig

extra/CO_trace.c:174–240  ·  view source on GitHub ↗

OD function for accessing _OD_traceConfig_ (index 0x2300+) from SDO server. * For more information see file CO_SDOserver.h. */

Source from the content-addressed store, hash-verified

172/* OD function for accessing _OD_traceConfig_ (index 0x2300+) from SDO server.
173 * For more information see file CO_SDOserver.h. */
174static CO_SDO_abortCode_t CO_ODF_traceConfig(CO_ODF_arg_t *ODF_arg) {
175 CO_trace_t *trace;
176 CO_SDO_abortCode_t ret = CO_SDO_AB_NONE;
177
178 trace = (CO_trace_t*) ODF_arg->object;
179
180 switch(ODF_arg->subIndex) {
181 case 1: /* size */
182 if(ODF_arg->reading) {
183 CO_setUint32(ODF_arg->data, trace->bufferSize);
184 }
185 break;
186
187 case 2: /* axisNo (trace enabled if nonzero) */
188 if(ODF_arg->reading) {
189 uint8_t *value = (uint8_t*) ODF_arg->data;
190 if(!trace->enabled) {
191 *value = 0;
192 }
193 }
194 else {
195 uint8_t *value = (uint8_t*) ODF_arg->data;
196
197 if(*value == 0) {
198 trace->enabled = false;
199 }
200 else if(!trace->enabled) {
201 if(trace->bufferSize == 0) {
202 ret = CO_SDO_AB_OUT_OF_MEM;
203 }
204 else {
205 /* set trace->OD_variable and trace->dt, based on 'map' and 'format' */
206 findVariable(trace);
207
208 if(trace->OD_variable != NULL) {
209 *trace->value = 0;
210 *trace->minValue = 0;
211 *trace->maxValue = 0;
212 *trace->triggerTime = 0;
213 trace->valuePrev = 0;
214 trace->readPtr = 0;
215 trace->writePtr = 0;
216 trace->enabled = true;
217 }
218 else {
219 ret = CO_SDO_AB_NO_MAP;
220 }
221 }
222 }
223 }
224 break;
225
226 case 5: /* map */
227 case 6: /* format */
228 if(!ODF_arg->reading) {
229 if(trace->enabled) {
230 ret = CO_SDO_AB_INVALID_VALUE;
231 }

Callers

nothing calls this directly

Calls 2

CO_setUint32Function · 0.85
findVariableFunction · 0.85

Tested by

no test coverage detected