<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Geir & Greg,<br>
<br>
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>
<br>
That has caused frames to get lost so you should apply this fix
first.<br>
<br>
<br>
<div class="moz-cite-prefix">Am 31.12.2017 um 01:00 schrieb Geir
Øyvind Vælidalo:<br>
</div>
<blockquote type="cite"
cite="mid:1EF21A82-2FBA-4B61-829B-B0D3230C010C@validalo.net">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
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><span style="font-variant-ligatures:
no-common-ligatures; color: #34bc26" class="">OVMS ></span></tt><tt><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><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><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><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><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><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><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><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><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><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><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><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>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>
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>
<br>
<blockquote type="cite"
cite="mid:1EF21A82-2FBA-4B61-829B-B0D3230C010C@validalo.net">
<div class="">
<div class="">
<div>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>
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>
<br>
<blockquote type="cite"
cite="mid:1EF21A82-2FBA-4B61-829B-B0D3230C010C@validalo.net">
<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>
</div>
</div>
</blockquote>
<br>
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>
<br>
<tt> // MERRF 0x80 = message tx/rx error</tt><tt><br>
</tt><tt> // ERRIF 0x20 = overflow / error state change</tt><br>
<br>
Regards,<br>
Michael<br>
<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>