Hello,

On 11/18/2011 09:04 AM, G.H.Lee wrote:
> Hello, all
> 
> I am one of the socketcan users. The kernel I am using is 2.6.29.1. So I can 
> only change the baud rate of the can bus using the ioctl() function. I find 
> this usage from the cantest project. If I want to set the baud rate as 1Mbps, 
> I should write the code as follows:
> 
> struct ifreq ifr;
> int s;
> .......
> s = socket(PF_CAN, SOCK_RAW, CAN_RAW);
> ifr.ifr_ifru.ifru_ivalue = 1000000;
> ret = ioctl(s, SIOCSCANBAUDRATE, &ifr);

What kernel and MSCAN driver are you using? With a recent version of the
mainline kernel, the bit-rate is set via netlink interface as described
here:

http://lxr.linux.no/#linux+v3.1.1/Documentation/networking/can.txt#L635

Looks like you are using the old and deprecated SysFS interface.

> But I find that the actual baud rate is 666.7Kbps, which is 2/3 of 1000Kbps. 
> Then I try some other values. I find that all of the actual baud rate is 2/3 
> of the setting value. It is very strange. I find that that is a function in 
> the file ./net/can/dev.c, named can_calc_bit_time. This function change the 
> baud rate to bit rate. So does this function correct ?

The frequency of the CAN clock source seems to be incorrect.

> Plus, the board I am using is TWR-MPC5125 provided by freescale.

Are you using a kernel from Freescale? If yes, please contact Freescale.

Wolfgang.
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Reply via email to