diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-15 14:28:17 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-11-15 14:28:58 +0100 |
commit | 9b5b8e03c99335b1e4a2bc37cf0197e453728784 (patch) | |
tree | 28ded43cee16028ed64baa60b081f19ec4f9cb02 | |
parent | 4dbf7c113182be27e4bdcacf67847118966298b4 (diff) | |
download | pjctl-9b5b8e03c99335b1e4a2bc37cf0197e453728784.tar.gz pjctl-9b5b8e03c99335b1e4a2bc37cf0197e453728784.tar.bz2 pjctl-9b5b8e03c99335b1e4a2bc37cf0197e453728784.zip |
Implement interpreted error status response
-rw-r--r-- | src/pjctl.c | 36 |
1 files changed, 35 insertions, 1 deletions
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 |