/* '======================================================================================================================================================== '=> [Start] About clsErrEventInfo '======================================================================================================================================================== '-------------------------------------------------------------------------------------------------------------------------------------------------------- '-> About Error Event Info '-------------------------------------------------------------------------------------------------------------------------------------------------------- ' ' [Build] ' Author: Jaan Doh ' Title: clsErrEventInfo ' Version: V0.1 ' Date: 12 Dec 2020 ' Category: System ' Notes: Shared generic error event info for use by framework objects ' '-------------------------------------------------------------------------------------------------------------------------------------------------------- '======================================================================================================================================================== '=> [Finish] About clsErrEventInfo '======================================================================================================================================================== */ #ifndef JD_ERROR_INFO_MODULE #define JD_ERROR_INFO_MODULE #include //-> Constants #define HUBDATA __attribute__((section(".hub"))) // const char ERRORTITLELEN1 = 32; const char ERRORDESCLEN1 = 64; // const char ETUNFORESEENLEN1 = 16; const char EDUNFORESEENLEN1 = 60; // const unsigned short eGBL_UNFORSEENERROR1 = 65535; // // //-> Variables (stored in shared hub ram) unsigned short HUBDATA _wSrcObjId1; unsigned short HUBDATA _wErrId1; char HUBDATA _baErrTitle1[33]; // title=32chars + 1 for zero separator char HUBDATA _baErrDesc1[65]; // desc=64chars + 1 for zero separator // //-> Unforeseen error text (stored in shared hub ram) char HUBDATA et_Unforeseen1[] = {"Unforseen Error!"}; // len16+1 char HUBDATA ed_Unforeseen1[] = {"An unforeseen error has occurred, please restart your device"}; //len=60+1 // // //-> Prototypes void EiInit(void); void EiClearErrors(void); unsigned int EiErrTitleAddr(void); unsigned int EiErrDescAddr(void); unsigned short EiGetSrcObjId(void); void EiSetSrcObjId(unsigned short pwNewErrSrcObjId); unsigned short EiGetErrId(void); void EiSetErrId(unsigned short pwNewErrId); void EiGetErrTitle(unsigned int *ptrDestStrAddr); void EiSetErrTitle(unsigned int *ptrSrcStrAddr); void EiGetErrDesc(unsigned int *ptrDestStrAddr); void EiSetErrDesc(unsigned int *ptrSrcStrAddr); void EiSetErrorInfo(unsigned short pwSrcObjId, unsigned short pwErrId, unsigned int *ptrErrTitleTxt, unsigned int *ptrErrDescTxt); // // //-> EiInit void EiInit(void) { EiClearErrors(); } //-> EiClearErrors void EiClearErrors(void) { char tmpPos; // tmpPos = 0; _wSrcObjId1 = 0; _wErrId1 = 0; while (tmpPos < ERRORDESCLEN1+1) { if (tmpPos < ERRORTITLELEN1+1) { _baErrTitle1[tmpPos] = 0; } _baErrDesc1[tmpPos] = 0; } } //-> EiErrTitleAddr unsigned int EiErrTitleAddr(void) { return (int)(&_baErrTitle1); } //-> EiErrDescAddr unsigned int EiErrDescAddr(void) { return (int)(&_baErrDesc1); } //-> EiGetSrcObjId unsigned short EiGetSrcObjId(void) { return _wSrcObjId1; } //-> EiSetSrcObjId void EiSetSrcObjId(unsigned short pwNewErrSrcObjId) { _wSrcObjId1 = pwNewErrSrcObjId; } //-> EiGetErrId unsigned short EiGetErrId(void) { return _wErrId1; } //-> EiSetErrId void EiSetErrId(unsigned short pwNewErrId) { _wErrId1 = pwNewErrId; } //-> EiGetErrTitle void EiGetErrTitle(unsigned int *ptrDestStrAddr) { memcpy(&_baErrTitle1, ptrDestStrAddr, ERRORTITLELEN1); } //-> EiSetErrTitle void EiSetErrTitle(unsigned int *ptrSrcStrAddr) { memcpy(ptrSrcStrAddr, &_baErrTitle1, ERRORTITLELEN1); } //-> EiGetErrDesc void EiGetErrDesc(unsigned int *ptrDestStrAddr) { memcpy(&_baErrDesc1, ptrDestStrAddr, ERRORDESCLEN1); } //-> EiSetErrDesc void EiSetErrDesc(unsigned int *ptrSrcStrAddr) { memcpy(ptrSrcStrAddr, &_baErrDesc1, ERRORDESCLEN1); } //-> EiSetErrorInfo void EiSetErrorInfo(unsigned short pwSrcObjId, unsigned short pwErrId, unsigned int *ptrErrTitleTxt, unsigned int *ptrErrDescTxt) { //-> Info // This method raises an error by populatng the error object fields with valid data and thus officiating the error // The user must call the PRintERROR method directly after calling this method to PRint the ERROR to the SCREEN //-> Process request if (pwErrId > 0) { // Clear old error info EiClearErrors; // Set error source object id _wSrcObjId1 = pwSrcObjId; // Set error id _wErrId1 = pwErrId; //-> Unforseen error if (pwErrId == eGBL_UNFORSEENERROR1) { // Store user friendly error title in error title memcpy(&_baErrTitle1, &et_Unforeseen1, ETUNFORESEENLEN1); // // Store user friendly error message in error description memcpy(&_baErrDesc1, &ed_Unforeseen1, EDUNFORESEENLEN1); } //-> Foreseen error else { // Store user friendly error title in error title memcpy(&_baErrTitle1, ptrErrTitleTxt, ERRORTITLELEN1); // // Store user friendly error message in error description memcpy(&_baErrDesc1, ptrErrDescTxt, ERRORDESCLEN1); } } } #endif /* '-------------------------------------------------------------------------------------------------------------------------------------------------------- '-> Terms Of Use : MIT Licence '-------------------------------------------------------------------------------------------------------------------------------------------------------- 'Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 'to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 'and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, ' 'Subject to the following conditions: ' The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. ' ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, ' INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ' IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ' TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ' '-------------------------------------------------------------------------------------------------------------------------------------------------------- */