mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-29 05:03:34 +08:00
Allow clearing core device log buffer.
This is useful to get a fresh environment, such as when running tests that print to log buffer.
This commit is contained in:
parent
c21387dc09
commit
d80be482fc
@ -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)
|
||||
|
@ -61,3 +61,8 @@ void log_get(char *outbuf)
|
||||
j = (j + 1) % LOG_BUFFER_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
void log_clear()
|
||||
{
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user