From 9b5b8e03c99335b1e4a2bc37cf0197e453728784 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Nov 2011 14:28:17 +0100 Subject: Implement interpreted error status response --- src/pjctl.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/pjctl.c b/src/pjctl.c index 69be760..08854bd 100644 --- a/src/pjctl.c +++ b/src/pjctl.c @@ -601,7 +601,41 @@ static void error_status_response(struct pjctl *pjctl, struct queue_command *cmd, char *op, char *param) { - printf("error status: %s\n", param); + int i; + int none = 1; + const char *flags[] = { + "fan", "lamp", "temperature", "cover", "filter", "other" + }; + + printf("errors: "); + if (handle_pjlink_error(param) < 0) + return; + + if (strlen(param) != 6) { + fprintf(stderr, "invalid message received\n"); + return; + } + + for (i = 0; i < ARRAY_SIZE(flags); ++i) { + switch (param[i]) { + case '2': + printf("%s:error ", flags[i]); + none = 0; + break; + case '1': + printf("%s:warning ", flags[i]); + none = 0; + break; + case '0': + break; + default: + fprintf(stderr, "invalid message received\n"); + return; + } + } + if (none) + fputs("none", stdout); + fputs("\n", stdout); } static void -- cgit