casaroli commented on code in PR #21398:
URL: https://github.com/apache/nuttx/pull/21398#discussion_r4453562755


##########
include/nuttx/can/can.h:
##########
@@ -909,6 +920,33 @@ struct canioc_bittiming_s
   uint8_t               bt_sjw;          /* Synchronization Jump Width in time 
quanta */
 };
 
+/* CANIOC_GET_ERRORS:
+ *
+ * The state is error-active unless the controller reports otherwise;
+ * WARNING is error-active with either error counter at or above 96.
+ * PASSIVE and BUSOFF follow the controller's own state.
+ */
+
+#define CANIOC_ERRSTATE_ACTIVE    0
+#define CANIOC_ERRSTATE_WARNING   1
+#define CANIOC_ERRSTATE_PASSIVE   2
+#define CANIOC_ERRSTATE_BUSOFF    3
+
+struct canioc_errors_s
+{
+  uint8_t               state;           /* CANIOC_ERRSTATE_* */
+  uint8_t               txerr;           /* Transmit error counter (TEC) */
+  uint8_t               rxerr;           /* Receive error counter (REC) */
+  uint32_t              errors;          /* Bus errors observed since the
+                                          * device was opened, monotonic */
+  uint32_t              arb_errors;      /* Errors observed during the

Review Comment:
   The header says these fields count errors and "RX frames the controller 
overwrote unread". The stm32h5 driver counts interrupts and masks PEA/PED and 
RF0L/RF1L after the first one until the next good frame, so the values are 
lower bounds, as stm32_fdcan.c:2253 says. Another driver that implements this 
ioctl only sees the header.
   
   Fix: say in the comments of arb_errors, data_errors and rx_overruns that 
they count error events and can be lower bounds.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to