mfgtools
mfgtools copied to clipboard
Add dynamic `MAX_PROGRESS_WIDTH` global variable to handle long lines
Description
Add dynamic MAX_PROGRESS_WIDTH global variable that will store longest line printed during progress phase.
Use as a replacement of get_console_width while sizing string during progress.
Initialized with 0, MAX_PROGRESS_WIDTH is updated on each progress step with actual line length as follow:
MAX_PROGRESS_WIDTH = MAX(MAX_PROGRESS_WIDTH, next_content_length)
Which warranty that next line even if shorter will contains required spaces in order to flush previous lines (while using terminal). Outside of a terminal context, lines will have a maximum length based on actual output and not on nonexistent terminal size.
Fixes #434
Type of change
- [X] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Tested by flashing firmware i.MX board with manual checking of standard output.
Example output
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.5.182-8-gc3a23e4EOL
Wait for Known USB Device Appear...EOL
[?25lEOL
3:3-18145A0A 1/ 0 [ ] EOL
[1F[1F[1F[1F
3:3-18145A0A 1/ 5 [ ] FB: ucmd setenv fastboot_dev mmcEOL
[1F[1F[1F[1F
Success 0 Failure 0 EOL
3:3-18145A0A 4/ 5 [ ] FB: flash bootloader ./imx-boot-imx8mm-lpddr4-evk-sd.bin-flash_evkEOL
[1F[1F[1F[1FEOL
Success 0 Failure 0 EOL
3:3-18145A0A 5/ 5 [ ] FB: Done EOL
Test Configuration:
- Operating System: Linux (Ubuntu 22.04)
- Toolchain: GCC 11.4.0 with glibc 2.38
It broken normal user case. Print may mass when use correct console. Generally, if uuu work as subprocess, use -v option to print raw log to easy parser by other program.
Hi @nxpfrankli, thanks for your fast reply. Proposed patch does not break anything when using uuu on a regular console (where tests where conducted)
Spaces count required to hide previous progress result is stored within a variable instead of printing spaces based on terminal width.
Please add signed-off at your each commit
Please add signed-off at your each commit
Done