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);