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
Diff: src/main.cpp
- Revision:
- 103:109fba818301
- Parent:
- 101:8a25782572a3
- Child:
- 109:bb4ef6a4bd0a
--- a/src/main.cpp Wed Sep 21 22:12:00 2016 +0000
+++ b/src/main.cpp Thu Sep 22 11:59:14 2016 +0000
@@ -1,7 +1,7 @@
/******************************************************************************
*
* File: main.cpp
- * Desciption: Ground Zero
+ * Desciption: Ground Zero
*
*****************************************************************************/
#include "mbed.h"
@@ -22,7 +22,7 @@
// main thread identifier (for signaling)
osThreadId mainThreadId = NULL;
-// bootup sequence signals
+// bootup sequence signals
int sig_output_continue = 0x1;
int sig_config_continue = 0x2;
@@ -54,6 +54,36 @@
I2C* i2c;
/*****************************************************************************
+ * Function: timestamp_boot_record()
+ * Description: timestamp the boot record with current time
+ *
+ * @param none
+ * @return none
+ *****************************************************************************/
+static void timestamp_boot_record(void)
+{
+ char time_string[1024];
+ time_t curr_sec;
+ struct tm *ts;
+
+ curr_sec = time(0);
+ ts = localtime(&curr_sec);
+ strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", ts);
+
+ // see if we can open the boot record
+ mDot::mdot_file file = GLOBAL_mdot->openUserFile("boot.time", mDot::FM_RDWR);
+ if ( file.fd < 0 ) {
+ file = GLOBAL_mdot->openUserFile("boot.time", mDot::FM_CREAT|mDot::FM_RDWR);
+ GLOBAL_mdot->writeUserFile(file, time_string, sizeof(time_string));
+ } else {
+ GLOBAL_mdot->seekUserFile(file, 0, SEEK_CUR);
+ GLOBAL_mdot->writeUserFile(file, time_string, sizeof(time_string));
+ }
+ GLOBAL_mdot->closeUserFile(file);
+ return;
+}
+
+/*****************************************************************************
* Function: banner()
* Description: Display the application boot banner
*
@@ -116,21 +146,22 @@
curr_sec = mktime( &rtc_time );
set_time(curr_sec);
+ timestamp_boot_record();
// for signaling from the configuration handler
mainThreadId = osThreadGetId();
banner();
-
- // start the output task
+
+ // start the output task
Thread outputTask_thread(OutputTask, NULL, osPriorityNormal, (1024*8), NULL);
osSignalWait(sig_output_continue, osWaitForever);
-
+
// start the configuration handler
Thread configHandler_thread(ConfigurationHandler, NULL, osPriorityNormal, (1024*3), NULL);
osSignalWait(sig_config_continue, osWaitForever);
- // we're clear to start running the controls
+ // we're clear to start running the controls
Thread controlTask_thread(ControlTask, NULL, osPriorityNormal, (1024*2), NULL);
//printf("\r%s: continuing to initialize...\n", __func__);
