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

Method HandleGCodeReply

src/SBC/SbcInterface.cpp:1830–1863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1828}
1829
1830void SbcInterface::HandleGCodeReply(MessageType mt, const char *reply) noexcept
1831{
1832 if (!IsConnected())
1833 {
1834 return;
1835 }
1836
1837#ifdef TRACK_FILE_CODES
1838 if ((mt & ((1u << GCodeChannel::File) | (1u << GCodeChannel::File2))) != 0)
1839 {
1840 fileCodesHandled++;
1841 }
1842#endif
1843
1844 MutexLocker lock(gcodeReplyMutex);
1845 OutputBuffer *buffer = gcodeReply.GetLastItem();
1846 if (buffer != nullptr && mt == gcodeReply.GetLastItemType() && (mt & PushFlag) != 0 && !buffer->IsReferenced())
1847 {
1848 // Try to save some space by combining segments that have the Push flag set
1849 buffer->cat(reply);
1850 }
1851 else if (reply[0] != 0 && OutputBuffer::Allocate(buffer))
1852 {
1853 // Attempt to allocate one G-code buffer per non-empty output message
1854 buffer->cat(reply);
1855 gcodeReply.Push(buffer, mt);
1856 }
1857 else
1858 {
1859 // Store nullptr to indicate an empty response. This way many OutputBuffer references can be saved
1860 gcodeReply.Push(nullptr, mt);
1861 }
1862 EventOccurred();
1863}
1864
1865void SbcInterface::HandleGCodeReply(MessageType mt, OutputBuffer *buffer) noexcept
1866{

Callers 2

MessageMethod · 0.45
MessageVMethod · 0.45

Calls 5

IsConnectedFunction · 0.85
GetLastItemTypeMethod · 0.80
IsReferencedMethod · 0.80
catMethod · 0.80
PushMethod · 0.80

Tested by

no test coverage detected