aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2012-10-19 10:31:19 +0800
committerAndy Green <andy.green@linaro.org>2012-10-19 10:31:19 +0800
commit720af6d8105b3bc243e5b5dcbf168305945350c6 (patch)
treef11c0bf4adc97779f20ed4d5c86a6152fb9640d6
parent34fd0997aedbbab319fba334a19a6e669fc45f13 (diff)
clean out debugging noise
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r--aepd/websocket-protocol.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/aepd/websocket-protocol.c b/aepd/websocket-protocol.c
index ad91c79..673c66e 100644
--- a/aepd/websocket-protocol.c
+++ b/aepd/websocket-protocol.c
@@ -132,7 +132,12 @@ callback_linaro_aepd(struct libwebsocket_context *context,
gettimeofday(&tv, NULL);
ms10 = (tv.tv_sec * 10) + (tv.tv_usec / 100000);
- if (ms10 != pss->ms10_last_caliper && pss->caliper_offset[0] >= 0 && aepd_shared->chans) {
+ /*
+ * is it time to do a caliper update?
+ */
+
+ if (ms10 != pss->ms10_last_caliper && pss->caliper_offset[0] >= 0 &&
+ aepd_shared->chans) {
pss->ms10_last_caliper = ms10;
l = pss->ringbuffer_tail - pss->caliper_offset[0];
@@ -140,20 +145,21 @@ callback_linaro_aepd(struct libwebsocket_context *context,
l += aepd_shared->modulo_integer_chan_size;
if (lseek(aepd_shared->fd_fifo_read, l, SEEK_SET) < 0)
fprintf(stderr, "seek %ld failed\n", l);
- if (read(aepd_shared->fd_fifo_read, &sam[0], aepd_shared->chans * sizeof(double) * 3) < 0)
- fprintf(stderr, "fifo read %ld failed\n", l);
+ if (read(aepd_shared->fd_fifo_read, &sam[0],
+ aepd_shared->chans * sizeof(double) * 3) < 0)
+ fprintf(stderr, "fifo read %ld failed\n", l);
l = pss->ringbuffer_tail - pss->caliper_offset[1];
while (l < 0)
l += aepd_shared->modulo_integer_chan_size;
if (lseek(aepd_shared->fd_fifo_read, l, SEEK_SET) < 0)
fprintf(stderr, "seek %ld failed\n", l);
- if (read(aepd_shared->fd_fifo_read, &sam2[0], aepd_shared->chans * sizeof(double) * 3) < 0)
- fprintf(stderr, "fifo read %ld fail\n", l);
-
- extent = (pss->caliper_offset[1] - pss->caliper_offset[0]) / (aepd_shared->chans * sizeof(double) * 3);
+ if (read(aepd_shared->fd_fifo_read, &sam2[0],
+ aepd_shared->chans * sizeof(double) * 3) < 0)
+ fprintf(stderr, "fifo read %ld fail\n", l);
-// fprintf(stderr, "calp %ld %ld %ld\n", extent, pss->caliper_offset[0], pss->caliper_offset[1]);
+ extent = (pss->caliper_offset[1] - pss->caliper_offset[0]) /
+ (aepd_shared->chans * sizeof(double) * 3);
*p++ = 'c';
m = 0;
@@ -173,10 +179,13 @@ callback_linaro_aepd(struct libwebsocket_context *context,
}
*p = '\0';
-// puts(&buf[LWS_SEND_BUFFER_PRE_PADDING]);
goto send;
}
+ /*
+ * do we need to isse a sync timestamp?
+ */
+
if (pss->issue_timestamp && aepd_shared->chans) {
pss->issue_timestamp = 0;
@@ -195,12 +204,13 @@ callback_linaro_aepd(struct libwebsocket_context *context,
extent /= aepd_shared->chans * sizeof(double) * 3;
p += sprintf(p, "t%f %d", aepd_shared->fifo_head_time - ((double)extent * 0.0001), aepd_shared->stop_flag ^ 1);
- fprintf(stderr, "timestamp headtime=%f aepd_shared->fifo_pos=%ld extent=%ld, l=%ld\n",
- aepd_shared->fifo_head_time, aepd_shared->fifo_pos, extent, l);
- puts(&buf[LWS_SEND_BUFFER_PRE_PADDING]);
goto send;
}
+ /*
+ * do we need to dump channel info?
+ */
+
if (!pss->channels_sent_flag && aepd_shared->chans) {
/* signal it's a message with channel names */
@@ -227,13 +237,12 @@ callback_linaro_aepd(struct libwebsocket_context *context,
*/
if (pss->viewport_offset_time < -0.00009)
- if (!pss->viewport_budget) {
-// fprintf(stderr, "bailing %f\n", pss->viewport_offset_time);
+ if (!pss->viewport_budget)
break;
- }
/*
- * aggregate up to 'budget' results in one websocket message
+ * if we didn't have to do any of the other tasks,
+ * aggregate up to 'budget' pending results in one websocket message
*/
if (!pss->seen_rate || !aepd_shared->chans)
@@ -257,7 +266,6 @@ callback_linaro_aepd(struct libwebsocket_context *context,
for (n = 0; n < aepd_shared->chans * 3; n++)
sam[n] = pss->sam[n];
} else {
-
lseek(aepd_shared->fd_fifo_read, pss->ringbuffer_tail, SEEK_SET);
if (read(aepd_shared->fd_fifo_read, &sam[0], aepd_shared->chans * sizeof(double) * 3) < 0)
fprintf(stderr, "fifo read fail\n");
@@ -266,10 +274,8 @@ callback_linaro_aepd(struct libwebsocket_context *context,
if (pss->viewport_budget)
pss->viewport_budget--;
else
- if (pss->viewport_offset_time < -0.00009) {
-// fprintf(stderr, "bail2: %f\n", pss->viewport_offset_time);
+ if (pss->viewport_offset_time < -0.00009)
goto send;
- }
pss->ringbuffer_tail += (pss->stride * aepd_shared->chans * sizeof(double) * 3 );
if (pss->ringbuffer_tail > (long)aepd_shared->modulo_integer_chan_size)
@@ -334,7 +340,6 @@ send:
switch (*(char *)in) {
case 'c': /* calipers changed */
-// puts((char *)in + 1);
if (sscanf(((char *)in) + 1, "%lf %lf\n", &d[0], &d[1]) == 2) {
if (d[0] > d[1]) {
d[2] = d[1];
@@ -349,24 +354,20 @@ send:
for (n = 0; n < 2; n++)
pss->caliper_offset[n] = (d[n] * 10000 * aepd_shared->chans * sizeof(double) * 3);
-// fprintf(stderr, " %ld %ld\n", pss->caliper_offset[0], pss->caliper_offset[1]);
} else
fprintf(stderr, "caliper sscanf failed\n");
break;
case 'r': /* rate or other change */
-// puts((char *)in + 1);
if (sscanf(((char *)in) + 1, "%lf %lf %lf %lf\n", &d[0], &d[1], &d[2], &d[3]) == 4) {
pss->stride = (int)d[0];
pss->viewport_offset_time = d[3];
-// fprintf(stderr, "d[0] = %f, d[1] = %f, d[2] = %f\n", d[0], d[1], d[2]);
l = aepd_shared->fifo_pos - ((int)d[1] * pss->stride * aepd_shared->chans * sizeof(double) * 3);
l += (int)((pss->viewport_offset_time / 0.0001)) * aepd_shared->chans * sizeof(double) * 3;
if (pss->viewport_offset_time)
pss->viewport_budget = d[1];
pss->ringbuffer_tail = l;
-// fprintf(stderr, " setting pss->ringbuffer_tail = %ld, aepd_shared->fifo_pos=%ld, d[1]=%f\n", pss->ringbuffer_tail, aepd_shared->fifo_pos, d[1]);
aepd_shared->stop_flag = ((int)d[2]) ^ 1;
pss->issue_timestamp = 1;
pss->seen_rate = 1;