From eeb53c5aa5d635c079c6bd7fb9ad5fa1cfc109c7 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 11 Dec 2015 22:55:40 +0800 Subject: [PATCH] coredevice/comm: compare software and gateware versions. Closes #97 --- artiq/coredevice/comm_generic.py | 8 +++++++- artiq/runtime/session.c | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index a42eeb501..c5ecd4309 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -5,6 +5,7 @@ from enum import Enum from fractions import Fraction from artiq.language import core as core_language +from artiq import __version__ as software_version logger = logging.getLogger(__name__) @@ -223,6 +224,11 @@ class CommGeneric: if runtime_id != b"AROR": raise UnsupportedDevice("Unsupported runtime ID: {}" .format(runtime_id)) + gateware_version = self._read_chunk(self._read_length).decode("utf-8") + if gateware_version != software_version: + logger.warning("Mismatch between gateware (%s) " + "and software (%s) versions", + gateware_version, software_version) def switch_clock(self, external): self._write_header(_H2DMsgType.SWITCH_CLOCK) @@ -236,7 +242,7 @@ class CommGeneric: self._read_header() self._read_expect(_D2HMsgType.LOG_REPLY) - return self._read_chunk(self._read_length).decode('utf-8') + return self._read_chunk(self._read_length).decode("utf-8") def clear_log(self): self._write_empty(_H2DMsgType.LOG_CLEAR) diff --git a/artiq/runtime/session.c b/artiq/runtime/session.c index 7198c6806..0870f34df 100644 --- a/artiq/runtime/session.c +++ b/artiq/runtime/session.c @@ -1,6 +1,7 @@ #include #include #include +#include #include @@ -394,11 +395,17 @@ static int receive_rpc_value(const char **tag, void **slot); static int process_input(void) { switch(buffer_in.header.type) { - case REMOTEMSG_TYPE_IDENT_REQUEST: + case REMOTEMSG_TYPE_IDENT_REQUEST: { + char version[IDENT_SIZE]; + + get_ident(version); + out_packet_start(REMOTEMSG_TYPE_IDENT_REPLY); out_packet_chunk("AROR", 4); + out_packet_chunk(version, strlen(version)); out_packet_finish(); break; + } case REMOTEMSG_TYPE_SWITCH_CLOCK: { int clk = in_packet_int8();