ret = HPCS_E_PARSE_ERROR;
goto out;
}
+ PR_DEBUGF("Signal step: %g, shift: %g\n", signal_step, signal_shift);
pret = read_scans_start(datafile, &scans_start);
if (pret != PARSE_OK) {
PR_DEBUGF("Error reading stream, r=%lu\n", r);
return PARSE_E_CANT_READ;
}
- segments_read++;
/* Expand storage if there is more data than we can store */
if (alloc_size == data_segments_read) {
dret = check_for_marker(raw, &next_marker_idx);
switch (dret) {
case DCHECK_GOT_MARKER:
- PR_DEBUGF("Got marker at 0x%lx\n", segments_read - 1);
+ PR_DEBUGF("Got marker at segment %lu, byte 0x%lx\n", segments_read, 2 * segments_read);
continue;
case DCHECK_NO_MARKER:
+#ifndef NDEBUG
+ if (segments_read == next_marker_idx)
+ PR_DEBUGF("Warning - marker expected but not found at segment %lu", segments_read);
+#endif
/* Check for a sudden jump of value */
if (raw[0] == BIN_MARKER_JUMP && raw[1] == BIN_MARKER_END) {
char lraw[4];
}
(*pairs)[data_segments_read].value = value;
+ segments_read++;
data_segments_read++;
break;
default:
#include <string.h>
#include <libHPCS.h>
-static int read_data(const char* path)
+static int read_data(const char* path, int raw_output)
{
struct HPCS_MeasuredData* mdata;
enum HPCS_RetCode hret;
mdata->y_units,
mdata->sampling_rate);
- for (di = 0; di < mdata->data_count; di++)
- printf("Time: %.17lg, Value: %.17lg\n", mdata->data[di].time, mdata->data[di].value);
+ for (di = 0; di < mdata->data_count; di++) {
+ if (raw_output)
+ printf("%.17lg; %.17lg\n", mdata->data[di].time, mdata->data[di].value);
+ else
+ printf("Time: %.17lg; Value: %.17lg\n", mdata->data[di].time, mdata->data[di].value);
+ }
hpcs_free_mdata(mdata);
int main(int argc, char** argv)
{
+ const char* sel;
+
if (argc < 3) {
printf("Not enough arguments\n");
printf("Usage: test_tool MODE FILE\n");
printf("MODE: d - read data file\n"
+ " r - read data file - raw output\n"
" i - method info\n"
" h - read header only\n"
"FILE: path\n");
return EXIT_FAILURE;
}
- if (strcmp(argv[1], "d") == 0)
- return read_data(argv[2]);
- else if (strcmp(argv[1], "h") == 0)
+ sel = argv[1];
+
+ if (strcmp(sel, "d") == 0 || strcmp(sel, "r") == 0)
+ return read_data(argv[2], strcmp(sel, "r") == 0);
+ else if (strcmp(sel, "h") == 0)
return read_header(argv[2]);
- else if (strcmp(argv[1], "i") == 0)
+ else if (strcmp(sel, "i") == 0)
return read_info(argv[2]);
else {
printf("Invalid mode argument\n");