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: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
src/AnalyticsLogger/AnalyticsLogger.cpp
- Committer:
- davidjhoward
- Date:
- 2016-09-15
- Revision:
- 61:ae6dd6692c7d
- Parent:
- 60:96e17fb215a6
- Child:
- 68:dbe39d83eb98
File content as of revision 61:ae6dd6692c7d:
/****************************************************************************** * * File: AnalyticsLogger.cpp * Desciption: source for the ICE Analytics Logger * *****************************************************************************/ #include "global.h" #include <stdio.h> #include "AnalyticsLogger.h" #include "eep.h" #include "rtc.h" /***************************************************************************** * Function: AnalyticsLogger * Description: entry point for the Analytics Logger * * @param (IN) args (user-defined arguments) * @return none *****************************************************************************/ void AnalyticsLogger(void const *args) { struct tm *ts; time_t curr_sec; char time_string[80]; int last_min=8; curr_sec = time(0); ts = localtime(&curr_sec); strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", ts); printf("\r\n%s has started at: %s\r\n", __func__, time_string); while ( true ) { osEvent evt = AnalyticsLoggerMailBox.get(5000); if (evt.status == osEventMail) { AnalyticsLoggerReq_t *mail = (AnalyticsLoggerReq_t*)evt.value.p; logInfo("Analytics Logger Mail Received: Timestamp: %s, Entry: %s", mail->timestamp, mail->log_entry); AnalyticsLoggerMailBox.free(mail); break; } curr_sec = time(0); ts = localtime(&curr_sec); // printf("curr_sec=%ld, min=%d (last=%d)\r\n", curr_sec, ts->tm_min, last_min ); if( ((ts->tm_min%15) == 0) && (ts->tm_min != last_min) ) { last_min = ts->tm_min; strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", ts); printf("%s logging at: %s\r\n", __func__, time_string); std::map<std::string, ModbusRegister>::iterator iter; for (iter = ModbusRegisterMap.begin(); iter != ModbusRegisterMap.end(); ++iter) { printf("Logging tag=%s, value=%2.2f", iter->first.c_str(), iter->second.float_value ); } } } }