My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

M118.cpp 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../gcode.h"
  23. #include "../../core/serial.h"
  24. /**
  25. * M118: Display a message in the host console.
  26. *
  27. * A1 Prepend '// ' for an action command, as in OctoPrint
  28. * E1 Have the host 'echo:' the text
  29. * Pn Redirect to another serial port
  30. * 0 : Announce to all ports
  31. * 1-9 : Serial ports 1 to 9
  32. */
  33. void GcodeSuite::M118() {
  34. bool hasE = false, hasA = false;
  35. #if HAS_MULTI_SERIAL
  36. int8_t port = -1; // Assume no redirect
  37. #endif
  38. char *p = parser.string_arg;
  39. for (uint8_t i = 3; i--;) {
  40. // A1, E1, and Pn are always parsed out
  41. if (!( ((p[0] == 'A' || p[0] == 'E') && p[1] == '1') || (p[0] == 'P' && NUMERIC(p[1])) )) break;
  42. switch (p[0]) {
  43. case 'A': hasA = true; break;
  44. case 'E': hasE = true; break;
  45. #if HAS_MULTI_SERIAL
  46. case 'P': port = p[1] - '0'; break;
  47. #endif
  48. }
  49. p += 2;
  50. while (*p == ' ') ++p;
  51. }
  52. PORT_REDIRECT(WITHIN(port, 0, NUM_SERIAL) ? (port ? SERIAL_PORTMASK(port - 1) : SERIAL_ALL) : multiSerial.portMask);
  53. if (hasE) SERIAL_ECHO_START();
  54. if (hasA) SERIAL_ECHOPGM("//");
  55. SERIAL_ECHOLN(p);
  56. }