<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX ProcessorsのトピックIMX6 CAN configuration using canutils and libsocketcan</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/IMX6-CAN-configuration-using-canutils-and-libsocketcan/m-p/237224#M19054</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;I have several questions about how handle the CAN, first I find a few documents &lt;BR /&gt;&lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-96194"&gt;winter2012_EcoCariMX53_v1.pdf&lt;/A&gt; &lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-1437"&gt;https://community.freescale.com/docs/DOC-1437&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.kernel.org/doc/Documentation/networking/can.txt"&gt;https://www.kernel.org/doc/Documentation/networking/can.txt&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://gitorious.org/linux-can/can-utils/source/31936b5a173dfe1d0ba0e71859e37cbc42d5bad8:"&gt;https://gitorious.org/linux-can/can-utils/source/31936b5a173dfe1d0ba0e71859e37cbc42d5bad8:&lt;/A&gt;&lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/servlet/JiveServlet/download/2019-316555-367675-268661/FlexCAN_training_material.pdf"&gt;https://community.freescale.com/servlet/JiveServlet/download/367675-268661/FlexCAN_training_material.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;But, dont show how shall be compiled the canutils on the app, for example, if in the app is used the ncurses, I need to add several lines in the makefile to point the locations of the include files and the lib, by the CAN dont say anything&lt;BR /&gt;&lt;BR /&gt;in the &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-9619"&gt;https://community.freescale.com/docs/DOC-9619&lt;/A&gt; , page 46 an 47 try to explain how calculate the Bitrate and the escalation, but is not clear enough, also how I can transfer to a code.&lt;BR /&gt;&lt;BR /&gt;The CAN is automatic open when we send the dataframe through "write" function or is necessary open it with other instructions, the documents show the instruction &lt;BR /&gt;&lt;BR /&gt;ifconfig can0 up&lt;BR /&gt; &lt;BR /&gt;When is transmitted through line command.&lt;BR /&gt;&lt;BR /&gt;Could you help me to clarify this points&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jan 2014 23:23:10 GMT</pubDate>
    <dc:creator>flaviocordova</dc:creator>
    <dc:date>2014-01-15T23:23:10Z</dc:date>
    <item>
      <title>IMX6 CAN configuration using canutils and libsocketcan</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/IMX6-CAN-configuration-using-canutils-and-libsocketcan/m-p/237224#M19054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;I have several questions about how handle the CAN, first I find a few documents &lt;BR /&gt;&lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-96194"&gt;winter2012_EcoCariMX53_v1.pdf&lt;/A&gt; &lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-1437"&gt;https://community.freescale.com/docs/DOC-1437&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.kernel.org/doc/Documentation/networking/can.txt"&gt;https://www.kernel.org/doc/Documentation/networking/can.txt&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://gitorious.org/linux-can/can-utils/source/31936b5a173dfe1d0ba0e71859e37cbc42d5bad8:"&gt;https://gitorious.org/linux-can/can-utils/source/31936b5a173dfe1d0ba0e71859e37cbc42d5bad8:&lt;/A&gt;&lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/servlet/JiveServlet/download/2019-316555-367675-268661/FlexCAN_training_material.pdf"&gt;https://community.freescale.com/servlet/JiveServlet/download/367675-268661/FlexCAN_training_material.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;But, dont show how shall be compiled the canutils on the app, for example, if in the app is used the ncurses, I need to add several lines in the makefile to point the locations of the include files and the lib, by the CAN dont say anything&lt;BR /&gt;&lt;BR /&gt;in the &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-9619"&gt;https://community.freescale.com/docs/DOC-9619&lt;/A&gt; , page 46 an 47 try to explain how calculate the Bitrate and the escalation, but is not clear enough, also how I can transfer to a code.&lt;BR /&gt;&lt;BR /&gt;The CAN is automatic open when we send the dataframe through "write" function or is necessary open it with other instructions, the documents show the instruction &lt;BR /&gt;&lt;BR /&gt;ifconfig can0 up&lt;BR /&gt; &lt;BR /&gt;When is transmitted through line command.&lt;BR /&gt;&lt;BR /&gt;Could you help me to clarify this points&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 23:23:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/IMX6-CAN-configuration-using-canutils-and-libsocketcan/m-p/237224#M19054</guid>
      <dc:creator>flaviocordova</dc:creator>
      <dc:date>2014-01-15T23:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: IMX6 CAN configuration using canutils and libsocketcan</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/IMX6-CAN-configuration-using-canutils-and-libsocketcan/m-p/237225#M19055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;But, dont show how shall be compiled&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;Can't help with that. It shouldn't need ncurses as it is a simple command-line program.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;page 46 an 47 try to explain how calculate the Bitrate and the escalation, but is not clear enough, also how I can transfer to a code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;You should just be able to specify the "bitrate" and canconfig should do the calculations for you and pick an appropriate set of numbers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;the documents show the instruction &lt;BR /&gt;&amp;gt; ifconfig can0 up&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you type "ifconfig can0" you can see if it is up or down. "ifconfig can0 up" and "ifconfig can0 down" will send it up and down.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO TOO will "canconfig can0 start" and "canconfig can0 stop", and you can see the results of that with "ifconfig".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I suggest you do "canconfig can0 stop ; canconfig can0 bitrate nnnn; canconfig can0 start" and then the "ifconfig can0 up" is not necessary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what we have in our custom&amp;nbsp; /etc/init.d startup script for CAN:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;# Configure the first CAN port&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/usr/local/sbin/canconfig can1 stop&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/usr/local/sbin/canconfig can1 bitrate 1000000&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/usr/local/sbin/canconfig can1 restart-ms 1000&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/usr/local/sbin/canconfig can1 clockfreq | grep -q 66666666&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RC=$?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if [ $RC -eq 0 ]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARMS="bittiming tq 90 prop-seg 3 phase-seg1 4 phase-seg2 3 sjw 3"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;else&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARMS="bittiming tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 3"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;fi&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/usr/local/sbin/canconfig can1 $PARMS&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/usr/local/sbin/canconfig can1 start&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;# 256-deep CAN transmit queue&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/bin/echo 256 &amp;gt; /sys/class/net/can1/tx_queue_len&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We're using "mainstream 3.4" linux and not Freescale 2.26, so there'll be differences. Our Linux platform code initially set up the CAN chips with the wrong clock. They supplied 66.66MHz. That can't be divided down to a 1MHz CAN baud rate with a legal tolerance, so we changed it to use the 24MHz clock instead, so the above is written to work on both. We don't rely on the "default" segment programming, but want to select our own.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;The CAN is automatic open when we send the dataframe through "write" function or is necessary open it with other instructions,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;You can test CAN with candump (which does what it says) and cansend. You can look at the sources of those to see how they work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;CAN ports are accessed using the same code as NETWORK sockets. The protocol is called "socketcan". Description and sample code showing exactly what to do in the usual place:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN" style="font-family: 'Helvetica','sans-serif'; color: #3d3d3d; font-size: 9pt;"&gt;&lt;A href="http://en.wikipedia.org/wiki/Socketcan" title="http://en.wikipedia.org/wiki/Socketcan"&gt;http://en.wikipedia.org/wiki/Socketcan&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 03:05:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/IMX6-CAN-configuration-using-canutils-and-libsocketcan/m-p/237225#M19055</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2014-02-05T03:05:58Z</dc:date>
    </item>
  </channel>
</rss>

