Skip to content

Commit

Permalink
Check relais number to switch and ignore call when number higher than…
Browse files Browse the repository at this point in the history
… relais count.
  • Loading branch information
breaker27 committed Oct 3, 2014
1 parent 03aaf59 commit 6d7972f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions firmware/shc_powerswitch/shc_powerswitch.c
Expand Up @@ -134,6 +134,12 @@ void switchRelais(int8_t num, bool on, uint16_t timeout, bool dbgmsg)
UART_PUTF3("Switching relais %u to %u with timeout %us.\r\n", num + 1, on, timeout);
}

if (num >= SWITCH_COUNT)
{
UART_PUTF("\r\nRelais number %u > SWITCH_COUNT, ignoring.", num);
return;
}

bool change_state = switch_state[num] != on;
bool change_timeout = switch_timeout[num] != timeout;

Expand Down

0 comments on commit 6d7972f

Please sign in to comment.