| 1828 | } |
| 1829 | |
| 1830 | void 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 | |
| 1865 | void SbcInterface::HandleGCodeReply(MessageType mt, OutputBuffer *buffer) noexcept |
| 1866 | { |
no test coverage detected