This is called when we reach the end of the file we are reading from. Return true if there is a line waiting to be processed.
| 1868 | |
| 1869 | // This is called when we reach the end of the file we are reading from. Return true if there is a line waiting to be processed. |
| 1870 | bool StringParser::FileEnded() noexcept |
| 1871 | { |
| 1872 | #if HAS_MASS_STORAGE |
| 1873 | if (IsWritingBinary()) |
| 1874 | { |
| 1875 | // We are in the middle of writing a binary file but the input stream has ended |
| 1876 | FinishWritingBinary(); |
| 1877 | Init(); |
| 1878 | return false; |
| 1879 | } |
| 1880 | #endif |
| 1881 | |
| 1882 | bool commandCompleted = false; |
| 1883 | if (gcodeLineEnd != 0) // if there is something in the buffer |
| 1884 | { |
| 1885 | Put('\n'); // append a newline in case the file didn't end with one |
| 1886 | commandCompleted = true; |
| 1887 | } |
| 1888 | |
| 1889 | #if HAS_MASS_STORAGE |
| 1890 | if (IsWritingFile()) |
| 1891 | { |
| 1892 | if (commandCompleted) |
| 1893 | { |
| 1894 | DecodeCommand(); |
| 1895 | if (gb.IsReady()) // if we have a complete command |
| 1896 | { |
| 1897 | const bool gotM29 = (GetCommandLetter() == 'M' && GetCommandNumber() == 29); |
| 1898 | if (!gotM29) // if it wasn't M29, write it to file |
| 1899 | { |
| 1900 | fileBeingWritten->Write(gb.buffer); |
| 1901 | fileBeingWritten->Write('\n'); |
| 1902 | } |
| 1903 | } |
| 1904 | } |
| 1905 | |
| 1906 | // Close the file whether or not we saw M29 |
| 1907 | fileBeingWritten->Close(); |
| 1908 | fileBeingWritten = nullptr; |
| 1909 | SetFinished(); |
| 1910 | const char *_ecv_array const r = (gb.LatestMachineState().compatibility == Compatibility::Marlin) ? "Done saving file." : ""; |
| 1911 | reprap.GetGCodes().HandleReply(gb, GCodeResult::ok, r); |
| 1912 | return false; |
| 1913 | } |
| 1914 | #endif |
| 1915 | |
| 1916 | if (!commandCompleted && gb.CurrentFileMachineState().GetIterations() >= 0) |
| 1917 | { |
| 1918 | // We reached the end of the file while inside a loop. Insert a dummy 'skip' command to allow the loop processing to complete. |
| 1919 | Init(); |
| 1920 | PutCommand("skip"); |
| 1921 | commandCompleted = true; |
| 1922 | } |
| 1923 | return commandCompleted; |
| 1924 | } |
| 1925 | |
| 1926 | // Check that a number was found. If it was, advance readPointer past it. Otherwise throw an exception. |
| 1927 | void StringParser::CheckNumberFound(const char *_ecv_array endptr) THROWS(GCodeException) |
nothing calls this directly
no test coverage detected