|
|
|
@ -52,7 +52,15 @@ STATIC mp_obj_t mod_trezorio_poll(mp_obj_t ifaces, mp_obj_t list_ref,
|
|
|
|
|
mp_raise_TypeError("invalid list_ref");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mp_uint_t timeout = trezor_obj_get_uint(timeout_ms);
|
|
|
|
|
// The value `timeout_ms` can be negative in a minority of cases, indicating a
|
|
|
|
|
// deadline overrun. This is not a problem because we use the `timeout` only
|
|
|
|
|
// to calculate a `deadline`, and having deadline in the past works fine
|
|
|
|
|
// (except when it overflows, but the code misbehaves near the overflow
|
|
|
|
|
// anyway). Instead of bothering to correct the negative value in Python, we
|
|
|
|
|
// just coerce it to an uint. Deliberately assigning *get_int* to *uint_t*
|
|
|
|
|
// will give us C's wrapping unsigned overflow behavior, and the `deadline`
|
|
|
|
|
// result will come out correct.
|
|
|
|
|
const mp_uint_t timeout = trezor_obj_get_int(timeout_ms);
|
|
|
|
|
const mp_uint_t deadline = mp_hal_ticks_ms() + timeout;
|
|
|
|
|
mp_obj_iter_buf_t iterbuf = {0};
|
|
|
|
|
|
|
|
|
|