<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">YESSS! Both can-buses are working now! Was stable for at least a few minutes (that was what I got time for), so I think we can say problem solve. Thanks guys!<div class=""><br class=""></div><div class="">Happy new year to all!</div><div class=""><br class=""></div><div class="">Geir<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">31. des. 2017 kl. 23:07 skrev Greg D. <<a href="mailto:gregd2350@gmail.com" class="">gregd2350@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
  
  <div text="#000000" bgcolor="#FFFFFF" class="">
    Right.  I verified the Tx with Wireshark, but the counters are zero
    as well.  Good cross-check.<br class="">
    <br class="">
    Fully agree with not putting delays in the driver.  My understanding
    from others was that it was a temporary hack to get things to work,
    pending a better solution.  We now have that, thanks!<br class="">
    <br class="">
    Greg<br class="">
    <br class="">
    <br class="">
    <div class="moz-cite-prefix">Michael Balzer wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:12149dec-80b2-c879-cd0c-ec93a08097f5@expeedo.de" class="">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
      Greg,<br class="">
      <br class="">
      you should now also be able to see TX overflows in the can status
      output.<br class="">
      <br class="">
      I removed the delay loop because delays and retries should not be
      done by the driver, the driver should just tell the application
      about a fail, which it does now. Also, the minimum delay with
      vTaskDelay() is 1 "tick" = currently 10 ms, which is already far
      too much time to be spent on this level.<br class="">
      <br class="">
      The previous esp32can implementation did no checking of the TX
      buffer at all, resulting in silent losses or possibly corruptions
      of frames on TX overflows.<br class="">
      <br class="">
      And TX overflows actually do occur quite often, without a
      plausible cause:<br class="">
      <br class="">
      <tt class="">OVMS > can can1 status </tt><tt class=""><br class="">
      </tt><tt class="">CAN:       can1</tt><tt class=""><br class="">
      </tt><tt class="">Mode:      Active</tt><tt class=""><br class="">
      </tt><tt class="">Speed:     500000</tt><tt class=""><br class="">
      </tt><tt class="">Rx pkt:                  133146</tt><tt class=""><br class="">
      </tt><tt class="">Rx err:                       0</tt><tt class=""><br class="">
      </tt><tt class="">Rx ovrflw:                    0</tt><tt class=""><br class="">
      </tt><tt class="">Tx pkt:                   53238</tt><tt class=""><br class="">
      </tt><tt class="">Tx err:                      95</tt><tt class=""><br class="">
      </tt><tt class="">Tx ovrflw:                  <b class="">498</b></tt><tt class=""><br class="">
      </tt><tt class="">Err flags: 0x12c00</tt><tt class=""><br class="">
      </tt><br class="">
      In this case, a TX occurs every 10 ms on a 500 kbit bus -- plenty
      of time for the buffer to get sent. I'm looking into that.<br class="">
      <br class="">
      Regards,<br class="">
      Michael<br class="">
      <br class="">
      <br class="">
      <div class="moz-cite-prefix">Am 31.12.2017 um 19:37 schrieb Greg
        D.:<br class="">
      </div>
      <blockquote type="cite" cite="mid:450fda3c-a873-53ed-f933-5168d0d521ba@gmail.com" class="">
        <meta http-equiv="Content-Type" content="text/html;
          charset=UTF-8" class="">
        Ok, MUCH better.  CAN3 is back to working again!  No evidence of
        the transmit overrun problem, and the frames are about 50ms
        apart, so I think your transmit changes are working.  I'm
        running 500k BAUD.<br class="">
        <br class="">
        I'll let it run for a while, just to check stability.  But so
        far, Yea!<br class="">
        <br class="">
        Greg<br class="">
        <br class="">
        <br class="">
        <div class="moz-cite-prefix">Michael Balzer wrote:<br class="">
        </div>
        <blockquote type="cite" cite="mid:5927ae56-5881-b44f-1d66-6bc543bd4b5f@expeedo.de" class="">
          <meta http-equiv="Content-Type" content="text/html;
            charset=UTF-8" class="">
          I've added another minor change to avoid TX lockups if the bus
          is lost (i.e. disconnected). Also CMD_READ_RXBUF actually
          clears the interrupt flag itself, so we can skip the
          additional BITMODIFY call.<br class="">
          <br class="">
          The internal ESP32 CAN controller (SJA1000) unfortunately only
          has one TX buffer. I'm having performance issues with the TX
          speed on that, it's not consistently sufficient high to get
          the Twizy charge control working reliably. Not sure yet if
          that's caused by the CAN controller, the driver or the RTOS.<br class="">
          <br class="">
          Regards,<br class="">
          Michael<br class="">
          <br class="">
          <br class="">
          <div class="moz-cite-prefix">Am 31.12.2017 um 14:33 schrieb
            Geir Øyvind Vælidalo:<br class="">
          </div>
          <blockquote type="cite" cite="mid:5687FF93-7DB9-4F9D-9B98-31CDCF8E8AAC@validalo.net" class="">
            <meta http-equiv="Content-Type" content="text/html;
              charset=UTF-8" class="">
            I’ve been looking into what’s happening with the
            interrupt/queue this morning and your fix makes more sense
            than my suggestion. It could potentially fix the problem
            with the buffer filling up.
            <div class="">Unfortunately my wife is using the car so I
              can’t test this yet,</div>
            <div class=""><br class="">
            </div>
            <div class="">Geir    </div>
            <div class="">
              <div class="">
                <div class=""><br class="">
                  <blockquote type="cite" class="">
                    <div class="">31. des. 2017 kl. 10:54 skrev Michael
                      Balzer <<a href="mailto:dexter@expeedo.de" class="" moz-do-not-send="true">dexter@expeedo.de</a>>:</div>
                    <br class="Apple-interchange-newline">
                    <div class="">
                      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
                      <div text="#000000" bgcolor="#FFFFFF" class="">
                        Geir & Greg,<br class="">
                        <br class="">
                        first of all, I did an over-optimization mistake
                        in the RxCallback: the return after fetching the
                        frame must always be true -- fix is pushed.<br class="">
                        <br class="">
                        That has caused frames to get lost so you should
                        apply this fix first.<br class="">
                        <br class="">
                        <br class="">
                        <div class="moz-cite-prefix">Am 31.12.2017 um
                          01:00 schrieb Geir Øyvind Vælidalo:<br class="">
                        </div>
                        <blockquote type="cite" cite="mid:1EF21A82-2FBA-4B61-829B-B0D3230C010C@validalo.net" class="">
                          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
                          I did a test where I created three counters.
                          <div class=""><font class="" face="Monaco">One
                              went into</font> <font class="" face="Monaco">MCP2515_isr and counts every
                              interrupt.</font></div>
                          <div class=""><font class="" face="Monaco">One
                              was added as the first code line in </font><span style="font-family: Monaco;" class="">mcp2515::RxCallback.</span></div>
                          <div class=""><span style="font-family:
                              Monaco;" class="">And the third one was
                              added to RxCallBack, but right before we
                              read the CAN frame via SPI that will end
                              up in IncomingFrame. I.e. should be a
                              count of every CAN frame. </span><span style="font-family: Monaco;" class=""> </span>
                            <div class=""><span style="font-family:
                                Monaco;" class=""><br class="">
                              </span></div>
                            <div class=""><span style="font-family:
                                Monaco;" class="">This is what I got:</span></div>
                            <div class=""><span style="font-family:
                                Monaco;" class=""><br class="">
                              </span></div>
                            <div style="margin: 0px; font-stretch:
                              normal; line-height: normal; font-family:
                              Menlo; background-color: rgb(255, 255,
                              255);" class="">
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures; color: #34bc26" class="">OVMS ></span></tt><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class=""> can
                                    can2 status</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">CAN:  
                                        can2</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Mode: 
                                        Active</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Speed:
                                        100000</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Rx
                                    pkt:                      82</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">MCP2515_isr:
                                                    239</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">RxCallback1:
                                                    320</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">RxCallback2:
                                                    295</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Rx
                                    err:                       0</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Tx
                                    pkt:                       0</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Tx
                                    err:                       0</span></tt></div>
                              <div style="margin: 0px; font-stretch:
                                normal; line-height: normal;" class=""><tt class=""><span style="font-variant-ligatures:
                                    no-common-ligatures" class="">Err
                                    flags: 0x2040</span></tt></div>
                              <div class=""><span style="font-variant-ligatures:
                                  no-common-ligatures" class=""><br class="">
                                </span></div>
                            </div>
                            <div class="">
                              <div class="">These numbers puzzles me.
                                Shouldn’t <span style="background-color:
                                  rgb(255, 255, 255);" class=""><b class="">RxCallback1</b></span> and <span style="background-color: rgb(255, 255,
                                  255);" class=""><b class="">RxCallback2</b></span> be
                                less or equal to <span style="background-color: rgb(255, 255,
                                  255);" class=""><b class="">MCP2515_isr</b></span>?
                                Where does these extra 81 calls come
                                from? I’m missing something here...</div>
                            </div>
                          </div>
                        </blockquote>
                        <br class="">
                        No, that's expected behaviour. The MCP2515 has
                        two RX buffers plus error conditions. The
                        framework is designed to loop RxCallback over an
                        IRQ event until all buffers and error conditions
                        have been processed, so RxCallback counters
                        should always be >= ISR count.<br class="">
                        <br class="">
                        <blockquote type="cite" cite="mid:1EF21A82-2FBA-4B61-829B-B0D3230C010C@validalo.net" class="">
                          <div class="">
                            <div class="">
                              <div class="">Also<b class="">,
                                  RxCallback2</b> is much bigger than <b class="">Rx pkt, </b>which means not
                                all frames are sent to IncomingFrame.</div>
                            </div>
                          </div>
                        </blockquote>
                        <br class="">
                        That's in part due to my bug, but it also can
                        happen under normal conditions, as an error IRQ
                        will also trigger the RxCallback but not return
                        a frame to be processed.<br class="">
                        <br class="">
                        <blockquote type="cite" cite="mid:1EF21A82-2FBA-4B61-829B-B0D3230C010C@validalo.net" class="">
                          <div class="">
                            <div class="">
                              <div class=""><br class="">
                              </div>
                              <div class="">What does the 0x2040 means?
                                And where do that number comes from? </div>
                              <br class="">
                            </div>
                          </div>
                        </blockquote>
                        <br class="">
                        That's constructed in line 293 from the error
                        interrupt flags and the error register. The
                        lower 8 bits are in the image I sent, the upper
                        8 bits are<br class="">
                        <br class="">
                        <tt class="">      //  MERRF 0x80 = message
                          tx/rx error</tt><tt class=""><br class="">
                        </tt><tt class="">      //  ERRIF 0x20 =
                          overflow / error state change</tt><br class="">
                        <br class="">
                        Regards,<br class="">
                        Michael<br class="">
                        <br class="">
                        <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
                      </div>
                      _______________________________________________<br class="">
                      OvmsDev mailing list<br class="">
                      <a href="mailto:OvmsDev@lists.teslaclub.hk" class="" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a><br class="">
                      <a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br class="">
                    </div>
                  </blockquote>
                </div>
                <br class="">
              </div>
            </div>
            <br class="">
            <fieldset class="mimeAttachmentHeader"></fieldset>
            <br class="">
            <pre wrap="" class="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.teslaclub.hk" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a>
<a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</pre>
          </blockquote>
          <br class="">
          <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
          <br class="">
          <fieldset class="mimeAttachmentHeader"></fieldset>
          <br class="">
          <pre wrap="" class="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.teslaclub.hk" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a>
<a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</pre>
        </blockquote>
        <br class="">
        <br class="">
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br class="">
        <pre wrap="" class="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.teslaclub.hk" moz-do-not-send="true">OvmsDev@lists.teslaclub.hk</a>
<a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</pre>
      </blockquote>
      <br class="">
      <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
      <br class="">
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br class="">
      <pre wrap="" class="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.teslaclub.hk">OvmsDev@lists.teslaclub.hk</a>
<a class="moz-txt-link-freetext" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a>
</pre>
    </blockquote>
    <br class="">
  </div>

_______________________________________________<br class="">OvmsDev mailing list<br class=""><a href="mailto:OvmsDev@lists.teslaclub.hk" class="">OvmsDev@lists.teslaclub.hk</a><br class="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev<br class=""></div></blockquote></div><br class=""></div></body></html>