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

Function CO_LSSslave_process

305/CO_LSSslave.c:259–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259bool_t
260CO_LSSslave_process(CO_LSSslave_t* LSSslave) {
261 bool_t resetCommunication = false;
262
263 if (CO_FLAG_READ(LSSslave->sendResponse)) {
264 uint8_t nid;
265 uint8_t errorCode;
266 uint8_t errorCodeManuf;
267 uint8_t tableSelector;
268 uint8_t tableIndex;
269 bool_t CANsend = false;
270 uint32_t valSw;
271
272 (void)memset(&LSSslave->TXbuff->data[0], 0, sizeof(LSSslave->TXbuff->data));
273
274 switch (LSSslave->service) {
275 case CO_LSS_SWITCH_STATE_GLOBAL: {
276 /* Node-Id was unconfigured before, now it is configured,
277 * enter the NMT Reset communication autonomously. */
278 resetCommunication = true;
279 break;
280 }
281 case CO_LSS_SWITCH_STATE_SEL_SERIAL: {
282 LSSslave->TXbuff->data[0] = CO_LSS_SWITCH_STATE_SEL;
283 CANsend = true;
284 break;
285 }
286 case CO_LSS_CFG_NODE_ID: {
287 nid = LSSslave->CANdata[1];
288 errorCode = CO_LSS_CFG_NODE_ID_OK;
289
290 if (CO_LSS_NODE_ID_VALID(nid)) {
291 *LSSslave->pendingNodeID = nid;
292 } else {
293 errorCode = CO_LSS_CFG_NODE_ID_OUT_OF_RANGE;
294 }
295
296 /* send confirmation */
297 LSSslave->TXbuff->data[0] = LSSslave->service;
298 LSSslave->TXbuff->data[1] = errorCode;
299 /* we do not use spec-error, always 0 */
300 CANsend = true;
301 break;
302 }
303 case CO_LSS_CFG_BIT_TIMING: {
304 if (LSSslave->pFunctLSScheckBitRate == NULL) {
305 /* setting bit timing is not supported. Drop request */
306 break;
307 }
308
309 tableSelector = LSSslave->CANdata[1];
310 tableIndex = LSSslave->CANdata[2];
311 errorCode = CO_LSS_CFG_BIT_TIMING_OK;
312 errorCodeManuf = CO_LSS_CFG_BIT_TIMING_OK;
313
314 if ((tableSelector == 0U) && CO_LSS_BIT_TIMING_VALID(tableIndex)) {
315 uint16_t bit = CO_LSS_bitTimingTableLookup[tableIndex];
316 bool_t bit_rate_supported = LSSslave->pFunctLSScheckBitRate(LSSslave->functLSScheckBitRateObject,

Callers 1

CO_processFunction · 0.85

Calls 1

CO_CANsendFunction · 0.85

Tested by

no test coverage detected