...
Code Block | ||
---|---|---|
| ||
/****************************************************************************/ /** MCTC MI - RPC Sync Loop */ void goal_miMctcRpcSyncLoop( MCTC_INST_T *pMiMctc /**< MI MCTC handle */ ) { GOAL_STATUS_T res = GOAL_OK; /* result */ GOAL_BOOL_T flgSetupLocal = GOAL_FALSE; /* local setup done flag */ GOAL_BOOL_T flgSetupRemote = GOAL_FALSE; /* remote setup done flag */ GOAL_MCTC_T *pHdlMctcTx = NULL; /* call handle */ /* leave if not in sync-mode */ if ((GOAL_MI_MCTC_RPC_STATE_RUN == pMiMctc->stateRpc) || (GOAL_MI_MCTC_RPC_STATE_STOP == pMiMctc->stateRpc)) { return; } /* check if send is permitted */ if (GOAL_TRUE != goal_miMctcRpcSendAllow(pMiMctc)) { return; } /* handle state machine */ switch (pMiMctc->stateRpc) { case GOAL_MI_MCTC_RPC_STATE_RUN_ONCE: /* .... */ break; /* initialize synchronisation */ case GOAL_MI_MCTC_RPC_STATE_SYNC_INIT: goal_logDbg("state: SYNC_INIT"); /* reset sync state */ GOAL_MASK_SET(pMiMctc->flgRpc, GOAL_MI_MCTC_RPC_FLG_SYNC_REQ); GOAL_MASK_CLR(pMiMctc->flgRpc, GOAL_MI_MCTC_RPC_FLG_SYNC_ACK); pMiMctc->seqRpcLocal = 0; pMiMctc->seqRpcLocalAck = 0; pMiMctc->seqRpcRemoteAck = 0; pMiMctc->stateRpc = GOAL_MI_MCTC_RPC_STATE_SYNC_REQ; /* intended fallthrough */ GOAL_TARGET_FALLTHROUGH; /* request synchronisation from partner */ case GOAL_MI_MCTC_RPC_STATE_SYNC_REQ: goal_logDbg("state: SYNC_REQ"); /* send RPC sync frame until ACK is received */ if (!(GOAL_MI_MCTC_RPC_FLG_SYNC_ACK & pMiMctc->flgRpcRemote)) { /* send sync request frame */ goal_miMctcRpcSend(pMiMctc, NULL, 0); break; } /* request acknowledge of first sequence */ GOAL_MASK_CLR(pMiMctc->flgRpc, GOAL_MI_MCTC_RPC_FLG_SYNC_REQ); GOAL_MASK_SET(pMiMctc->flgRpc, GOAL_MI_MCTC_RPC_FLG_REQ_ACK); pMiMctc->seqRpcLocal = 1; pMiMctc->stateRpc = GOAL_MI_MCTC_RPC_STATE_SYNC_ACK_LOCAL; /* intended fallthrough */ GOAL_TARGET_FALLTHROUGH; case GOAL_MI_MCTC_RPC_STATE_SYNC_ACK_LOCAL: goal_logDbg("state: SYNC_ACK_LOCAL"); /* send empty sequence 1 until ACK is received and we confirmed remote sequence */ if (1 != pMiMctc->seqRpcLocalAck) { /* send empty RPC request */ goal_miMctcRpcSend(pMiMctc, NULL, 0); break; } /* wait for remote sync */ pMiMctc->stateRpc = GOAL_MI_MCTC_RPC_STATE_SYNC_ACK_REMOTE; break; case GOAL_MI_MCTC_RPC_STATE_SYNC_ACK_REMOTE: goal_logDbg("state: SYNC_ACK_REMOTE"); if (0 == pMiMctc->seqRpcRemoteAck) { /* send empty RPC request */ goal_miMctcRpcSend(pMiMctc, NULL, 0); break; } /* enter run mode */ GOAL_MASK_CLR(pMiMctc->flgRpc, GOAL_MI_MCTC_RPC_FLG_REQ_ACK); pMiMctc->stateRpc = GOAL_MI_MCTC_RPC_STATE_RUN_ONCE; break; } } |
Debugging
Disabling Peer-Loss Detection
By default both, the basic SPI communication and the RPC communication, are monitored and in case of loss of communication or a missing response an error is detected and propagated. This will stop the system from working any further. This can be disabled for debugging purpose. However this should never be done in a productive system, since this will mask potential communication problems.
...
This will disable both the RPC timeout and the SPI communication timeout. If the application controller is halted for an arbitrary time, operation can be resumed without any error.
General Debugging procedure
If debugging an application some precautions need to be considered. The correct sequence for debugging a application would be:
stop the application (on the application controller)
reset the SoM module (e.g. using the reset button on the arduino shield)
start debugging of the application (application controller)
run the application
Then the application should be able to start the communication module as required.