Socketcan can0 port stops working after a few messages have been sent and won't reset.












0















I have been working on a project and I ran into a port command problem, but before I ask the question I need to explain the set up, my goal, and my problem.



Set Up:



So I have a Raspberry Pi 3 B+ connected to the CANable CAN interface via USB. The Pi has the Raspian software installed, and I use the desktop to manage files and use the command line to execute programs, and communicate with the CAN interface. I also installed can-utils and python-can by using the commands:



apt-get install can-utils



pip install python-can



The CANable has the Candlelight software installed, which allows me to use the can-utils commands to communicate with it.



Goal:



I need to be able to playback(send) CAN messages stored in my .asc files from my Pi through my CANable CAN interface to be received by another CAN node.



Problem:



So I was able to set up the can0 port by pluggin the CANable with USB and then using this command:



sudo ip link set can0 up type can bitrate 1000000 restart-ms 100;



I wanted to test can0 so I opened two command prompts. One to send CAN messages and the other one to monitor the received messages. To monitor I used:



candump -e any,0:0,#FFFFFFFF



and to send random messages to can0:



cangen can0



These are the results:



Sending Messages Results



Monitoring the Mesages



Also if I open the status of can0 by using "ip -det -stats link show can0" It shows that it is in the "Error Passive" mode and that 10 packets have been dropped in TX. So it looks like there is an acknowledgment problem as well as a TX buffer space problem. I assumed that it needs the message to be acknowledged and if it is not then the buffer gets full and then the connection drops. What I did to get around this was I activated the loopback function by:



sudo ifconfig can0 down;



sudo ip link set can0 up type can bitrate 1000000 restart-ms 100 loopback on;



When I do this there are no errors and I am able to see the messages using candump, but the problem is that each message line is echoed back to can0 and I see two of the same lines repeated in candump. Also, I can't find a way to reset can0 to clear the buffer other than disconnecting the CANable or shutting down the Pi. I tried:



sudo ip link set can0 type can restart;



I get: "RTNETLINK answers: Invalid argument"



I do not get these problems if I create and use a virtual CAN port (vcan0) instead of using an actual physical CAN node such as the CANable (can0).



Questions



Is there a way to pass the acknowledgment problem without the use of the loopback function so I can send the messages that I want without echo? (Like maybe using the virtual CAN node to acknowledge the messages)



If I hook up another CANable to my CANable will the messages acknowledge?



Why doesn't can0 reset even though I have the "restart-ms 100" in the command?



Why can't I reset the buffer or the information about packets by using the restart command?



Any help would be appreciated.










