Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 524f9ecd9401
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a62b0be22b18
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on May 18, 2021

  1. WAV files, and CSV without a time header, now use file mod time as th…

    …e waveform timestamp in history. Fixes #426.
    azonenberg committed May 18, 2021
    Copy the full SHA
    a62b0be View commit details
Showing with 26 additions and 2 deletions.
  1. +26 −2 scopehal/MockOscilloscope.cpp
28 changes: 26 additions & 2 deletions scopehal/MockOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -377,6 +377,17 @@ bool MockOscilloscope::LoadCSV(const string& path)
time_t timestamp = 0;
int64_t fs = 0;

//Get timestamp of the file if no header timestamp
//TODO: Add Windows equivalent
#ifndef _WIN32
struct stat st;
if(0 == stat(path.c_str(), &st))
{
timestamp = st.st_mtim.tv_sec;
fs = st.st_mtim.tv_nsec * 1000L * 1000L;
}
#endif

char line[1024];
size_t nrow = 0;
size_t ncols = 0;
@@ -961,6 +972,19 @@ bool MockOscilloscope::LoadWAV(const string& path)
fseek(fp, header[1], SEEK_CUR);
}

//Get timestamp of the file if no header timestamp
//TODO: Add Windows equivalent
int64_t timestamp = 0;
int64_t fs = 0;
#ifndef _WIN32
struct stat st;
if(0 == stat(path.c_str(), &st))
{
timestamp = st.st_mtim.tv_sec;
fs = st.st_mtim.tv_nsec * 1000L * 1000L;
}
#endif

//Create our channels
size_t datalen = header[1];
size_t bytes_per_sample = nbits / 8;
@@ -989,8 +1013,8 @@ bool MockOscilloscope::LoadWAV(const string& path)
//Create new waveform for channel
auto wfm = new AnalogWaveform;
wfm->m_timescale = interval;
wfm->m_startTimestamp = 0; //TODO: use WAV file mod time
wfm->m_startFemtoseconds = 0;
wfm->m_startTimestamp = timestamp;
wfm->m_startFemtoseconds = fs;
wfm->m_triggerPhase = 0;
wfm->m_densePacked = true;
wfm->Resize(nsamples);