mirror of https://github.com/m-labs/artiq.git
Report watchdog expiration and RTIO clock failure as exceptions.
Fixes #316.
This commit is contained in:
parent
80b13b1263
commit
501de30626
|
@ -50,6 +50,9 @@ class _D2HMsgType(Enum):
|
||||||
FLASH_OK_REPLY = 12
|
FLASH_OK_REPLY = 12
|
||||||
FLASH_ERROR_REPLY = 13
|
FLASH_ERROR_REPLY = 13
|
||||||
|
|
||||||
|
WATCHDOG_EXPIRED = 14
|
||||||
|
CLOCK_FAILURE = 15
|
||||||
|
|
||||||
|
|
||||||
class UnsupportedDevice(Exception):
|
class UnsupportedDevice(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -522,6 +525,10 @@ class CommGeneric:
|
||||||
self._serve_rpc(object_map)
|
self._serve_rpc(object_map)
|
||||||
elif self._read_type == _D2HMsgType.KERNEL_EXCEPTION:
|
elif self._read_type == _D2HMsgType.KERNEL_EXCEPTION:
|
||||||
self._serve_exception(object_map, symbolizer)
|
self._serve_exception(object_map, symbolizer)
|
||||||
|
elif self._read_type == _D2HMsgType.WATCHDOG_EXPIRED:
|
||||||
|
raise exceptions.WatchdogExpired
|
||||||
|
elif self._read_type == _D2HMsgType.CLOCK_FAILURE:
|
||||||
|
raise exceptions.ClockFailure
|
||||||
else:
|
else:
|
||||||
self._read_expect(_D2HMsgType.KERNEL_FINISHED)
|
self._read_expect(_D2HMsgType.KERNEL_FINISHED)
|
||||||
return
|
return
|
||||||
|
|
|
@ -129,3 +129,9 @@ class DDSBatchError(Exception):
|
||||||
class I2CError(Exception):
|
class I2CError(Exception):
|
||||||
"""Raised with a I2C transaction fails."""
|
"""Raised with a I2C transaction fails."""
|
||||||
artiq_builtin = True
|
artiq_builtin = True
|
||||||
|
|
||||||
|
class WatchdogExpired(Exception):
|
||||||
|
"""Raised when a watchdog expires."""
|
||||||
|
|
||||||
|
class ClockFailure(Exception):
|
||||||
|
"""Raised when RTIO PLL is unable to lock."""
|
||||||
|
|
|
@ -158,9 +158,9 @@ static void tcp_pcb_service(void *arg, struct tcp_pcb *pcb)
|
||||||
/* Writer interface */
|
/* Writer interface */
|
||||||
if(cs == instance->open_session_cs) {
|
if(cs == instance->open_session_cs) {
|
||||||
void *data;
|
void *data;
|
||||||
int len, sndbuf;
|
int len, sndbuf, close_flag;
|
||||||
|
|
||||||
cs->instance->poll(&data, &len);
|
cs->instance->poll(&data, &len, &close_flag);
|
||||||
if(len > 0) {
|
if(len > 0) {
|
||||||
sndbuf = tcp_sndbuf(pcb);
|
sndbuf = tcp_sndbuf(pcb);
|
||||||
if(len > sndbuf)
|
if(len > sndbuf)
|
||||||
|
@ -168,10 +168,12 @@ static void tcp_pcb_service(void *arg, struct tcp_pcb *pcb)
|
||||||
tcp_write(pcb, data, len, 0);
|
tcp_write(pcb, data, len, 0);
|
||||||
instance->ack_consumed(len);
|
instance->ack_consumed(len);
|
||||||
}
|
}
|
||||||
if(len < 0)
|
if(close_flag) {
|
||||||
|
tcp_output(pcb);
|
||||||
net_server_close(cs, pcb);
|
net_server_close(cs, pcb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void net_server_err(void *arg, err_t err)
|
static void net_server_err(void *arg, err_t err)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct net_server_instance {
|
||||||
void (*start)(void);
|
void (*start)(void);
|
||||||
void (*end)(void);
|
void (*end)(void);
|
||||||
int (*input)(void *data, int length);
|
int (*input)(void *data, int length);
|
||||||
void (*poll)(void **data, int *length);
|
void (*poll)(void **data, int *length, int *close_flag);
|
||||||
void (*ack_consumed)(int length);
|
void (*ack_consumed)(int length);
|
||||||
void (*ack_sent)(int length);
|
void (*ack_sent)(int length);
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,10 @@ enum {
|
||||||
|
|
||||||
REMOTEMSG_TYPE_FLASH_READ_REPLY,
|
REMOTEMSG_TYPE_FLASH_READ_REPLY,
|
||||||
REMOTEMSG_TYPE_FLASH_OK_REPLY,
|
REMOTEMSG_TYPE_FLASH_OK_REPLY,
|
||||||
REMOTEMSG_TYPE_FLASH_ERROR_REPLY
|
REMOTEMSG_TYPE_FLASH_ERROR_REPLY,
|
||||||
|
|
||||||
|
REMOTEMSG_TYPE_WATCHDOG_EXPIRED,
|
||||||
|
REMOTEMSG_TYPE_CLOCK_FAILURE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int receive_rpc_value(const char **tag, void **slot);
|
static int receive_rpc_value(const char **tag, void **slot);
|
||||||
|
@ -1083,21 +1086,26 @@ int session_input(void *data, int length)
|
||||||
/* *length is set to -1 in case of irrecoverable error
|
/* *length is set to -1 in case of irrecoverable error
|
||||||
* (the session must be dropped and session_end called)
|
* (the session must be dropped and session_end called)
|
||||||
*/
|
*/
|
||||||
void session_poll(void **data, int *length)
|
void session_poll(void **data, int *length, int *close_flag)
|
||||||
{
|
{
|
||||||
|
*close_flag = 0;
|
||||||
|
|
||||||
if(user_kernel_state == USER_KERNEL_RUNNING) {
|
if(user_kernel_state == USER_KERNEL_RUNNING) {
|
||||||
if(watchdog_expired()) {
|
if(watchdog_expired()) {
|
||||||
core_log("Watchdog expired\n");
|
core_log("Watchdog expired\n");
|
||||||
*length = -1;
|
|
||||||
return;
|
*close_flag = 1;
|
||||||
|
out_packet_empty(REMOTEMSG_TYPE_WATCHDOG_EXPIRED);
|
||||||
}
|
}
|
||||||
if(!rtiocrg_check()) {
|
if(!rtiocrg_check()) {
|
||||||
core_log("RTIO clock failure\n");
|
core_log("RTIO clock failure\n");
|
||||||
*length = -1;
|
|
||||||
return;
|
*close_flag = 1;
|
||||||
|
out_packet_empty(REMOTEMSG_TYPE_CLOCK_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!*close_flag) {
|
||||||
/* If the output buffer is available,
|
/* If the output buffer is available,
|
||||||
* check if the kernel CPU has something to transmit.
|
* check if the kernel CPU has something to transmit.
|
||||||
*/
|
*/
|
||||||
|
@ -1110,6 +1118,7 @@ void session_poll(void **data, int *length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out_packet_extract(data, length);
|
out_packet_extract(data, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ void session_start(void);
|
||||||
void session_end(void);
|
void session_end(void);
|
||||||
|
|
||||||
int session_input(void *data, int length);
|
int session_input(void *data, int length);
|
||||||
void session_poll(void **data, int *length);
|
void session_poll(void **data, int *length, int *close_flag);
|
||||||
void session_ack_consumed(int length);
|
void session_ack_consumed(int length);
|
||||||
void session_ack_sent(int length);
|
void session_ack_sent(int length);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue