J784S4XEVM: CAN Configuration Set

Part Number: J784S4XEVM

Tool/software:

Hello TI Support Team,

I am working with the TI TDA4 J784S4 architecture and would like to set the CAN configuration programmatically for CAN arbitration as well as data bitrate include bitrate,TSeg1,Tseg2,sjw . Could you kindly point me to any existing library supports  especially in a Linux environment?

Thank you in advance for your assistance.

Regards,

Nirosekhan J

  • Hello,

    You can give the below command in linux environment to set bit rate and also corresponding parameters.

    Usage: ip link set DEVICE type can
            [ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
            [ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
              phase-seg2 PHASE-SEG2 [ sjw SJW ] ]
            [ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] |
            [ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1
              dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ]
            [ loopback { on | off } ]
            [ listen-only { on | off } ]
            [ triple-sampling { on | off } ]
            [ one-shot { on | off } ]
            [ berr-reporting { on | off } ]
            [ fd { on | off } ]
            [ restart-ms TIME-MS ]
            [ restart ]
            Where: BITRATE  := { 1..1000000 }
                      SAMPLE-POINT  := { 0.000..0.999 }
                      TQ            := { NUMBER }
                      PROP-SEG      := { 1..8 }
                      PHASE-SEG1    := { 1..8 }
                      PHASE-SEG2    := { 1..8 }
                      SJW           := { 1..4 }
                      RESTART-MS    := { 0 | NUMBER }

    Regards
    Tarun Mukesh
  • Hello Ti Support Team,

        Thanks for the response.

         We had tried the ip link command in the linux terminal & working as expected. The same tried through the libsocketcan library programmatically & not working as expected. Is there any library support to set the bitrate and other parameters.Please suggest the working method if anything is there.

    Regards,

    Nirosekhan J

      

  • Hello Ti Support Team,

         I was awaiting for the response to proceed further. Please provide the response for the previous ticket.

    Regards,

    Nirosekhan J

  • Hello,

    We had tried the ip link command in the linux terminal & working as expected. The same tried through the libsocketcan library programmatically & not working as expected. Is there any library support to set the bitrate and other parameters.Please suggest the working method if anything is there.

    Let me know what steps have you followed , what changes have you performed and how did you include it in firmware ?

    RegardS

    Tarun Mukesh

  • Hello Ti Support Team,

          Thanks for the response.

         1.Added the libsocket files in the source code base.

         2.Called the can_set_bittiming API & ensured that CAN interface down before calling the API.

         The same tried for the can_get_bittiming & working as expected to get the bittiming parameter.

    Regards,

    Nirosekhan J

      

  • Hello,

    can you screenshot the changes or attach the file changes done, how did you compile and added as part of executable is what i asked for ?

    Regards

    Tarun Mukesh

  • Hello Ti Support Team,

       I can't share the code due to organisation policy.As informed earlier,libsocket files is included in the source code.Called the can_set_bittiming interface to set the configuration.Executable is invoked in the linux environment in the Eval board.Kindly let me know.

    Regards,

    Nirosekhan J

  • Hello Team,

      I had tried the below stub code to set the CAN configuration using the libsocketcan interface.Could you please advice whether this interface will help to set the configuration or any other interface shall be used in the eval board to do the same.

    struct can_bittiming bt;

    bt.bitrate = 0;
    bt.tq = 0;
    bt.prop_seg = 6;
    bt.phase_seg1 = 7;
    bt.phase_seg2 = 2;
    bt.sjw = 1;

    can_set_bittiming(interface_name, &bt);

    Regards,

    Nirosekhan J

  • Hello Ti Support Team,

         Could you please provide the response for the above.It will help us to expedite our activity.

    Regards,

    Nirosekhan J

  • Hi Nirosekhan,

    Apologies for the delay in response. You should be able to use SocketCAN like in this Linux documentation: https://docs.kernel.org/networking/can.html

    If you still cannot get SocketCAN to work, you can reference the code for the "ip" tool. I think the source code is this: https://github.com/iproute2/iproute2/blob/main/ip/iplink_can.c

    Regards,

    Takuma