VCD/Gnuplot: Store time/date in output.

This commit is contained in:
Uwe Hermann 2010-05-09 14:54:16 +02:00
parent 607b58de58
commit 5cca9adbf2
2 changed files with 9 additions and 4 deletions

View File

@ -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. */

View File

@ -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. */