diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-11-09 23:34:01 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-11-09 23:34:01 +0200 |
| commit | e7cbb2ad47498bb072ee293baaf7fc9e2999fbec (patch) | |
| tree | 073fe0b1fee57246dd639c2f21dc6b175e197a23 /Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | |
| parent | f42acf4a2513bfb156f3323d2cd9dadf67809220 (diff) | |
| parent | 313970208cf06fe7925e41a9479e619fa1aca7f6 (diff) | |
| download | Tango-e7cbb2ad47498bb072ee293baaf7fc9e2999fbec.tar.gz Tango-e7cbb2ad47498bb072ee293baaf7fc9e2999fbec.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 63072e4d8..cdb726b5e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -49,6 +49,7 @@ #include "PMR/ThreadLoading/TryThreadLoadingResponse.pb-c.h" #include "PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h" #include "PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h" +#include "PMR/ThreadLoading/AttemptThreadJoggingResponse.pb-c.h" //#include <stdint.h> //#include <stdbool.h> @@ -1597,3 +1598,52 @@ uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer) return OK; } +uint8_t attemptJogCounter = 0; +#define ATTEMPT_JOG_TIMEOUT 18 +char AttemptJoggingToken[36+1] = {0}; + +uint32_t AttemptThreadJoggingCallback(uint32_t index, uint32_t ReadValue) +{ + AttemptThreadJoggingResponse response = ATTEMPT_THREAD_JOGGING_RESPONSE__INIT; + MessageContainer responseContainer; + + attemptJogCounter++; + Report("AttemptThreadJoggingCallback",__FILE__,attemptJogCounter,JobEndReason,RpWarning,(int)JobIsActive(),0); + if (attemptJogCounter<ATTEMPT_JOG_TIMEOUT) + { + if (JobIsActive() == true)//jog still preparing/running + return OK; + } + if (JobEndReason == JOB_OK) + ThreadAbortJoggingFunc(); + else + { + responseContainer.has_error = true; + responseContainer.error = getJobError_to_ErrorCode(JobEndReason); + } + SafeRemoveControlCallback(LoadingControlId, AttemptThreadJoggingCallback ); + LoadingControlId = 0xFF; + + if (AttemptJoggingToken[0]) + { + responseContainer = createContainer(MESSAGE_TYPE__AttemptThreadJoggingResponse, AttemptJoggingToken, true, &response, &attempt_thread_jogging_response__pack, &attempt_thread_jogging_response__get_packed_size); + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + SendChars((char*)container_buffer, container_size); + } + return OK; + +} +uint32_t AttemptThreadJoggingFunc(MessageContainer* requestContainer) +{ + attemptJogCounter = 0; + if(requestContainer) + ustrncpy (AttemptJoggingToken, requestContainer->token,36); + Report("AttemptThreadJoggingFunc",__FILE__,__LINE__,0xFF,RpWarning,(int)ATTEMPT_JOG_TIMEOUT,0); + LoadingControlId = AddControlCallback("Load jog",AttemptThreadJoggingCallback, eOneSecond,TemplateDataReadCBFunction,0,0,0); + ThreadJoggingFunc(30); + return OK; +} + |
