<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Greg,<br>
<br>
you should now also be able to see TX overflows in the can status
output.<br>
<br>
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>
<br>
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>
<br>
And TX overflows actually do occur quite often, without a plausible
cause:<br>
<br>
<tt>OVMS > can can1 status </tt><tt><br>
</tt><tt>CAN: can1</tt><tt><br>
</tt><tt>Mode: Active</tt><tt><br>
</tt><tt>Speed: 500000</tt><tt><br>
</tt><tt>Rx pkt: 133146</tt><tt><br>
</tt><tt>Rx err: 0</tt><tt><br>
</tt><tt>Rx ovrflw: 0</tt><tt><br>
</tt><tt>Tx pkt: 53238</tt><tt><br>
</tt><tt>Tx err: 95</tt><tt><br>
</tt><tt>Tx ovrflw: <b>498</b></tt><tt><br>
</tt><tt>Err flags: 0x12c00</tt><tt><br>
</tt><br>
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>
<br>
Regards,<br>
Michael<br>
<br>
<br>
<div class="moz-cite-prefix">Am 31.12.2017 um 19:37 schrieb Greg D.:<br>
</div>
<blockquote type="cite"
cite="mid:450fda3c-a873-53ed-f933-5168d0d521ba@gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
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>
<br>
I'll let it run for a while, just to check stability. But so far,
Yea!<br>
<br>
Greg<br>
<br>
<br>
<div class="moz-cite-prefix">Michael Balzer wrote:<br>
</div>
<blockquote type="cite"
cite="mid:5927ae56-5881-b44f-1d66-6bc543bd4b5f@expeedo.de">
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
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>
<br>
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>
<br>
Regards,<br>
Michael<br>
<br>
<br>
<div class="moz-cite-prefix">Am 31.12.2017 um 14:33 schrieb Geir
Øyvind Vælidalo:<br>
</div>
<blockquote type="cite"
cite="mid:5687FF93-7DB9-4F9D-9B98-31CDCF8E8AAC@validalo.net">
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
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><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>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
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>
<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>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
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>
<pre class="moz-signature" cols="160">--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
</body>
</html>