Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CRC16 FreescaleIAP FreescaleWatchdog GGSProtocol LM75B PIMA Parameters PersistentCircularQueue SerialNumberV2COM mbed-dev-watchdog_2016_03_04
Fork of smartRamalKW by
Diff: cmd/lerAlarmes.cpp
- Revision:
- 13:eed9484a89bc
diff -r 0f549dfba86c -r eed9484a89bc cmd/lerAlarmes.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmd/lerAlarmes.cpp Tue Jul 28 17:56:11 2015 +0000 @@ -0,0 +1,41 @@ +#include "appCommands.h" +#include "alarm.h" + +#define ALARMES_FALHA 1 +#define ALARMES_FIM 2 + +extern Alarm alarm; +char* respAlarm; + +void cmdLerAlarmes(int block){ + if(block == 0){ + free(respAlarm); + respAlarm = alarm.getAllAlarms(); + } + + if(respAlarm == NULL){ + exec.enviaResposta(RESP_LER_ALARMES, ALARMES_FALHA); + } else{ + int alarmSize = APP_PARAMETERS.ALARMS_QUEUE_SIZE; + if(alarmSize < 0 || alarmSize > 127){ + alarmSize = 100; // Use default + } + int blocks = ceil(alarmSize / 25.0); + if(blocks < 0 || blocks > 6){ + blocks = 4; // Use default of 100 entries + } + if(block >= blocks){ + exec.enviaResposta(RESP_LER_ALARMES, ALARMES_FIM); + free(respAlarm); + } else{ + int size = 8*25; + if(block == blocks-1){ + size = 8*(APP_PARAMETERS.ALARMS_QUEUE_SIZE % 25); + if(size == 0){ + size = 8*25; + } + } + exec.enviaResposta(RESP_LER_ALARMES, respAlarm+block*8*25, size); + } + } +}