Skip to content

Commit

Permalink
Added two new error-handling functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pasetti committed May 21, 2018
1 parent 519ee4d commit dc9cddc
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/CrFwRepErr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
* reported.
* This interface defines several error reporting functions, one for each set of
* error parameter types.
* Not all functions defined in this interface are used by the CORDET Framework.
* Some are intended for use by application components.
*
* The range of error codes is defined in type <code>::CrFwRepErrCode_t</code>.
* Note that this is a configurable type that users are expected to extend with
* their own error codes.
*
* In general, the implementation of this interface is entirely application-specific
* but a simple default implementation is provided in <code>CrFwRepErr.c</code>.
Expand Down Expand Up @@ -145,10 +151,35 @@ void CrFwRepErrPckt(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
* @param errCode the error code
* @param instanceId the instance identifier of the component which raises the error report
* @param typeId the type identifier of the component which raises the error report
* @param rep the component holding the report which triggered the error
* @param rep a component holding a report
*/
void CrFwRepErrRep(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
CrFwInstanceId_t instanceId, FwSmDesc_t rep);

/**
* Report an error which has one parameter attached to it representing a command component.
* This function generate an error report with one parameter.
* @param errCode the error code
* @param instanceId the instance identifier of the component which raises the error report
* @param typeId the type identifier of the component which raises the error report
* @param cmd a component holding a command
*/
void CrFwRepErrCmd(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
CrFwInstanceId_t instanceId, FwSmDesc_t cmd);


/**
* Report an error which has three parameters attached to it representing the kind of a report
* or command as given by the triplet [type, sub-type, discriminant].
* This function generate an error report with three parameters.
* @param errCode the error code
* @param instanceId the instance identifier of the component which raises the error report
* @param typeId the type identifier of the component which raises the error report
* @param type a report or command service
*/
void CrFwRepErrKind(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
CrFwInstanceId_t instanceId, CrFwServType_t servType,
CrFwServSubType_t servSubType, CrFwDiscriminant_t disc);


#endif /* CRFW_REPERR_H_ */
35 changes: 35 additions & 0 deletions tests/config/CrFwRepErr.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,41 @@ void CrFwRepErrRep(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
errRepPos = (CrFwCounterU2_t)((errRepPos + 1) % CR_FW_ERR_REP_ARRAY_SIZE);
}

/*-----------------------------------------------------------------------------------------*/
void CrFwRepErrCmd(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
CrFwInstanceId_t instanceId, FwSmDesc_t cmd) {
CrFwCounterU1_t i;
FwSmDesc_t* temp = NULL;

errRepArray[errRepPos].errCode = errCode;
errRepArray[errRepPos].instanceId = instanceId;
errRepArray[errRepPos].typeId = typeId;
temp = (FwSmDesc_t*)&errRepArray[errRepPos].par[0]; /* Load address of cmd in first 4 elements of par[] */
*temp = cmd;
for (i=4; i<CR_FW_ERR_REP_PAR_SIZE; i++)
errRepArray[errRepPos].par[i] = 255;

errRepPos = (CrFwCounterU2_t)((errRepPos + 1) % CR_FW_ERR_REP_ARRAY_SIZE);
}

/*-----------------------------------------------------------------------------------------*/
void CrFwRepErrKind(CrFwRepErrCode_t errCode, CrFwTypeId_t typeId,
CrFwInstanceId_t instanceId, CrFwServType_t servType,
CrFwServSubType_t servSubType, CrFwDiscriminant_t disc) {
CrFwCounterU1_t i;

errRepArray[errRepPos].errCode = errCode;
errRepArray[errRepPos].instanceId = instanceId;
errRepArray[errRepPos].typeId = typeId;
errRepArray[errRepPos].par[0] = (CrFwCounterU1_t)(servType % 256);;
errRepArray[errRepPos].par[1] = (CrFwCounterU1_t)(servSubType % 256);
errRepArray[errRepPos].par[2] = (CrFwCounterU1_t)(disc % 256);
for (i=3; i<CR_FW_ERR_REP_PAR_SIZE; i++)
errRepArray[errRepPos].par[i] = 255;

errRepPos = (CrFwCounterU2_t)((errRepPos + 1) % CR_FW_ERR_REP_ARRAY_SIZE);
}

/*-----------------------------------------------------------------------------------------*/
CrFwRepErrCode_t CrFwRepErrStubGetErrCode(CrFwCounterU2_t errRepPos) {
return errRepArray[errRepPos].errCode;
Expand Down

0 comments on commit dc9cddc

Please sign in to comment.