From 6a27a521f99c7babc9d000465b661f66b54ee101 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Sun, 8 Nov 2020 00:44:09 +0000 Subject: add wait until disarmed --- arm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'arm.c') diff --git a/arm.c b/arm.c index 7cfdd3f..e34115d 100644 --- a/arm.c +++ b/arm.c @@ -122,12 +122,13 @@ static const char *ready_to_str (int i) -int show_state (int fd) +int show_state (int fd, int zone) { int i, l = SIA_MAX_DATA_LENGTH; unsigned char armed[SIA_MAX_DATA_LENGTH]; unsigned char state[SIA_MAX_DATA_LENGTH]; unsigned char ready[SIA_MAX_DATA_LENGTH]; + int s = 0; i = get_thing (fd, "SA", armed); @@ -161,12 +162,19 @@ int show_state (int fd) printf ("%-6s | %-15s | %-15s | %-15s\n", "Zone", "Armed", "State", "Ready"); printf ("-------+-----------------+-----------------+----------------\n"); - for (i = 0; i < l; ++i) + if (zone > 0) { + s = zone; + l = zone + 1; + } + + for (i = s; i < l; ++i) printf ("%6d | %-15s | %-15s | %-15s\n", i + 1, armed_to_str (armed[i]), state_to_str (state[i]), ready_to_str (ready[i])); printf ("\n"); - return armed[0] - '0'; + if (zone < 0) zone = 0; + + return armed[zone] - '0'; } -- cgit v1.2.3