MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / ProcessReceivedMessage

Method ProcessReceivedMessage

src/CAN/CommandProcessor.cpp:294–730  ·  view source on GitHub ↗

Process a received broadcast or request message. Don't free the message buffer

Source from the content-addressed store, hash-verified

292
293// Process a received broadcast or request message. Don't free the message buffer
294void CommandProcessor::ProcessReceivedMessage(CanMessageBuffer *buf) noexcept
295{
296 if (buf->id.Src() != CanInterface::GetCanAddress()) // I don't think we should receive our own broadcasts, but in case we do...
297 {
298 if ( buf->id.Dst() != CanId::BroadcastAddress
299 && buf->id.MsgType() != CanMessageType::fansReport // don't flash whenever we receive a regular status message
300 && buf->id.MsgType() != CanMessageType::heatersStatusReport
301 && buf->id.MsgType() != CanMessageType::boardStatusReport
302 && buf->id.MsgType() != CanMessageType::driversStatusReport
303 && buf->id.MsgType() != CanMessageType::filamentMonitorsStatusReportNew2
304 )
305 {
306 reprap.GetPlatform().OnProcessingCanMessage();
307 }
308
309 const CanMessageType id = buf->id.MsgType();
310#if SUPPORT_REMOTE_COMMANDS
311 if (CanInterface::InExpansionMode())
312 {
313 String<StringLength500> reply;
314 const StringRef& replyRef = reply.GetRef();
315 GCodeResult rslt;
316 CanRequestId requestId;
317 uint8_t extra = 0;
318
319 switch (id)
320 {
321 case CanMessageType::timeSync:
322 StepTimer::ProcessTimeSyncMessage(buf->msg.sync, buf->dataLength, buf->timeStamp);
323 return; // no reply needed
324
325 case CanMessageType::emergencyStop:
326 reprap.EmergencyStop();
327 reprap.ScheduleReset();
328 return; // no reply needed
329
330 case CanMessageType::movementLinearShaped:
331 // Check for duplicate and out-of-sequence message
332 // We can get out-of-sequence messages because of a bug in the CAN hardware; so use only the sequence number to detect duplicates
333 {
334 const int8_t seq = buf->msg.moveLinearShaped.seq;
335 if (((seq + 1) & CanMessageMovementLinearShaped::SeqMask) == expectedSeq)
336 {
337 ++duplicateMotionMessages;
338 return;
339 }
340
341 if (seq != expectedSeq && expectedSeq != 0xFF)
342 {
343 switch ((seq - expectedSeq) & CanMessageMovementLinearShaped::SeqMask)
344 {
345 case 1:
346 ++oosMessages1Ahead;
347 break;
348
349 case 2:
350 ++oosMessages2Ahead;
351 break;

Callers

nothing calls this directly

Calls 15

GetCanAddressFunction · 0.85
InitiateFirmwareUpdateFunction · 0.85
EutGetInfoFunction · 0.85
DeleteFunction · 0.85
HandleInputStateChangedFunction · 0.85
ScheduleResetMethod · 0.80
AddMoveFromRemoteMethod · 0.80
StopDriversFromRemoteMethod · 0.80
RevertPositionMethod · 0.80
ConfigureHeaterMethod · 0.80
ProcessM307NewMethod · 0.80

Tested by

no test coverage detected