On Thursday, February 20, 2014 2:47 AM Wolfgang Grandegger wrote: > Am Mi, 19.02.2014, 23:05 schrieb Wayne Ross: >> On Wednesday, February 19, 2014 3:16 AM Wolfgang Grandegger wrote: >>> Am Di, 18.02.2014, 23:00 schrieb Wayne Ross: >>>> On Monday, February 17, 2014 3:21 PM, Wolfgang Grandegger >>>> <[email protected]> wrote: ... >>>> dmesg shows new activity:
>>>> rtcan0: real bitrate 250000, sampling point 87.5% >>>> rtcan_sja_set_bit_time: btr0=0x1 btr1=0x1c >>>> rtcan1: real bitrate 250000, sampling point 87.5% >>>> rtcan_sja_set_bit_time: btr0=0x1 btr1=0x9c >>> >>> That's strange. "btr1" should here be "0x1c" as well. >>> >> *Most* times I start after boot, BOTH report btr1=0x9c... >> One boot I saw the values swapped. > > That's wired == not OK! btr1 should always be "0x1c". > > Wolfgang. Researching this some more, I *think* I have tracked down this behavior to an uninitialized variable in the file ksrc/drivers/can/rtcan_raw_dev.c, routine rtcan_cal_bit_time(): this function is called by rtcan_ioctl_dev_set(), passing a can_bittime pointer. At the end of rtcan_calc_bit_time, 5 members of that structure (bt) are filled out, not touching 1 value (sam, a single bit) leaving it uninitialized. I don't see any initialization of that structure in the calling routine either. I see the alternate Kernel configuration of CONFIG_XENO_DRIVERS_CAN_CALC_BITTIME_OLD earlier in the file always sets this value to 0. I cannot see any reason to have this value unset for the STD calculation. include/rtdm/rtcan.h describes this bit as "enable triple sampling", which is probably available for a custom timing. So, I propose the following change: diff --git a/ksrc/drivers/can/rtcan_raw_dev.c b/ksrc/drivers/can/rtcan_raw_dev.c index c5fd1b6..d305bab 100644 --- a/ksrc/drivers/can/rtcan_raw_dev.c +++ b/ksrc/drivers/can/rtcan_raw_dev.c @@ -219,6 +219,7 @@ static int rtcan_calc_bit_time(struct rtcan_device *dev, bt->phase_seg1 = tseg1 - bt->prop_seg; bt->phase_seg2 = tseg2; bt->sjw = 1; + bt->sam = 0; bt->brp = best_brp; /* real bit-rate */ With this change I have confirmed rtcanconfig *always* yields the *same* result for btr1 (0x1c): rtcan0: real bitrate 250000, sampling point 87.5% rtcan_sja_set_bit_time: btr0=0x1 btr1=0x1c Wayne _______________________________________________ Xenomai mailing list [email protected] http://www.xenomai.org/mailman/listinfo/xenomai
