This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Error in can_set_bitrate function of SDK v1.6.0

Hello, in zephir/include/drivers/can.h, in can_set_bitrate there is an error - you define local struct can_timing timing, but timing.sjw member wasn't initialized nor later calculated. However, you pass that structure to can_set_timing which use that parameter (actually it has asserts checks for it and therefore sometime application just crash). My fix is below, but I believe that proper calculation of sjw should be implemented:

@@ -766,20 +766,21 @@ static inline int z_impl_can_set_timing(const struct device *dev,
  *
  * @retval 0 If successful.
  * @retval -EINVAL bitrate cannot be reached.
  * @retval -EIO General input / output error, failed to set bitrate.
  */
 static inline int can_set_bitrate(const struct device *dev,
 				  uint32_t bitrate,
 				  uint32_t bitrate_data)
 {
 	struct can_timing timing;
+	timing.sjw = 1;
 #ifdef CONFIG_CAN_FD_MODE
 	struct can_timing timing_data;
 #endif
 	int ret;
 
 	ret = can_calc_timing(dev, &timing, bitrate, 875);
 	if (ret < 0) {
 		return -EINVAL;
 	}
 

Parents Reply Children
No Data
Related