<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
UpMiiGo guys,<br>
<br>
Am 30.07.20 um 14:43 schrieb Soko:<br>
<blockquote type="cite">Can I somehow get called (in my
vehicle-class) if an can-error is thrown?</blockquote>
Am 30.07.20 um 16:17 schrieb Michael Balzer:<br>
<blockquote type="cite"
cite="mid:429f9711-74bd-828c-0c9c-3872f9b0bfac@expeedo.de"> CAN tx
errors can be caused by other issues as well, so should generally
not be interpreted that way.</blockquote>
<br>
According to Chris on the GE forum, you're also seeing CAN tx errors
on the Komfort CAN bus, so maybe it actually makes sense for you to
check for CAN errors.<br>
<br>
There are two options:<br>
<ol>
<li>Register a TX callback for a specific TX frame</li>
<li>Register a general TX callback<br>
</li>
</ol>
<u><br>
Option 1</u> is currently not supported by the poller framework
(but could be added). For a manual frame transmission, simply set
the frame callback pointer to your handler:<br>
<br>
<tt>static void CAN_tx_callback(const CAN_frame_t* frame, bool
success)</tt><tt> </tt><tt>{</tt><tt><br>
</tt><tt> if (!success) {</tt><tt><br>
</tt><tt> // tx failure</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt><tt><br>
</tt><tt>…</tt><tt><br>
</tt><tt><br>
</tt><tt> CAN_frame_t txframe;</tt><tt><br>
</tt><tt> txframe = {};</tt><tt><br>
</tt><tt> txframe.MsgID = 0x705;</tt><tt><br>
</tt><tt> txframe.FIR.B.DLC = 8;</tt><tt><br>
</tt><tt> txframe.data = { 0x…, 0x…, … };</tt><tt><br>
</tt><tt> txfrane.callback = CAN_tx_callback;</tt><tt><br>
</tt><tt> txframe.Write(m_can3);</tt><br>
<br>
<br>
<u>Option 2</u> uses the same handler signature. A handlers is
registered as a general callback like this, e.g. on vehicle init:<br>
<br>
<tt> MyCAN.RegisterCallback(TAG, </tt><tt>CAN_tx_callback,
true);</tt><br>
<br>
You can also register an RX callback by passing "false" or omitting
the third argument. On unloading the vehicle module, simply do:<br>
<br>
<tt> MyCAN.DeregisterCallback(TAG)</tt><tt>;</tt><br>
<br>
<br>
CAN callbacks are called directly within the CAN driver context
prior to all standard queues, so can be used for very fast CAN
responses -- and thus need to be very fast too, to not affect CAN
driver throughput. Don't do any complex processing in the handler,
avoid anything that could block the task.<br>
<br>
Regards,<br>
Michael<br>
<br>
<pre class="moz-signature" cols="72">--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
</body>
</html>