From 5cca9adbf27252349729cdb1e1c6ca0a526561b1 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sun, 9 May 2010 14:54:16 +0200 Subject: [PATCH] VCD/Gnuplot: Store time/date in output. --- output/output_gnuplot.c | 7 +++++-- output/output_vcd.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index 45b7a870..a0d5a8fc 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -34,7 +34,7 @@ struct context { const char *gnuplot_header = "\ # Sample data in space-separated columns format usable by gnuplot\n\ #\n\ -# Generated by: %s on %s\n%s\ +# Generated by: %s on %s%s\ # Timescale: %d %s\n\ # Column assignment:\n%s\n"; @@ -54,6 +54,7 @@ static int init(struct output *o) int b, num_probes; char *c, *samplerate_s; char wbuf[1000], comment[128]; + time_t t; if (!(ctx = calloc(1, sizeof(struct context)))) return SIGROK_ERR_MALLOC; @@ -102,8 +103,10 @@ static int init(struct output *o) /* TODO: date: File or signals? Make y/n configurable. */ /* TODO: Timescale */ + t = time(NULL); b = snprintf(ctx->header, MAX_HEADER_LEN, gnuplot_header, - PACKAGE_STRING, "TODO", comment, 1, "ns", (char *)&wbuf); + PACKAGE_STRING, ctime(&t), comment, 1, "ns", + (char *)&wbuf); /* TODO: Handle snprintf errors. */ diff --git a/output/output_vcd.c b/output/output_vcd.c index fd569e0e..1acf4a7b 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -33,7 +33,7 @@ struct context { }; const char *vcd_header = "\ -$date\n %s\n$end\n\ +$date\n %s$end\n\ $version\n %s\n$end\n%s\ $timescale\n %i %s\n$end\n\ $scope module %s $end\n\ @@ -57,6 +57,7 @@ static int init(struct output *o) int i, b, num_probes; char *c, *samplerate_s; char wbuf[1000], comment[128]; + time_t t; if (!(ctx = calloc(1, sizeof(struct context)))) return SIGROK_ERR_MALLOC; @@ -107,7 +108,8 @@ static int init(struct output *o) } /* TODO: Date: File or signals? Make y/n configurable. */ - b = snprintf(ctx->header, MAX_HEADER_LEN, vcd_header, "TODO: Date", + t = time(NULL); + b = snprintf(ctx->header, MAX_HEADER_LEN, vcd_header, ctime(&t), PACKAGE_STRING, comment, 1, "ns", PACKAGE, (char *)&wbuf); /* TODO: Handle snprintf() errors. */