diff --git a/src/periph/fpga.cpp b/src/periph/fpga.cpp index ff3769e784227eacd0d6b7442707ebb597e6d88b..d254619054d3e82a5592f72ef21f666de8bf44d5 100644 --- a/src/periph/fpga.cpp +++ b/src/periph/fpga.cpp @@ -225,7 +225,7 @@ uint32_t Periph_fpga::shift_mask(const string addr_str, uint32_t data) */ bool Periph_fpga::read_system_info(TermOutput& termout) { - cout << "node " << GlobalNr << " read system info" << endl; + // cout << "node " << GlobalNr << " read system info" << endl; uint32_t data; bool retval = Read("mm/0/PIO_SYSTEM_INFO/0/info", &data); if (retval == false) { @@ -236,7 +236,7 @@ bool Periph_fpga::read_system_info(TermOutput& termout) // string design_name = read_design_name(); my_current_design_name = read_design_name(); - cout << "node " << GlobalNr << " design_name=" << my_current_design_name << endl; + cout << "node " << GlobalNr << " design_name= " << my_current_design_name << endl; // FIXME: get rid of magic constants in masks, should be in CCFG: uint firmware_version = (data & 0x00F00000) >> 20; @@ -587,7 +587,8 @@ bool Periph_fpga::monitor(TermOutput& termout) if (!Enabled) { return false; } // use tictoc, tic(start) toc(stop) to see how long this function takes // first 9 read functions on 4 nodes will take 6 msec. - tictoc.tic("periph.fpga.monitor"); + string name = "periph.fpga.monitor node " + to_string(GlobalNr); + tictoc.tic(name.c_str()); read_system_info(termout); if (Online) { read_time_since_last_pps(termout, REG_FORMAT_INT64, R_UCP); diff --git a/src/sdptr.cpp b/src/sdptr.cpp index 7fffbe4e8dad998d487f4b21ee751b11922dcabb..8357050624a378a51c520caa520653b3f0e8bdbb 100644 --- a/src/sdptr.cpp +++ b/src/sdptr.cpp @@ -63,6 +63,9 @@ void monitor() string cmdname = ""; TermOutput termout; struct timeval current_time; + time_t secs; + struct tm * now; + char time_str[50]; SD.timetick = SECONDS_PER_TICK; clock_gettime(CLOCK_REALTIME, (struct timespec *)&SD.t0); @@ -84,10 +87,14 @@ void monitor() gettimeofday(¤t_time, NULL); SD.tod = current_time.tv_sec; - cout << "MONITOR THREAD. now=" << current_time.tv_sec << "." << current_time.tv_usec - << " uptime=" << SD.uptime << " seconds" << endl; SD.uptime++; + secs = current_time.tv_sec; + now = gmtime(&secs); + sprintf(time_str, "%02d:%02d:%02d.%06ld", now->tm_hour, now->tm_min, now->tm_sec, current_time.tv_usec); + + cout << "[" << time_str << " (UTC)] " << "MONITOR THREAD: uptime=" << SD.uptime << " seconds" << endl; + if (SD.unb != NULL) { // cout << "sdptr_monitor start" << endl; SD.unb->monitor(termout); diff --git a/src/tools/util.cpp b/src/tools/util.cpp index a56aae66d4fa4569a16cffd1d621ae04bca45f52..baca093aa5abbb210b1be0ead2eae2b293e932d1 100644 --- a/src/tools/util.cpp +++ b/src/tools/util.cpp @@ -29,6 +29,8 @@ #include <cmath> #include <iostream> #include <algorithm> +#include <ctime> +#include <sys/time.h> #include "util.h" @@ -97,7 +99,7 @@ vector<uint> unique_and_sort(vector<uint> v) void Tictoc::tic(string idstr) { name = idstr; - cout << "tic: start [" << name << "]" << endl; + // cout << "tic: start [" << name << "]" << endl; c_start = clock(); t_start = chrono::high_resolution_clock::now(); } @@ -106,6 +108,15 @@ void Tictoc::toc(void) { clock_t c_end = clock(); auto t_end = chrono::high_resolution_clock::now(); + + struct timeval tv; + gettimeofday(&tv, NULL); + time_t secs = tv.tv_sec; + struct tm * now = gmtime(&secs); + char time_str[50]; + sprintf(time_str, "%02d:%02d:%02d.%06ld", now->tm_hour, now->tm_min, now->tm_sec, tv.tv_usec); + + cout << "[" << time_str << " (UTC)] "; cout << "toc-tic (" << name << ") CPU time: " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " ms. "; cout << "Real time: " << chrono::duration_cast<chrono::milliseconds>(t_end - t_start).count()