Commit 98c5c7c7 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Various fixes for tracing and command handling.

parent d69c23a4
command_joystick
command_list command_list
command_send command_send
/* /*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2007, 2008, 2011, 2013 Copyright Jeroen Vreeken (jeroen@vreeken.net), 2007, 2008, 2011, 2013, 2015
Copyright Stichting C.A. Muller Radioastronomiestation, 2007, 2008, 2011 Copyright Stichting C.A. Muller Radioastronomiestation, 2007, 2008, 2011
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#include <trace/trace.h> #include <trace/trace.h>
//#define DEBUG_TIMESTAMP
//#define DEBUG_INTERVAL
struct timespec t_int; struct timespec t_int;
char *tracename; char *tracename;
...@@ -35,7 +38,9 @@ static void handler_interval(struct trace *trace, ...@@ -35,7 +38,9 @@ static void handler_interval(struct trace *trace,
struct timespec *interval, enum trace_interval_type type) struct timespec *interval, enum trace_interval_type type)
{ {
memcpy(&t_int, interval, sizeof(struct timespec)); memcpy(&t_int, interval, sizeof(struct timespec));
#ifdef DEBUG_INTERVAL
printf("interval: %ld.%09ld\n", interval->tv_sec, interval->tv_nsec); printf("interval: %ld.%09ld\n", interval->tv_sec, interval->tv_nsec);
#endif
} }
int cnt =0; int cnt =0;
...@@ -43,7 +48,9 @@ int cnt =0; ...@@ -43,7 +48,9 @@ int cnt =0;
static void handler_timestamp(struct trace *trace, static void handler_timestamp(struct trace *trace,
struct timespec *t) struct timespec *t)
{ {
#ifdef DEBUG_TIMESTAMP
printf("timestamp: %ld.%09ld, cnt=%d\n", t->tv_sec, t->tv_nsec, cnt); printf("timestamp: %ld.%09ld, cnt=%d\n", t->tv_sec, t->tv_nsec, cnt);
#endif
cnt = 0; cnt = 0;
} }
...@@ -170,6 +177,8 @@ int main(int argc, char **argv) ...@@ -170,6 +177,8 @@ int main(int argc, char **argv)
trace_packet_put(pkt); trace_packet_put(pkt);
} }
trace_autorecover(trace, true);
printf("Wait for data\n"); printf("Wait for data\n");
while (trace_state_get(trace) == TRACE_STATE_RECEIVING || while (trace_state_get(trace) == TRACE_STATE_RECEIVING ||
......
...@@ -475,11 +475,11 @@ static void start_trace(struct libwebsocket *wsi, int freq, char *variable) ...@@ -475,11 +475,11 @@ static void start_trace(struct libwebsocket *wsi, int freq, char *variable)
if (freq) { if (freq) {
uint64_t nsec; uint64_t nsec;
nsec = 1000000000 / freq; nsec = 1000000000ull / freq;
type = TRACE_INTERVAL_TYPE_INTERVAL; type = TRACE_INTERVAL_TYPE_INTERVAL;
t_int.tv_sec = nsec / 1000000000; t_int.tv_sec = nsec / 1000000000ull;
t_int.tv_nsec = nsec - t_int.tv_sec * 1000000000; t_int.tv_nsec = nsec - (uint64_t)t_int.tv_sec * 1000000000ull;
t_int.tv_sec = 0; t_int.tv_sec = 0;
t_int.tv_nsec = 500000000; t_int.tv_nsec = 500000000;
......
...@@ -383,7 +383,10 @@ int main (int argc, char **argv) ...@@ -383,7 +383,10 @@ int main (int argc, char **argv)
try_command(client->command); try_command(client->command);
} }
} }
for (i = 0; i < spgs_nr; i++) {
command_fd_set(spgs[i].spg_cmd, &fd_rd, &high);
}
select(high + 1, &fd_rd, NULL, NULL, &timeout); select(high + 1, &fd_rd, NULL, NULL, &timeout);
if (FD_ISSET(fd_listen, &fd_rd)) { if (FD_ISSET(fd_listen, &fd_rd)) {
...@@ -394,6 +397,10 @@ int main (int argc, char **argv) ...@@ -394,6 +397,10 @@ int main (int argc, char **argv)
command_server_fdset_handle(offset_srv, &fd_rd); command_server_fdset_handle(offset_srv, &fd_rd);
command_server_fdset_handle(console_srv, &fd_rd); command_server_fdset_handle(console_srv, &fd_rd);
for (i = 0; i < spgs_nr; i++) {
command_handle(spgs[i].spg_cmd, &fd_rd);
}
for (client = clients, clientp = &clients; client; client = *clientp) { for (client = clients, clientp = &clients; client; client = *clientp) {
if (!client->pending) if (!client->pending)
command_handle(client->command, &fd_rd); command_handle(client->command, &fd_rd);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <utils/dt_host.h> #include <utils/dt_host.h>
#include <trace/trace.h> #include <trace/trace.h>
#include <log/log.h>
#include <utils/tcp_listen.h> #include <utils/tcp_listen.h>
#include <stdio.h> #include <stdio.h>
...@@ -63,9 +64,9 @@ static void common_denom(struct timespec *common, struct timespec *int1, struct ...@@ -63,9 +64,9 @@ static void common_denom(struct timespec *common, struct timespec *int1, struct
uint64_t d1, d2; uint64_t d1, d2;
uint64_t inew; uint64_t inew;
i1 = int1->tv_sec * 1000000000 + int1->tv_nsec; i1 = (uint64_t)int1->tv_sec * 1000000000ull + (uint64_t)int1->tv_nsec;
i2 = int2->tv_sec * 1000000000 + int2->tv_nsec; i2 = (uint64_t)int2->tv_sec * 1000000000ull + (uint64_t)int2->tv_nsec;
b = base_interval.tv_sec * 1000000000 + base_interval.tv_nsec; b = (uint64_t)base_interval.tv_sec * 1000000000ull + (uint64_t)base_interval.tv_nsec;
if (!b) { if (!b) {
memcpy(common, int1, sizeof(struct timespec)); memcpy(common, int1, sizeof(struct timespec));
return; return;
...@@ -73,7 +74,7 @@ static void common_denom(struct timespec *common, struct timespec *int1, struct ...@@ -73,7 +74,7 @@ static void common_denom(struct timespec *common, struct timespec *int1, struct
d1 = i1 / b; d1 = i1 / b;
d2 = i2 / b; d2 = i2 / b;
if (d1 == d2) { if (d1 == d2) {
inew = d1; inew = d1;
} else if (d2 && d1 > d2 && !(d1 % d2)) { } else if (d2 && d1 > d2 && !(d1 % d2)) {
...@@ -90,9 +91,8 @@ static void common_denom(struct timespec *common, struct timespec *int1, struct ...@@ -90,9 +91,8 @@ static void common_denom(struct timespec *common, struct timespec *int1, struct
} }
common->tv_sec = base_interval.tv_sec * inew; common->tv_sec = base_interval.tv_sec * inew;
common->tv_nsec = base_interval.tv_nsec * inew; common->tv_nsec = ((uint64_t)base_interval.tv_nsec * inew) % 1000000000ull;
common->tv_sec += common->tv_nsec / 1000000000; common->tv_sec += ((uint64_t)base_interval.tv_nsec * inew) / 1000000000ull;
common->tv_nsec %= 1000000000;
} }
static void server_interval_check(struct trace *server) static void server_interval_check(struct trace *server)
...@@ -145,7 +145,6 @@ static void server_interval_check(struct trace *server) ...@@ -145,7 +145,6 @@ static void server_interval_check(struct trace *server)
if ((server->interval_type != type) || if ((server->interval_type != type) ||
(server->interval.tv_sec != interval.tv_sec) || (server->interval.tv_sec != interval.tv_sec) ||
(server->interval.tv_nsec != interval.tv_nsec)) { (server->interval.tv_nsec != interval.tv_nsec)) {
struct trace_pkt *pkt;
printf("Changing server trace %s from %ld.%09ld, %d to %ld.%09ld, %d\n", printf("Changing server trace %s from %ld.%09ld, %d to %ld.%09ld, %d\n",
server->name, server->name,
...@@ -153,11 +152,7 @@ static void server_interval_check(struct trace *server) ...@@ -153,11 +152,7 @@ static void server_interval_check(struct trace *server)
server->interval_type, server->interval_type,
interval.tv_sec, interval.tv_nsec, type); interval.tv_sec, interval.tv_nsec, type);
pkt = trace_packet_new(); trace_interval_set(server, &interval, type);
trace_packet_interval_set(pkt,
&interval, type);
trace_packet_write(server, pkt);
trace_packet_put(pkt);
} }
} }
...@@ -516,7 +511,10 @@ int main (int argc, char **argv) ...@@ -516,7 +511,10 @@ int main (int argc, char **argv)
fd_set fd_rd; fd_set fd_rd;
struct trace *list; struct trace *list;
int high, i, j; int high, i, j;
log_client_start(dt_host_console(), CONSOLE_LOG_PORT_IN,
LOG_T_DEBUG, LOG_T_INFO, "trace_proxy");
fd_listen = tcp_listen(CONSOLE_TRACE_PORT, 0, 100); fd_listen = tcp_listen(CONSOLE_TRACE_PORT, 0, 100);
if (fd_listen < 0) { if (fd_listen < 0) {
printf("Could not open listen port %d\n", CONSOLE_TRACE_PORT); printf("Could not open listen port %d\n", CONSOLE_TRACE_PORT);
......
...@@ -538,6 +538,34 @@ dt_ui_text.prototype.oninput_set = function(func) ...@@ -538,6 +538,34 @@ dt_ui_text.prototype.oninput_set = function(func)
this.element.oninput = func; this.element.oninput = func;
} }
function dt_ui_range(elementid)
{
this.element = document.createElement("input");
this.element.type = "range";
this.element.id = elementid;
dt_ui_element.call(this, elementid);
this.element.max = 100;
this.element.min = 0;
this.element.defaultValue = 0;
}
dt_ui_range.prototype = new dt_ui_element();
dt_ui_range.prototype.min_set = function(min)
{
this.element.min = min;
}
dt_ui_range.prototype.max_set = function(max)
{
this.element.max = max;
}
dt_ui_range.prototype.default_set = function(val)
{
this.element.defaultValue = val;
}
dt_ui_range.prototype.value_get = function()
{
return this.element.value;
}
function dt_ui_textarea(elementid) function dt_ui_textarea(elementid)
{ {
......
...@@ -102,7 +102,6 @@ static void pid_aw_calculate(struct controller_block *pid) ...@@ -102,7 +102,6 @@ static void pid_aw_calculate(struct controller_block *pid)
outp = 0; outp = 0;
outi = 0; outi = 0;
outd = 0; outd = 0;
priv->previous = 0;
} }
priv->outp = outp; priv->outp = outp;
......
Supports Markdown
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