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: 0530460959b5
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e87d335e7ea9
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Feb 14, 2020

  1. Copy the full SHA
    e87d335 View commit details
Showing with 38 additions and 12 deletions.
  1. +38 −12 scopehal/LeCroyOscilloscope.cpp
50 changes: 38 additions & 12 deletions scopehal/LeCroyOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
#include "LeCroyOscilloscope.h"
#include "ProtocolDecoder.h"
#include "base64.h"
#include <locale>

using namespace std;

@@ -1005,22 +1006,47 @@ bool LeCroyOscilloscope::AcquireData(bool toQueue)
if(h_off_frac < 0)
h_off_frac = interval + h_off_frac; //double h_unit = *reinterpret_cast<double*>(pdesc + 244);

//Timestamp is a somewhat complex format that needs some shuffling around.
/*
Timestamp is a somewhat complex format that needs some shuffling around.
Timestamp starts at offset 296 bytes in the wavedesc
(296-303) double seconds
(304) byte minutes
(305) byte hours
(306) byte days
(307) byte months
(308-309) uint16 year
*/
double fseconds = *reinterpret_cast<double*>(pdesc + 296);
uint8_t seconds = floor(fseconds);
double basetime = fseconds - seconds;

//TODO: during startup, query instrument for its current time zone
//since the wavedesc reports instment local time

//Get the current time
time_t tnow = time(NULL);
struct tm* now = localtime(&tnow);
struct tm tstruc;
tstruc.tm_sec = seconds;
tstruc.tm_min = pdesc[304];
tstruc.tm_hour = pdesc[305];
tstruc.tm_mday = pdesc[306];
tstruc.tm_mon = pdesc[307];
tstruc.tm_year = *reinterpret_cast<uint16_t*>(pdesc+308);
tstruc.tm_wday = now->tm_wday;
tstruc.tm_yday = now->tm_yday;
tstruc.tm_isdst = now->tm_isdst;
localtime_r(&tnow, &tstruc);

//Convert the instrument time to a string, then back to a tm
//Is there a better way to do this???
//Naively poking "struct tm" fields gives incorrect results (scopehal-apps:#52)
//Maybe because tm_yday is inconsistent?
char tblock[64] = {0};
snprintf(tblock, sizeof(tblock), "%d-%d-%d %d:%02d:%02d",
*reinterpret_cast<uint16_t*>(pdesc+308),
pdesc[307],
pdesc[306],
pdesc[305],
pdesc[304],
seconds);
locale cur_locale;
auto& tget = use_facet< time_get<char> >(cur_locale);
istringstream stream(tblock);
ios::iostate state;
char format[] = "%F %T";
tget.get(stream, time_get<char>::iter_type(), stream, state, &tstruc, format, format+strlen(format));
time_t ttime = mktime(&tstruc);

//Read the actual waveform data
string data;
@@ -1047,7 +1073,7 @@ bool LeCroyOscilloscope::AcquireData(bool toQueue)
cap->m_timescale = round(interval);

cap->m_triggerPhase = h_off_frac;
cap->m_startTimestamp = mktime(&tstruc);
cap->m_startTimestamp = ttime;

//Parse the time
if(num_sequences > 1)