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 #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 G2818). 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 settingcommand_checksumadded onconfig.inifile. The feature is also selectable at runtime from theFeature` menu.
NOTE: Disable it in case:
printing is controlled by a remote host (e.g. ESP3D, OctoPrint etc.) and a COMMAND_CHECKSUM
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.
ADVANCED_OK feature is enabled in TFT. Otherwise, any out of synch command already sent to
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 #2836 and #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() and loopFrontEnd() functions optimized to provide better performance on both idle and printing 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 and interfaceCmd renamed to Mainboard_AckHandler and Mainboard_CmdHandler respectively.
Cleanup: Created APIs Mainboard_CmdControl and Mainboard_FlowControl with functions and/or control functions shared between Mainboard_AckHandler and Mainboard_CmdHandler.
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 #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 G2818). 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_checksumadded on
config.inifile. The feature is also selectable at runtime from the
Feature` menu.NOTE: Disable it in case:
loopBackEnd()
andloopFrontEnd()
functions optimized to provide better performance on bothidle
andprinting
states.speed
,fan
,coordinate
query gcode removed from command queue), the status is reset allowing the TFT to reschedule the periodic transmission of the gcode.parseACK
andinterfaceCmd
renamed toMainboard_AckHandler
andMainboard_CmdHandler
respectively.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