Modify stm32mon to better suite autotest use
Modify stm32mon to better suite autotest use

This change introduces the following modifications:

When used outside chroot on Goobuntu the serial interface fails to initialize
if parity enable bit is set (for a reason not clearly understood). On top of
that the tcsetattr() return value of zero is not a guarantee of success. To be
sure that the settings came through one is supposed to read back the driver
config and compare it with the desired config.

To add insult to injury, gPrecise driver rejects attempts to enable parity.
Parity setting is not essential in many cases, this is why we check the actual
config and if the only missing setting is parity we print a warning message
and continue.

In case an operation fails, the exit value should reflect that (so
that the autotest suite using the utility could report failure).

Often when the programming attempt is undertaken soon after reset,
this utility gets overwhelmed with the console output generated by the
EC on resets. Consume the output before proceeding.

Instead of printing a long set of dots (one per written/read block),
print a spinning wheel instead.

BRANCH=None
BUG=chrome-os-partner:15610
TEST=manual

   . used the utility to program Snow EC both inside and outside
     chroot, it succeeded.

    Observed the failing attempt to set parity when running outside
    chroot.

    Observed spinning characters instead of stream of dots.

Change-Id: Id25595d35a2a3ca578639cebd508f599e618787c
Signed-off-by: Vadim Bendebury <5515d6d2d0829cbe0dd0dcf2094aaded06d58514@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42310
Reviewed-by: Vincent Palatin <70a9964ec8fd10b0b08fcc8623c2add25ddf99ac@chromium.org>

mtk09422/chromiumos-platform-ec,mtk09422/chromiumos-platform-ec,alterapraxisptyltd/chromium-ec,longsleep/ec,fourier49/BIZ_EC,coreboot/chrome-ec,fourier49/BZ_DEV_EC,akappy7/ChromeOS_EC_LED_Diagnostics,akappy7/ChromeOS_EC_LED_Diagnostics,alterapraxisptyltd/chromium-ec,coreboot/chrome-ec,longsleep/ec,fourier49/BIZ_EC,coreboot/chrome-ec,md5555/ec,gelraen/cros-ec,longsleep/ec,akappy7/ChromeOS_EC_LED_Diagnostics,alterapraxisptyltd/chromium-ec,coreboot/chrome-ec,fourier49/BZ_DEV_EC,eatbyte/chromium-ec,eatbyte/chromium-ec,fourier49/BIZ_EC,thehobn/ec,md5555/ec,md5555/ec,mtk09422/chromiumos-platform-ec,fourier49/BZ_DEV_EC,coreboot/chrome-ec,fourier49/BZ_DEV_EC,gelraen/cros-ec,thehobn/ec,gelraen/cros-ec,thehobn/ec,mtk09422/chromiumos-platform-ec,alterapraxisptyltd/chromium-ec,fourier49/BIZ_EC,coreboot/chrome-ec,gelraen/cros-ec,eatbyte/chromium-ec,longsleep/ec,md5555/ec,akappy7/ChromeOS_EC_LED_Diagnostics,thehobn/ec,eatbyte/chromium-ec,akappy7/ChromeOS_EC_LED_Diagnostics