diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index d33685c..fc371e5 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -653,11 +653,43 @@ int LegacyDLLExport icsneoGetErrorMessages(void* hObject, int* pErrorMsgs, int* return false; } -int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR* szErrorDescriptionShort, TCHAR* szErrorDescriptionLong, +int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, char* szErrorDescriptionShort, char* szErrorDescriptionLong, int* lMaxLengthShort, int* lMaxLengthLong, int* lErrorSeverity, int* lRestartNeeded) { - // TODO Implement - return false; + if (szErrorDescriptionShort == nullptr || szErrorDescriptionLong == nullptr + || lMaxLengthShort == nullptr || lMaxLengthLong == nullptr || lErrorSeverity == nullptr + || lRestartNeeded == nullptr) + { + return false; + } + + //Set and send back 0. We will not restart the software. + *lRestartNeeded = 0; + + //Using the error number, get the description from the event. + const char* tempDescription = APIEvent::DescriptionForType(APIEvent::Type(lErrorNumber)); + int descrLength = int(std::strlen(tempDescription)); + + //Check to make sure the length of the error is not >= the buffer. + if (descrLength >= *lMaxLengthShort || descrLength >= *lMaxLengthLong) + { + return false; + } + + //Copy the error description to the inout Short and Long arguments. + std::copy(tempDescription, tempDescription + descrLength, szErrorDescriptionShort); + std::copy(tempDescription, tempDescription + descrLength, szErrorDescriptionLong); + + //Add the null terminator. + szErrorDescriptionShort[descrLength] = '\0'; + szErrorDescriptionLong[descrLength] = '\0'; + + //Update the inout lengths to what the actual length of the error is + *lMaxLengthShort = *lMaxLengthLong = descrLength; + + //Update the inout severity argument. + *lErrorSeverity = int(APIEvent::Severity::Any); + return true; } //ISO15765-2 Functions diff --git a/include/icsneo/icsneolegacy.h b/include/icsneo/icsneolegacy.h index e71173d..42937a7 100644 --- a/include/icsneo/icsneolegacy.h +++ b/include/icsneo/icsneolegacy.h @@ -91,7 +91,7 @@ extern int LegacyDLLExport icsneoFindRemoteNeoDevices(const char* pIPAddress, Ne //Error Functions extern int LegacyDLLExport icsneoGetLastAPIError(void* hObject, unsigned long* pErrorNumber); extern int LegacyDLLExport icsneoGetErrorMessages(void* hObject, int* pErrorMsgs, int* pNumberOfErrors); -extern int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR*szErrorDescriptionShort, TCHAR*szErrorDescriptionLong, int* lMaxLengthShort, int* lMaxLengthLong,int* lErrorSeverity,int* lRestartNeeded); +extern int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, char* szErrorDescriptionShort, char* szErrorDescriptionLong, int* lMaxLengthShort, int* lMaxLengthLong,int* lErrorSeverity,int* lRestartNeeded); //ISO15765-2 Functions extern int LegacyDLLExport icsneoISO15765_EnableNetworks(void* hObject, unsigned long ulNetworks);