Add ack failure count to XModem status
This commit is contained in:
parent
cb64ea4198
commit
8182b384ba
3 changed files with 9 additions and 6 deletions
|
|
@ -216,17 +216,18 @@ cheerios_insert(const char *buf, size_t len)
|
|||
|
||||
|
||||
static void
|
||||
__xmodem_callback(size_t sent, size_t total)
|
||||
__xmodem_callback(size_t sent, size_t total, int ack_fails)
|
||||
{
|
||||
char status_str[1024];
|
||||
|
||||
|
||||
snprintf(
|
||||
status_str, sizeof(status_str),
|
||||
"\r %.02f/%.02fKB (%.01f%%)",
|
||||
"\r %.02f/%.02fKB (%.01f%%, %d ACK fails)",
|
||||
(sent / 1024.0),
|
||||
(total / 1024.0),
|
||||
(sent * 100.0 / total)
|
||||
(sent * 100.0 / total),
|
||||
ack_fails
|
||||
);
|
||||
|
||||
cheerios_insert(status_str, strlen(status_str));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ xmodem_send(
|
|||
int in_fd,
|
||||
size_t sz,
|
||||
int block_sz,
|
||||
void (*status_cb)(size_t sent, size_t total)
|
||||
void (*status_cb)(size_t sent, size_t total, int ack_fails)
|
||||
)
|
||||
{
|
||||
uint8_t start_byte;
|
||||
|
|
@ -30,6 +30,7 @@ xmodem_send(
|
|||
uint8_t packet_num;
|
||||
int retries;
|
||||
int ret = 0;
|
||||
int ack_fails = 0;
|
||||
|
||||
if (block_sz != 128 && block_sz != 1024) {
|
||||
return -1;
|
||||
|
|
@ -120,11 +121,12 @@ xmodem_send(
|
|||
}
|
||||
|
||||
retries++;
|
||||
ack_fails++;
|
||||
}
|
||||
|
||||
sent += read_len;
|
||||
packet_num++; /* expect overflow */
|
||||
status_cb(sent, sz);
|
||||
status_cb(sent, sz, ack_fails);
|
||||
}
|
||||
|
||||
end_of_transmission:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ int xmodem_send(
|
|||
int in_fd,
|
||||
size_t sz,
|
||||
int block_sz,
|
||||
void (*status_cb)(size_t sent, size_t total)
|
||||
void (*status_cb)(size_t sent, size_t total, int ack_fails)
|
||||
);
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue