<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/</id><updated>2020-09-29T12:16:19.431000Z</updated><subtitle>Recent posts to Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</subtitle><entry><title>Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/?limit=25#a126" rel="alternate"/><published>2020-09-29T12:16:19.431000Z</published><updated>2020-09-29T12:16:19.431000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.comd01489a442120494e559fa6990b84056b80994c7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;come one, this is not really true, default is only CODESYS use the CAN ;-)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/?limit=25#289c" rel="alternate"/><published>2020-09-29T10:47:54.649000Z</published><updated>2020-09-29T10:47:54.649000Z</updated><author><name>hanlec</name><uri>https://forge.codesys.com/u/hanlec/</uri></author><id>https://forge.codesys.comd2326887e9c800d735f5bf53160670e1e9516dc8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;ok, I googled a little bit on this topic: &lt;br/&gt;
SocketCAN documetation on kernel.org reads:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;  &lt;span class="mi"&gt;4&lt;/span&gt;.&lt;span class="mi"&gt;1&lt;/span&gt;.&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="nv"&gt;RAW&lt;/span&gt; &lt;span class="nv"&gt;socket&lt;/span&gt; &lt;span class="nv"&gt;option&lt;/span&gt; &lt;span class="nv"&gt;CAN_RAW_LOOPBACK&lt;/span&gt;

  &lt;span class="nv"&gt;To&lt;/span&gt; &lt;span class="nv"&gt;meet&lt;/span&gt; &lt;span class="nv"&gt;multi&lt;/span&gt; &lt;span class="nv"&gt;user&lt;/span&gt; &lt;span class="nv"&gt;needs&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;local&lt;/span&gt; &lt;span class="nv"&gt;loopback&lt;/span&gt; &lt;span class="nv"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;enabled&lt;/span&gt; &lt;span class="nv"&gt;by&lt;/span&gt; &lt;span class="nv"&gt;default&lt;/span&gt;
  &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;see&lt;/span&gt; &lt;span class="nv"&gt;chapter&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;.&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;details&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;. &lt;span class="nv"&gt;But&lt;/span&gt; &lt;span class="nv"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;some&lt;/span&gt; &lt;span class="nv"&gt;embedded&lt;/span&gt; &lt;span class="nv"&gt;use&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;cases&lt;/span&gt;
  &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;e&lt;/span&gt;.&lt;span class="nv"&gt;g&lt;/span&gt;. &lt;span class="nv"&gt;when&lt;/span&gt; &lt;span class="nv"&gt;only&lt;/span&gt; &lt;span class="nv"&gt;one&lt;/span&gt; &lt;span class="nv"&gt;application&lt;/span&gt; &lt;span class="nv"&gt;uses&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;CAN&lt;/span&gt; &lt;span class="nv"&gt;bus&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;this&lt;/span&gt; &lt;span class="nv"&gt;loopback&lt;/span&gt;
  &lt;span class="nv"&gt;functionality&lt;/span&gt; &lt;span class="nv"&gt;can&lt;/span&gt; &lt;span class="nv"&gt;be&lt;/span&gt; &lt;span class="nv"&gt;disabled&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;separately&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;each&lt;/span&gt; &lt;span class="nv"&gt;socket&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;:

    &lt;span class="nv"&gt;int&lt;/span&gt; &lt;span class="nv"&gt;loopback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="c1"&gt;; /* 0 = disabled, 1 = enabled (default) */&lt;/span&gt;

    &lt;span class="nv"&gt;setsockopt&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;s&lt;/span&gt;, &lt;span class="nv"&gt;SOL_CAN_RAW&lt;/span&gt;, &lt;span class="nv"&gt;CAN_RAW_LOOPBACK&lt;/span&gt;, &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nv"&gt;loopback&lt;/span&gt;, &lt;span class="nv"&gt;sizeof&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;loopback&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;so again:&lt;br/&gt;
&lt;em&gt;WHY&lt;/em&gt; does CodeSys' CanDriver not use the default setting of 1 (=enabled) per default?&lt;br/&gt;
no one can (or should!) assume, that only one application uses the CAN bus!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/?limit=25#b936" rel="alternate"/><published>2020-09-29T10:36:50.771000Z</published><updated>2020-09-29T10:36:50.771000Z</updated><author><name>hanlec</name><uri>https://forge.codesys.com/u/hanlec/</uri></author><id>https://forge.codesys.com4b104e7624d51e2f846d8906b7291a25474f416d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;thanks Edwin, adding&lt;br/&gt;
&lt;span&gt;[CmpSocketCanDrv]&lt;/span&gt;&lt;br/&gt;
   Loopback=1&lt;br/&gt;
