From b92a0d24b0c3387b7ffb46a54f99f933d00eb6b9 Mon Sep 17 00:00:00 2001 From: Saleem Rashid Date: Mon, 11 Dec 2017 18:15:31 +0000 Subject: [PATCH] fsm: Include file and line in fsm_sendFailure for DEBUG_LINK --- firmware/fsm.c | 12 ++++++++++++ firmware/fsm.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/firmware/fsm.c b/firmware/fsm.c index 15359c8a33..f88e3710a7 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -106,7 +106,11 @@ void fsm_sendSuccess(const char *text) msg_write(MessageType_MessageType_Success, resp); } +#if DEBUG_LINK +void fsm_sendFailureDebug(FailureType code, const char *text, const char *source) +#else void fsm_sendFailure(FailureType code, const char *text) +#endif { if (protectAbortedByInitialize) { fsm_msgInitialize((Initialize *)0); @@ -156,10 +160,18 @@ void fsm_sendFailure(FailureType code, const char *text) break; } } +#if DEBUG_LINK + resp->has_message = true; + strlcpy(resp->message, source, sizeof(resp->message)); + if (text) { + strlcat(resp->message, text, sizeof(resp->message)); + } +#else if (text) { resp->has_message = true; strlcpy(resp->message, text, sizeof(resp->message)); } +#endif msg_write(MessageType_MessageType_Failure, resp); } diff --git a/firmware/fsm.h b/firmware/fsm.h index b91129a34d..24861a2f07 100644 --- a/firmware/fsm.h +++ b/firmware/fsm.h @@ -25,7 +25,14 @@ // message functions void fsm_sendSuccess(const char *text); + +#if DEBUG_LINK +void fsm_sendFailureDebug(FailureType code, const char *text, const char *source); + +#define fsm_sendFailure(code, text) fsm_sendFailureDebug((code), (text), __FILE__ ":" VERSTR(__LINE__) ":") +#else void fsm_sendFailure(FailureType code, const char *text); +#endif void fsm_msgInitialize(Initialize *msg); void fsm_msgGetFeatures(GetFeatures *msg);