Skip to content

Commit

Permalink
timesync: improve debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Oct 8, 2023
1 parent 3469307 commit 393163a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions quectel-timesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ int parse_response(const char *response, uint16_t *output) {
copy_and_parse_field(response, 18, 2, &output[DATE_TIME_FIELD_SECOND]);

if (debug) {
#define PRINT_FIELD(label, value) fprintf(stdout, "%s: %d\n", label, value)
fprintf(stdout, "Parsed DateTime:\n");
#define PRINT_FIELD(label, value) fprintf(stdout, " %s: %d\n", label, value)
PRINT_FIELD("Year", output[DATE_TIME_FIELD_YEAR]);
PRINT_FIELD("Month", output[DATE_TIME_FIELD_MONTH]);
PRINT_FIELD("Day", output[DATE_TIME_FIELD_DAY]);
Expand All @@ -182,7 +183,7 @@ int set_date_and_time(uint16_t *fields) {
fields[DATE_TIME_FIELD_SECOND]);

if (debug)
fprintf(stdout, "%s\n", buf);
fprintf(stdout, "Execute: %s\n", buf);

system(buf);

Expand Down Expand Up @@ -211,6 +212,10 @@ int perform_timesync(int serial_fd) {
return -1;
}

if (debug) {
fprintf(stdout, "Read from serial: %s\n", buf);
}

if (parse_response(buf, fields)) {
fprintf(stderr, "Unable to parse response\n");
return -1;
Expand Down

0 comments on commit 393163a

Please sign in to comment.