From e94a9236aa259cd4405e93cd29fa8f37ed3b6fa0 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 15 Feb 2016 03:56:27 +0000 Subject: [PATCH] Add workaround for analyzer core bug (#206). --- artiq/runtime/rtio.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/artiq/runtime/rtio.c b/artiq/runtime/rtio.c index 76514d19a..36d4927ee 100644 --- a/artiq/runtime/rtio.c +++ b/artiq/runtime/rtio.c @@ -50,12 +50,13 @@ void rtio_log_va(long long int timestamp, const char *fmt, va_list args) rtio_chan_sel_write(CONFIG_RTIO_LOG_CHANNEL); rtio_o_timestamp_write(timestamp); - int i = 0; + int i = 0, j = 0; unsigned int word = 0; while(1) { word <<= 8; word |= *buf & 0xff; if(*buf == 0) { + j++; rtio_o_data_write(word); rtio_o_we_write(1); break; @@ -63,12 +64,23 @@ void rtio_log_va(long long int timestamp, const char *fmt, va_list args) buf++; i++; if(i == 4) { + j++; rtio_o_data_write(word); rtio_o_we_write(1); word = 0; i = 0; } } + + if(j % 2 == 1) { + // https://github.com/m-labs/artiq/issues/206#issuecomment-167347507 + // Note: due to a bug in the analyzer core, for now make sure that all runs + // produce an even number of analyzer messages. As far as the log is concerned, + // an analyzer message contains 4 characters of payload, the terminal 0 counts + // as one, and the payload of one log entry is padded to a message boundary. + rtio_o_data_write(0); + rtio_o_we_write(1); + } } void rtio_log(long long int timestamp, const char *fmt, ...)