aws / amazon-freertos

DEPRECATED - See README.md
https://aws.amazon.com/freertos/
MIT License
2.54k stars 1.1k forks source link

[BUG] Trace output of ESP32-DevKitC jobs demo is clobbered #3543

Open cookpate opened 1 year ago

cookpate commented 1 year ago

Describe the bug A help message is printed out when the jobs_for_aws demo first runs. On the ESP32 DevKit at least, the message ends up clobbered and doesn't print out in full. I initially thought I was going to a dead link in the docs.

System information

Expected behavior The help message should be displayed in full without any clobbering as shown: https://github.com/aws/amazon-freertos/blob/49e7fe5d667362ce90bcd03b12633361d6e6f220/demos/jobs_for_aws/jobs_demo.c#L828-L854

Screenshots or console output

14 495 [iot_thread] [jobs_demo.c:833] [INFO] [JobsDemo]
/*-----------------------------------------------------------*/

The Jobs demo is now ready to accept Jobs.
https://docs.aws.amazon.com/cli/latest/reference/iot/create-job.htmlJobsDemo]

 - print          ] [jobs_demo.c:843] [INFO] [JobsDemo]  key.
   Logs a message to the local console. The Job document must also contain a "message".
 - publish        "action17 495 [iot_thread] [jobs_demo.c:846] [INFO] [JobsDemo]
   Publishes a message to an MQTT topic. The Job document must also contain a "message" and "topic".

   For example: { "action": "publish", "topic": "demo/jobs", "message": "Hello world!"} will cause
 - exit           to be published 19 495 [iot_thread] [jobs_demo.c:854] [INFO] [JobsDemo]
   Exits the demo program. This program will run until { "action": "exit" } is received.

/*--------------------20 495 [iot_thread] [mqtt_demo_helpers.c:565] [INFO] [MQTT] Attempt to subscribe to the MQTT topic $aws/things/cookpateESP32-TestBoard/jobs/notify-next.

Steps to reproduce bug Example:

  1. Configure to run the Jobs Demo (#define CONFIG_JOBS_DEMO_ENABLED in aws_demo_config.h)
  2. In the root directory with a configured ESP32 thing plugged in, flash and monitor the demo
cookpate commented 1 year ago

This actually looks more like a race condition in LogInfo for this demo. IT should have printed out an example job, but this is an example console output in the ESP-IDF 4.2 PowerShell window:

14 495 [iot_thread] [jobs_demo.c:833] [INFO] [JobsDemo]
/*-----------------------------------------------------------*/

The Jobs demo is now ready to accept Jobs.
https://docs.aws.amazon.com/cli/latest/reference/iot/create-job.htmlJobsDemo]

 - print          ] [jobs_demo.c:843] [INFO] [JobsDemo]  key.
   Logs a message to the local console. The Job document must also contain a "message".
 - publish        "action17 495 [iot_thread] [jobs_demo.c:846] [INFO] [JobsDemo]
   Publishes a message to an MQTT topic. The Job document must also contain a "message" and "topic".

   For example: { "action": "publish", "topic": "demo/jobs", "message": "Hello world!"} will cause
 - exit           to be published 19 495 [iot_thread] [jobs_demo.c:854] [INFO] [JobsDemo]
   Exits the demo program. This program will run until { "action": "exit" } is received.

/*--------------------20 495 [iot_thread] [mqtt_demo_helpers.c:565] [INFO] [MQTT] Attempt to subscribe to the MQTT topic $aws/things/cookpateESP32-TestBoard/jobs/notify-next.

This is printed out from here: https://github.com/aws/amazon-freertos/blob/49e7fe5d667362ce90bcd03b12633361d6e6f220/demos/jobs_for_aws/jobs_demo.c#L828-L854

cookpate commented 1 year ago

Ah, it looks like the carriage return at the beginning of log messages isn't overwriting the current line. It's a hacky way of suppressing the log message header.