Added Command Checksum + code optimization + cleanup #2889
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With other two pending PRs #2886 and #2852, this PR implements the last remaining (useful) FR #2839 requesting the command checksum feature. I needed that feature to troubleshot #2870. Once created, I'm simply sharing it with other code optimization/improvements compliant to other FRs.
IMPROVEMENTS:
Added line number and checksum feature based on [FR] Support for gcode sending with line numbers and checksums to improve communicaton reliability #2839: The TFT enriches each G-code to be sent to the mainboard adding a leading sequential line number and a trailing checksum appended after an * character used as separator. The checksum is based on algorithm
CheckSum8 Xor
and it is calculated on the G-code with the applied line number. E.g.G28
is firstly enriched with a line number (e.g.N1 G28
) and finally a checksum calculated on that enriched G-code is appended (e.g.N1 G28*18
). A data integrity check (sequential line number check and checksum check) will be performed on the mainboard. In case of data mismatch (e.g. data corruption due to EMI on communication serial line) the TFT will resend the requested G-code for a maximum of 3 attempts.New setting
command_checksum
added onconfig.ini
file. The feature is also selectable at runtime from theFeature
menu.NOTE: Disable it in case:
feature is enabled and managed by the remote host. Otherwise (COMMAND_CHECKSUM feature also
enabled in TFT), the TFT's COMMAND_CHECKSUM feature will always replace the one provided by
the remote host causing conflicts in case data mismatch will be notified by the mainboard.
the mainboard will be discarded by the mainboard and not resent by the TFT due the current
implementation of COMMAND_CHECKSUM feature on the TFT buffers only the last sent command
and not all the pending commands.
Code optimization and reduction based on [FR] General TFT Speed Improvements #2836 and [BUG] Buggy time handling code (doesn't consider timer rollover) #2832: Functions looping on query updates (based on periodic update time) or HW events (e.g. a touch on screen etc.) invoked in the main
loopBackEnd()
andloopFrontEnd()
functions optimized to provide better performance on bothidle
andprinting
states.Improved TFT stability in case of ACK timeout: In case of no OK ACK message is received by the TFT (e.g. ACK corrupted) within a timeout period of 15 seconds for a pending gcode, the pending gcode is released allowing the TFT to not freeze.
Improved TFT stability for all the queries sent by the TFT based on a state variable (e.g. not sent again until the query gcode is dequeued and sent to the mainboard). In case the query is lost without resetting its status (e.g.
speed
,fan
,coordinate
query gcode removed from command queue), the status is reset allowing the TFT to reschedule the periodic transmission of the gcode.Renamed API: APIs
parseACK
andinterfaceCmd
renamed toMainboard_AckHandler
andMainboard_CmdHandler
respectively.Cleanup: Created APIs
Mainboard_CmdControl
andMainboard_FlowControl
with functions and/or control functions shared betweenMainboard_AckHandler
andMainboard_CmdHandler
.resolves #2878 (answer provided)
resolves #2864 (answer provided)
resolves #2839
resolves #2836
resolves #2832
PR STATE: Ready for merge