Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configurable delay for sending to mainboard + other #2970

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

digant73
Copy link
Contributor

@digant73 digant73 commented Feb 3, 2025

Ironically speed improvements added to the TFT accentuated communication errors with some mainboards. This PR primarily adds some settings, logic and tools to setup a stable communication if possible (e.g. in case the issue is not due to EMI).

IMPROVEMENTS:

  • Added configurable delay for sending to mainboard: new setting tx_delay is available on both config.ini file and Feature menu. It allows (in case the issue is not related to EMI) to fix the Unknown Command error messages reported by users with some mainboards.

    Minimum delay (in ms) to apply between the last sent G-code and the next one to be sent to the mainboard.
    Minimum delay for the next G-code to send depends on ADVANCED_OK feature status:

    • If disabled: the delay is applied to the last received ACK message OK response timestamp.
    • If enabled: the delay is applied to the last sent G-code timestamp (timestamp taken when the G-code transmission on serial line is completed).

    NOTE: Increase it in case:

    • The mainboard notifies frequent error ACK messages (e.g. unknown command or command checksum
      missmatch (if COMMAND_CHECKSUM feature is enabled)) to the TFT during printing in particular
      when the reported command is slightly misswritten at the beginning (e.g. "M14 E" instead of
      "M114 E", "20" instead of "M220", "221" instead of "M221", "GX108.607 Y96.632 E0.02052"
      instead of "G1 X108.607 Y96.632 E0.02052" etc.).
      Typically, to avoid those error messages:
      • A value of 1-2 is emough if ADVANCED_OK feature is disabled.
      • A value of 3-4 is emough if ADVANCED_OK feature is enabled.
  • Added configurable prefetch option: new setting tx_prefetch is available on both config.ini file and Feature menu. It allows to reduce latency at minimum when tx_delay is also set to 0.

    Used/effective only when printing from TFT SD card / TFT USB disk.
    The TFT prefetches from TFT SD card / TFT USB disk the next G-code to be sent to the mainboard
    so it will be immediately ready to be sent to the mainboard (no extra latency to read, parse
    and enqueue from TFT media) when the G-code is scheduled to be sent.

    NOTE: Disable it in case:

    • The mainboard notifies frequent error ACK messages (e.g. unknown command or command checksum
      missmatch (if COMMAND_CHECKSUM feature is enabled)) to the TFT during printing in particular
      when the reported command is slightly misswritten at the beginning (e.g. "M14 E" instead of
      "M114 E", "20" instead of "M220", "221" instead of "M221", "GX108.607 Y96.632 E0.02052"
      instead of "G1 X108.607 Y96.632 E0.02052" etc.).
  • Added monitoring task for heaters waiting for target temperature. In case of issue on printer, after a timeout value of 5 minutes, a dialog message asking to wait for heating or to resume without waiting is prompted. That feature is also useful for troubleshooting

  • Added Test Monitoring menu on Tuning menu: It continuously (at maximum rate) send predefined gcodes to mainboard to stress the system and let stability issues emerge such as Unknown Command error messages. It temporary enables command checksum feature to intercept even corrupted but valid commands (otherwise not reported as Unknown Command error messages). That menu is useful to test and find the minimum value for tx_delay making the system stable

  • Code optimization: Some code reviewed allowing to reduce about 100 bytes on flash. Some code made more robust avoiding any possibility of buffer overflow (and so a possible freeze)

  • Fix casting to (uint8_t *): Some changes on language, popup and menu API allowing to remove that very excessive and useless need of casting to (uint8_t *) on text string (that useless casting was everywhere)

  • Configured range values in config.h: All hard coded range values in config.c are now configured in config.h (as all the others already present there)

  • Minor cleanup: Naming convention, order of declaration etc.

BUGFIXES:

  • Fixed bug introduced by PR Fix MACHINE_TYPE with KINEMATICS in M115 #2913. : if CAP KINEMATICS was present then CAP EXTRUDER_COUNT was not parsed
  • Fixed a possible unknown command error message during a print cancel/stop
  • Fixed minor cosmetic bug on GUI (e.g. lines on list item menu not properly cleared etc.)

PR STATE: ready for merge

should fix #2968
should fix #2962
should fix #2960
should fix #2950
should fix #2860

Tuning_1

@looxonline
Copy link
Collaborator

Let's leave this here for a while so that others can also test it before merging. @BTTJUSTIN Please add this to the weekly meeting for review when they resume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment