MCPcopy Create free account
hub / github.com/ArduPilot/ArduRemoteID / send

Method send

RemoteIDModule/CANDriver.cpp:221–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221bool CANDriver::send(const CANFrame &frame)
222{
223 if (frame.isErrorFrame() || frame.dlc > 8) {
224 return false;
225 }
226
227 twai_message_t message {};
228 message.identifier = frame.id;
229 message.extd = frame.isExtended() ? 1 : 0;
230 message.data_length_code = frame.dlc;
231 memcpy(message.data, frame.data, 8);
232
233 twai_status_info_t info {};
234 twai_get_status_info(&info);
235 switch (info.state) {
236 case TWAI_STATE_STOPPED:
237 twai_start();
238 break;
239 case TWAI_STATE_RUNNING:
240 case TWAI_STATE_RECOVERING:
241 break;
242 case TWAI_STATE_BUS_OFF: {
243 uint32_t now = millis();
244 if (now - last_bus_recovery_ms > 2000) {
245 last_bus_recovery_ms = now;
246 twai_initiate_recovery();
247 }
248 break;
249 }
250 }
251
252 const esp_err_t sts = twai_transmit(&message, pdMS_TO_TICKS(5));
253 if (sts == ESP_OK) {
254 last_bus_recovery_ms = 0;
255 }
256
257 return (sts == ESP_OK);
258}
259
260bool CANDriver::receive(CANFrame &out_frame)
261{

Callers 7

handleMethod · 0.80
initMethod · 0.80
processTxMethod · 0.80
ajax_get_callbackFunction · 0.80
ajax_get_callback_binaryFunction · 0.80
ajax_pollFunction · 0.80
jquery.min.jsFile · 0.80

Calls 2

isErrorFrameMethod · 0.80
isExtendedMethod · 0.80

Tested by

no test coverage detected