in /etc/CODESYSControl_User.cfg does the trick...&lt;/p&gt;
&lt;p&gt;still - two questions remain:&lt;/p&gt;
&lt;p&gt;1) why isn't that enabled by default? &lt;br/&gt;
IMHO SocketCAN behaves just like a (hardware-)bus: everything that is on the line should be seen by every device attached to it. &lt;br/&gt;
what reason is there that the CodeSys-CanDriver even has the option of disabling this behavior at all?!&lt;/p&gt;
&lt;p&gt;2) why do you advise do "remove it later after finishing this dump investigations"?&lt;br/&gt;
I actually &lt;em&gt;do&lt;/em&gt; need the CodeSys-sent messages internally on SocketCAN as I need to process and handle some messages by a service running on the RasPi&lt;/p&gt;
&lt;p&gt;thanks again,&lt;br/&gt;
Hannes&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/?limit=25#8104" rel="alternate"/><published>2020-09-29T10:03:13.874000Z</published><updated>2020-09-29T10:03:13.874000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.combfeb3d468b2f1e73f060361782cf809b1cb74089</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I would use the compiler define (in CODESYS on the Application) CANOPEN_DEBUG to have all this SDO's in the plc logger to analyze the CAN problem with the network. ( Guess this is what try to do?)&lt;/p&gt;
&lt;p&gt;I'm not really sure if this setting in /etc/CODESYSControl_User.cfg:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[CmpSocketCanDrv]&lt;/span&gt; &lt;br/&gt;
Loopback= 0|1&lt;br/&gt;
would help - but even if so, remove it later after finishing this dump investigations.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Strange: CodeSys outbound/send messages seen by hardware but not by SocketCAN (inbound/read is OK)</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fb83184bd3/?limit=25#a4d4" rel="alternate"/><published>2020-09-29T06:57:49.542000Z</published><updated>2020-09-29T06:57:49.542000Z</updated><author><name>hanlec</name><uri>https://forge.codesys.com/u/hanlec/</uri></author><id>https://forge.codesys.com880229269c6a61e92f82f808a6f1e5ea9452e0eb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;I'm using CodeSys on a Raspberry Pi.&lt;br/&gt;
I successfully use the CANbus library/module to read an write messages using SocketCAN and an attached CAN-hardware (MCP2518FD)&lt;/p&gt;
&lt;p&gt;in CodeSys I use:&lt;br/&gt;
    can0: CAN.CANBus_11bit&lt;/p&gt;
&lt;p&gt;the driver is initialized with the following config:&lt;br/&gt;
    can0Config: CAN.DRIVER_CONFIG := (usiNetwork := 0, uiBaudrate := 500, ctMessages := 200);&lt;/p&gt;
&lt;p&gt;the driver is opened/started with:&lt;br/&gt;
    can0(DriverConfig:= GVL.can0Config, eError=&amp;gt; );&lt;/p&gt;
&lt;p&gt;...and as mentioned initially: everything works - almost!&lt;/p&gt;
&lt;p&gt;the very strange thing is, that I can sucessfully send and receive messages between codesys and my hardware - but when I use the "candump can0" command to monitor the messages on SocketCAN on my rasberry, I miss all the messages sent from codesys (to the hardware). all the incomming messages (harware to codesys) are there.&lt;br/&gt;
sending test-messages using "cansend can0 ..." successfully reach both ends: codesys and my hardware&lt;/p&gt;
&lt;p&gt;it seems to me somehow as if calling "can0.SendMessage()" from codesys bypasses SocketCAN on the raspberry and writes directly to the hardware. &lt;br/&gt;
again:&lt;br/&gt;
&lt;em&gt; "can0.ReceiveMessage(..)" can see both: messages from the hardware and (test-)messages created using "cansend can0 ..."&lt;br/&gt;
&lt;/em&gt; "can0.SendMessage(..)" only sends to hardware. these messages are NOT seen on SocketCAN ("candump can0")&lt;/p&gt;
&lt;p&gt;...any ideas?&lt;br/&gt;
is there an option to enable "mirroring" the sent messages on SocketCAN?&lt;/p&gt;
&lt;p&gt;thanks for your help!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>