share|improve this question



























    0















    I have been working on a project and I ran into a port command problem, but before I ask the question I need to explain the set up, my goal, and my problem.



    Set Up:



    So I have a Raspberry Pi 3 B+ connected to the CANable CAN interface via USB. The Pi has the Raspian software installed, and I use the desktop to manage files and use the command line to execute programs, and communicate with the CAN interface. I also installed can-utils and python-can by using the commands:



    apt-get install can-utils



    pip install python-can



    The CANable has the Candlelight software installed, which allows me to use the can-utils commands to communicate with it.



    Goal:



    I need to be able to playback(send) CAN messages stored in my .asc files from my Pi through my CANable CAN interface to be received by another CAN node.



    Problem:



    So I was able to set up the can0 port by pluggin the CANable with USB and then using this command:



    sudo ip link set can0 up type can bitrate 1000000 restart-ms 100;



    I wanted to test can0 so I opened two command prompts. One to send CAN messages and the other one to monitor the received messages. To monitor I used:



    candump -e any,0:0,#FFFFFFFF



    and to send random messages to can0:



    cangen can0



    These are the results:



    Sending Messages Results



    Monitoring the Mesages



    Also if I open the status of can0 by using "ip -det -stats link show can0" It shows that it is in the "Error Passive" mode and that 10 packets have been dropped in TX. So it looks like there is an acknowledgment problem as well as a TX buffer space problem. I assumed that it needs the message to be acknowledged and if it is not then the buffer gets full and then the connection drops. What I did to get around this was I activated the loopback function by:



    sudo ifconfig can0 down;



    sudo ip link set can0 up type can bitrate 1000000 restart-ms 100 loopback on;



    When I do this there are no errors and I am able to see the messages using candump, but the problem is that each message line is echoed back to can0 and I see two of the same lines repeated in candump. Also, I can't find a way to reset can0 to clear the buffer other than disconnecting the CANable or shutting down the Pi. I tried:



    sudo ip link set can0 type can restart;



    I get: "RTNETLINK answers: Invalid argument"



    I do not get these problems if I create and use a virtual CAN port (vcan0) instead of using an actual physical CAN node such as the CANable (can0).



    Questions



    Is there a way to pass the acknowledgment problem without the use of the loopback function so I can send the messages that I want without echo? (Like maybe using the virtual CAN node to acknowledge the messages)



    If I hook up another CANable to my CANable will the messages acknowledge?



    Why doesn't can0 reset even though I have the "restart-ms 100" in the command?



    Why can't I reset the buffer or the information about packets by using the restart command?



    Any help would be appreciated.










    share|improve this question

























      0












      0








      0








      I have been working on a project and I ran into a port command problem, but before I ask the question I need to explain the set up, my goal, and my problem.



      Set Up:



      So I have a Raspberry Pi 3 B+ connected to the CANable CAN interface via USB. The Pi has the Raspian software installed, and I use the desktop to manage files and use the command line to execute programs, and communicate with the CAN interface. I also installed can-utils and python-can by using the commands:



      apt-get install can-utils



      pip install python-can



      The CANable has the Candlelight software installed, which allows me to use the can-utils commands to communicate with it.



      Goal:



      I need to be able to playback(send) CAN messages stored in my .asc files from my Pi through my CANable CAN interface to be received by another CAN node.



      Problem:



      So I was able to set up the can0 port by pluggin the CANable with USB and then using this command:



      sudo ip link set can0 up type can bitrate 1000000 restart-ms 100;



      I wanted to test can0 so I opened two command prompts. One to send CAN messages and the other one to monitor the received messages. To monitor I used:



      candump -e any,0:0,#FFFFFFFF



      and to send random messages to can0:



      cangen can0



      These are the results:



      Sending Messages Results



      Monitoring the Mesages



      Also if I open the status of can0 by using "ip -det -stats link show can0" It shows that it is in the "Error Passive" mode and that 10 packets have been dropped in TX. So it looks like there is an acknowledgment problem as well as a TX buffer space problem. I assumed that it needs the message to be acknowledged and if it is not then the buffer gets full and then the connection drops. What I did to get around this was I activated the loopback function by:



      sudo ifconfig can0 down;



      sudo ip link set can0 up type can bitrate 1000000 restart-ms 100 loopback on;



      When I do this there are no errors and I am able to see the messages using candump, but the problem is that each message line is echoed back to can0 and I see two of the same lines repeated in candump. Also, I can't find a way to reset can0 to clear the buffer other than disconnecting the CANable or shutting down the Pi. I tried:



      sudo ip link set can0 type can restart;



      I get: "RTNETLINK answers: Invalid argument"



      I do not get these problems if I create and use a virtual CAN port (vcan0) instead of using an actual physical CAN node such as the CANable (can0).



      Questions



      Is there a way to pass the acknowledgment problem without the use of the loopback function so I can send the messages that I want without echo? (Like maybe using the virtual CAN node to acknowledge the messages)



      If I hook up another CANable to my CANable will the messages acknowledge?



      Why doesn't can0 reset even though I have the "restart-ms 100" in the command?



      Why can't I reset the buffer or the information about packets by using the restart command?



      Any help would be appreciated.










      share|improve this question














      I have been working on a project and I ran into a port command problem, but before I ask the question I need to explain the set up, my goal, and my problem.



      Set Up:



      So I have a Raspberry Pi 3 B+ connected to the CANable CAN interface via USB. The Pi has the Raspian software installed, and I use the desktop to manage files and use the command line to execute programs, and communicate with the CAN interface. I also installed can-utils and python-can by using the commands:



      apt-get install can-utils



      pip install python-can



      The CANable has the Candlelight software installed, which allows me to use the can-utils commands to communicate with it.



      Goal:



      I need to be able to playback(send) CAN messages stored in my .asc files from my Pi through my CANable CAN interface to be received by another CAN node.



      Problem:



      So I was able to set up the can0 port by pluggin the CANable with USB and then using this command:



      sudo ip link set can0 up type can bitrate 1000000 restart-ms 100;



      I wanted to test can0 so I opened two command prompts. One to send CAN messages and the other one to monitor the received messages. To monitor I used:



      candump -e any,0:0,#FFFFFFFF



      and to send random messages to can0:



      cangen can0



      These are the results:



      Sending Messages Results



      Monitoring the Mesages



      Also if I open the status of can0 by using "ip -det -stats link show can0" It shows that it is in the "Error Passive" mode and that 10 packets have been dropped in TX. So it looks like there is an acknowledgment problem as well as a TX buffer space problem. I assumed that it needs the message to be acknowledged and if it is not then the buffer gets full and then the connection drops. What I did to get around this was I activated the loopback function by:



      sudo ifconfig can0 down;



      sudo ip link set can0 up type can bitrate 1000000 restart-ms 100 loopback on;



      When I do this there are no errors and I am able to see the messages using candump, but the problem is that each message line is echoed back to can0 and I see two of the same lines repeated in candump. Also, I can't find a way to reset can0 to clear the buffer other than disconnecting the CANable or shutting down the Pi. I tried:



      sudo ip link set can0 type can restart;



      I get: "RTNETLINK answers: Invalid argument"



      I do not get these problems if I create and use a virtual CAN port (vcan0) instead of using an actual physical CAN node such as the CANable (can0).



      Questions



      Is there a way to pass the acknowledgment problem without the use of the loopback function so I can send the messages that I want without echo? (Like maybe using the virtual CAN node to acknowledge the messages)



      If I hook up another CANable to my CANable will the messages acknowledge?



      Why doesn't can0 reset even though I have the "restart-ms 100" in the command?



      Why can't I reset the buffer or the information about packets by using the restart command?



      Any help would be appreciated.







      linux ubuntu command-line python raspberry-pi






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 29 '18 at 5:28









      Leo Leo

      12




      12






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388656%2fsocketcan-can0-port-stops-working-after-a-few-messages-have-been-sent-and-wont%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388656%2fsocketcan-can0-port-stops-working-after-a-few-messages-have-been-sent-and-wont%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Plaza Victoria

          Puebla de Zaragoza

          Musa