diff --git a/artiq/coredevice/comm_generic.py b/artiq/coredevice/comm_generic.py index b1967b352..a42eeb501 100644 --- a/artiq/coredevice/comm_generic.py +++ b/artiq/coredevice/comm_generic.py @@ -12,23 +12,26 @@ logger = logging.getLogger(__name__) class _H2DMsgType(Enum): LOG_REQUEST = 1 - IDENT_REQUEST = 2 - SWITCH_CLOCK = 3 + LOG_CLEAR = 2 - LOAD_LIBRARY = 4 - RUN_KERNEL = 5 + IDENT_REQUEST = 3 + SWITCH_CLOCK = 4 - RPC_REPLY = 6 - RPC_EXCEPTION = 7 + LOAD_LIBRARY = 5 + RUN_KERNEL = 6 - FLASH_READ_REQUEST = 8 - FLASH_WRITE_REQUEST = 9 - FLASH_ERASE_REQUEST = 10 - FLASH_REMOVE_REQUEST = 11 + RPC_REPLY = 7 + RPC_EXCEPTION = 8 + + FLASH_READ_REQUEST = 9 + FLASH_WRITE_REQUEST = 10 + FLASH_ERASE_REQUEST = 11 + FLASH_REMOVE_REQUEST = 12 class _D2HMsgType(Enum): LOG_REPLY = 1 + IDENT_REPLY = 2 CLOCK_SWITCH_COMPLETED = 3 CLOCK_SWITCH_FAILED = 4 @@ -235,6 +238,11 @@ class CommGeneric: self._read_expect(_D2HMsgType.LOG_REPLY) return self._read_chunk(self._read_length).decode('utf-8') + def clear_log(self): + self._write_empty(_H2DMsgType.LOG_CLEAR) + + self._read_empty(_D2HMsgType.LOG_REPLY) + def flash_storage_read(self, key): self._write_header(_H2DMsgType.FLASH_READ_REQUEST) self._write_string(key) diff --git a/soc/runtime/log.c b/soc/runtime/log.c index ebc7990ec..413857564 100644 --- a/soc/runtime/log.c +++ b/soc/runtime/log.c @@ -61,3 +61,8 @@ void log_get(char *outbuf) j = (j + 1) % LOG_BUFFER_SIZE; } } + +void log_clear() +{ + memset(buffer, 0, sizeof(buffer)); +} diff --git a/soc/runtime/log.h b/soc/runtime/log.h index 0fb7ce8b1..74e3e815e 100644 --- a/soc/runtime/log.h +++ b/soc/runtime/log.h @@ -12,5 +12,6 @@ void log_va(const char *fmt, va_list args); void log(const char *fmt, ...); void log_get(char *outbuf); +void log_clear(); #endif /* __LOG_H */ diff --git a/soc/runtime/session.c b/soc/runtime/session.c index ff6629f4f..3bdf3bb81 100644 --- a/soc/runtime/session.c +++ b/soc/runtime/session.c @@ -310,6 +310,8 @@ void session_end(void) /* host to device */ enum { REMOTEMSG_TYPE_LOG_REQUEST = 1, + REMOTEMSG_TYPE_LOG_CLEAR, + REMOTEMSG_TYPE_IDENT_REQUEST, REMOTEMSG_TYPE_SWITCH_CLOCK, @@ -328,6 +330,7 @@ enum { /* device to host */ enum { REMOTEMSG_TYPE_LOG_REPLY = 1, + REMOTEMSG_TYPE_IDENT_REPLY, REMOTEMSG_TYPE_CLOCK_SWITCH_COMPLETED, REMOTEMSG_TYPE_CLOCK_SWITCH_FAILED, @@ -383,6 +386,11 @@ static int process_input(void) out_packet_finish(); break; + case REMOTEMSG_TYPE_LOG_CLEAR: + log_clear(); + out_packet_empty(REMOTEMSG_TYPE_LOG_REPLY); + break; + case REMOTEMSG_TYPE_FLASH_READ_REQUEST: { #if SPIFLASH_SECTOR_SIZE - 4 > BUFFER_OUT_SIZE - 9 #error Output buffer cannot hold the flash storage data