> -----Mensaje original-----
> De: Wolfgang Grandegger [mailto:[email protected]]
> Enviado el: Monday, March 14, 2011 3:25 PM
> Para: Jorge Fernandez Monteagudo
> CC: [email protected]
> Asunto: Re: [Socketcan-users] Setting the clock, ocr and cdr values
>
> On 03/14/2011 03:06 PM, Jorge Fernandez Monteagudo wrote:
> >
> >
> >> -----Mensaje original-----
> >> De: Wolfgang Grandegger [mailto:[email protected]]
> >> Enviado el: Monday, March 14, 2011 2:51 PM
> >> Para: Jorge Fernandez Monteagudo
> >> CC: [email protected]
> >> Asunto: Re: [Socketcan-users] Setting the clock, ocr and cdr values
> >>
> >> On 03/14/2011 02:37 PM, Jorge Fernandez Monteagudo wrote:
> >>>> -----Mensaje original-----
> >>>> De: Wolfgang Grandegger [mailto:[email protected]]
> >>>> Enviado el: Monday, March 14, 2011 1:06 PM
> >>>> Para: Jorge Fernandez Monteagudo
> >>>> CC: [email protected]
> >>>> Asunto: Re: [Socketcan-users] Setting the clock, ocr and cdr
> values
> >>>>
> >>>> On 03/14/2011 11:42 AM, Jorge Fernandez Monteagudo wrote:
> >>>>> Hi,
> >>>>>
> >>>>> I'm trying to implement my can infrastructure with socketcan. I
> >> would
> >>>> like to know where to find
> >>>>> information about the values from sja1000_priv struct, the
> >>>> can.clock.freq, ocr and cdr.
> >>>>
> >>>> Not sure what you are looking for. The meaning of theses values is
> >>>> described in the SJA1000 datasheet.
> >>>>
> >>>
> >>> Well, I'm trying to setup the sja1000 chip using the socketcan
> >> architecture.
> >>> In my old code I had the registers CDR, BTR0, BTR1, OCR, CMR and
> IER
> >>> loaded with some values in order to set the pelican mode with 1Mbps
> >>> and let the chip ready to serve interruptions. Now I'm trying to
> >> replicate
> >>> this in a modified version of the plx_pci.c but I've seen that the
> >> only
> >>> register used are from the sja1000_priv struct.
> >>
> >> You need to provide proper cdr, ocr and the CAN clock sources
> >> frequency.
> >> See also:
> >>
> >>
> http://lxr.linux.no/#linux+v2.6.37.3/drivers/net/can/sja1000/sja1000.c#
> >> L242
> >>
> >> The rest is handled by the SJA1000 driver.
> >>
> >
> > Oh yes, I see where this sja1000_priv struct fields are used!
> >
> >>From the 'static int sja1000_set_bittiming(struct net_device *dev)'
> method
> > there is some way to set manually the btr0 and btr1 values? In my
> code I set
> >
> > BTR0 <- 0x01
> > BTR1 <- 0x10
> >
> > to set the 1000 Kbs.
>
> You can use the methods described in
>
> http://lxr.linux.no/#linux+v2.6.37.3/Documentation/networking/can.txt#L
> 635
>
> to set the bit-timing parameters. You cannot set btr0/1 directly. Make
> sure you define a proper CAN clock source frequency. The BTR0/1 values
> above indicate that it's not 8 MHz.
>
> >>>>> I'm following the plx_pci.c code but in my driver I setup these
> >>>> register in a different way.
> >>>>> First, I set the CDR <- 0xC0, then I set the clock using the BTR0
> >> and
> >>>> BTR1 registers to set the 1Mbps
> >>>>> baudrate, BTR0 <- 0x01, BTR1 <- 0x10 and finally the OCR register
> >> is
> >>>> initialized with OCR <- 0x1A.
> >>>>
> >>>> The input clock frequency, cdr and ocr must be defined by the
> >> SJA1000
> >>>> driver, e.g.:
> >>>>
> >>>>
> >>
> http://lxr.linux.no/#linux+v2.6.37.3/drivers/net/can/sja1000/plx_pci.c#
> >>>> L526
> >>>>
> >>>> Some drivers allow to set these values via module parameter. So,
> >>>> depending on the driver appropriate for your CAN hardware, you
> need
> >> to
> >>>> adjust them. The bit-timing have to be defined via netlink
> interface
> >> as
> >>>> described here:
> >>>>
> >>>>
> >>
> http://lxr.linux.no/#linux+v2.6.37.3/Documentation/networking/can.txt#L
> >>>> 635
> >>>>
> >>>
> >>> Thanks for the info, now I get an error in dmesg: "bit-timing not
> yet
> >> defined"
> >>> then I suppose I'll need to follow this last link.
> >>
> >> Yes, you need to set the bit-timing before you can start the device.
> >>
> >
> >
> > Where I can found the iproute2 utility suite? I have debian 5.0.7,
> but
> > the command
> >
> > # ip link set can0 type can help
> >
> > don't print any bitrate or tq option...
> >
> > # ip -V
> > ip utility, iproute2-ss080725
>
> You need a recent version of the IPROUTE2 utility suite, which you can
> get from:
>
> http://www.linuxfoundation.org/collaborate/workgroups/networking/iprout
> e2
>
> Wolfgang.

Hi, I have something running...

I've installed the last iproute2:

# cd /opt/iproute2-2.6.37/ip
# ./ip link set can0 type can bitrate 1000000
# ifconfig can0 up
can0      Link encap:UNSPEC  HWaddr 
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:8061 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10
          RX bytes:8061 (7.8 KiB)  TX bytes:0 (0.0 B)
          Interrupt:21

# dmesg
...
device 0000:01:03.0: setting BTR0=0x00 BTR1=0x14

# cat /proc/net/can/stats

        0 transmitted frames (TXF)
     7410 received frames (RXF)
        4 matched frames (RXMF)

        0 % total match ratio (RXMR)
        0 frames/s total tx rate (TXR)
        0 frames/s total rx rate (RXR)

        0 % current match ratio (CRXMR)
        0 frames/s current tx rate (CTXR)
        9 frames/s current rx rate (CRXR)

       27 % max match ratio (MRXMR)
        0 frames/s max tx rate (MTXR)
       11 frames/s max rx rate (MRXR)

        0 current receive list entries (CRCV)
        1 maximum receive list entries (MRCV)

# cd /opt/socketcan/can-utils
# ./candump can0 0:0,#FFFFFFFF
SIOCGIFINDEX: No such device

The can0 device is up and receiving frames? but I can read them.
Maybe the /dev/can0 is not set properly, because I'm using the
old one:

# ls -al /dev/can0
crw-rw-rw- 1 root root 91, 0 2011-03-11 14_39 /dev/can0

Regards,
Jorge

Este mensaje se dirige exclusivamente a su destinatario y puede contener 
información privilegiada o CONFIDENCIAL. Si no es vd. el destinatario indicado, 
queda notificado de que la utilización, divulgación y/o copia sin autorización 
está prohibida en virtud de la legislación vigente. Si ha recibido este mensaje 
por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y 
proceda a su destrucción.

This message is intended exclusively for its addressee and may contain 
information that is CONFIDENTIAL and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any 
dissemination, copy or disclosure of this communication is strictly prohibited 
by law. If this message has been received in error, please immediately notify 
us via e-mail and delete it.
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Reply via email to