Add progressbar for read and write command (#912)

This commit is contained in:
Hans 2022-03-31 22:21:49 +02:00 committed by GitHub
parent 79c4137289
commit 1d0cbc2246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -302,6 +302,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
return -1; return -1;
} }
report_progress(0, 1, "Reading");
for (uint32_t i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
int32_t rc = pgm->read_byte(pgm, p, mem, addr + i, &buf[i]); int32_t rc = pgm->read_byte(pgm, p, mem, addr + i, &buf[i]);
if (rc != 0) { if (rc != 0) {
@ -312,7 +313,9 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
mem->desc); mem->desc);
return -1; return -1;
} }
report_progress(i, len, NULL);
} }
report_progress(1, 1, NULL);
hexdump_buf(stdout, addr, buf, len); hexdump_buf(stdout, addr, buf, len);
fprintf(stdout, "\n"); fprintf(stdout, "\n");
@ -508,7 +511,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
return -1; return -1;
} }
avrdude_message(MSG_NOTICE, "Info: Writing %d bytes starting from address 0x%02x", avrdude_message(MSG_NOTICE, "\nInfo: Writing %d bytes starting from address 0x%02x",
len + data.bytes_grown, addr); len + data.bytes_grown, addr);
if (write_mode == WRITE_MODE_FILL) if (write_mode == WRITE_MODE_FILL)
avrdude_message(MSG_NOTICE, ". Remaining space filled with %s", argv[argc - 2]); avrdude_message(MSG_NOTICE, ". Remaining space filled with %s", argv[argc - 2]);
@ -516,6 +519,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
pgm->err_led(pgm, OFF); pgm->err_led(pgm, OFF);
bool werror = false; bool werror = false;
report_progress(0, 1, "Writing");
for (i = 0; i < (len + data.bytes_grown); i++) { for (i = 0; i < (len + data.bytes_grown); i++) {
int32_t rc = avr_write_byte(pgm, p, mem, addr+i, buf[i]); int32_t rc = avr_write_byte(pgm, p, mem, addr+i, buf[i]);
if (rc) { if (rc) {
@ -538,12 +542,13 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
if (werror) { if (werror) {
pgm->err_led(pgm, ON); pgm->err_led(pgm, ON);
} }
report_progress(i, (len + data.bytes_grown), NULL);
} }
report_progress(1, 1, NULL);
free(buf); free(buf);
fprintf(stdout, "\n");
return 0; return 0;
} }