Commit 847f1981 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

make trace_view a bit more usable

parent 362d549c
......@@ -69,17 +69,22 @@ void handle_val(struct trace * trace, float val, time_t seconds, int sample)
freopen(NULL, "w", trace->fdtmp);
for (i = trace->bufpos + 1; i < VAL_BUFLEN; i++) {
if (isnan(trace->val_buffer[i]))
continue;
fprintf(trace->fdtmp, "%f %e\n",
(double)(i - trace->bufpos - VAL_BUFLEN)* step +
trace->bufpos_time - starttime,
trace->val_buffer[i]);
}
for (i = 0; i <= trace->bufpos; i++) {
if (isnan(trace->val_buffer[i]))
continue;
fprintf(trace->fdtmp, "%f %e\n",
(double)(i - trace->bufpos) * step + trace->bufpos_time
- starttime,
trace->val_buffer[i]);
}
fflush(trace->fdtmp);
trace->bufpos++;
if (trace->bufpos == VAL_BUFLEN)
trace->bufpos = 0;
......@@ -102,6 +107,8 @@ int open_trace(struct trace *trace, char *tracename)
memset(trace, 0, sizeof(struct trace));
memset(trace->val_buffer, 0xff, sizeof(float)*VAL_BUFLEN);
trace->fd = tcp_connect("localhost", 10000);
if (trace->fd < 0) {
return 1;
......@@ -147,7 +154,7 @@ int open_trace(struct trace *trace, char *tracename)
f32.u = ntohl(*buffer.val32);
period = f32.f;
if (period < 0.1)
interval = (0.1 / period);
interval = (0.2 / period);
else
interval = 1;
unit = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment