<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="">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="">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="">OvmsDev@lists.teslaclub.hk</a><br class="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev<br class=""></div></blockquote></div><br class=""></div></div></body></html>