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-22
- Revision:
- 116:7337ed514891
- Parent:
- 79:d6638c01eeec
- Child:
- 125:f11cc566d073
File content as of revision 116:7337ed514891:
/******************************************************************************
*
* 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 ) {
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);
logInfo("%s logging at: %s\r\n", __func__, time_string);
std::map<std::string, ModbusRegister>::iterator iter;
for (iter = ModbusRegisterMap.begin(); iter != ModbusRegisterMap.end(); ++iter) {
logInfo("Logging tag=%s, value=%2.2f\r\n", iter->first.c_str(), iter->second.float_value );
}
}
Thread::wait(5000);
}
}
bool AnalyticsLoggerApi( std::string *log_string )
{
logInfo("%s:%d Sending Mail To AnalyticsLoggerMailbox", __func__, __LINE__);
AnalyticsLoggerReq_t *mail = AnalyticsLoggerMailBox.alloc();
strncpy( mail->log_entry, log_string->c_str(), (sizeof(mail->log_entry)-1));
AnalyticsLoggerMailBox.put(mail);
return true;
}
