From 1bea099eb201526a777f3d30b8a9e017724aaa9d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 29 Sep 2020 14:05:50 -0500 Subject: [PATCH] Allow the _state_count properties to be unimplemented This is the case on the SPI implementations MCP2515 and MCP2518. --- shared-bindings/canio/CAN.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index 925b248fa6..15ce3dc08c 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -172,7 +172,12 @@ STATIC const mp_obj_property_t canio_can_receive_error_count_obj = { }; //| error_warning_state_count: int -//| """The number of times the controller enterted the Error Warning state (read-only). This number wraps around to 0 after an implementation-defined number of errors.""" +//| """The number of times the controller enterted the Error Warning +//| state (read-only). This number wraps around to 0 after an +//| implementation-defined number of errors. +//| +//| Not all implementations support this property. If the property +//| is unsupported, AttributeError will be raised.""" //| STATIC mp_obj_t canio_can_error_warning_state_count_get(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -189,7 +194,12 @@ STATIC const mp_obj_property_t canio_can_error_warning_state_count_obj = { }; //| error_passive_state_count: int -//| """The number of times the controller enterted the Error Passive state (read-only). This number wraps around to 0 after an implementation-defined number of errors.""" +//| """The number of times the controller enterted the Error Passive +//| state (read-only). This number wraps around to 0 after an +//| implementation-defined number of errors. +//| +//| Not all implementations support this property. If the property +//| is unsupported, AttributeError will be raised.""" //| STATIC mp_obj_t canio_can_error_passive_state_count_get(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -206,7 +216,12 @@ STATIC const mp_obj_property_t canio_can_error_passive_state_count_obj = { }; //| bus_off_state_count: int -//| """The number of times the controller enterted the Bus Off state (read-only). This number wraps around to 0 after an implementation-defined number of errors.""" +//| """The number of times the controller enterted the Bus Off state +//| (read-only). This number wraps around to 0 after an +//| implementation-defined number of errors. +//| +//| Not all implementations support this property. If the property +//| is unsupported, AttributeError will be raised.""" //| STATIC mp_obj_t canio_can_bus_off_state_count_get(mp_obj_t self_in) { canio_can_obj_t *self = MP_OBJ_TO_PTR(self_in);