Handle failures in fread from TX callback.
This commit is contained in:

committed by
Michael Ossmann

parent
cb8fc333aa
commit
2448796e35
@ -523,6 +523,13 @@ int tx_callback(hackrf_transfer* transfer)
|
|||||||
} else {
|
} else {
|
||||||
/* Read samples from file. */
|
/* Read samples from file. */
|
||||||
bytes_read = fread(transfer->buffer, 1, bytes_to_read, file);
|
bytes_read = fread(transfer->buffer, 1, bytes_to_read, file);
|
||||||
|
|
||||||
|
/* If no more bytes, error or file empty, treat as end. */
|
||||||
|
if (bytes_read == 0) {
|
||||||
|
completed_byte_count += transfer->valid_length;
|
||||||
|
tx_complete = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accumulate power (magnitude squared). */
|
/* Accumulate power (magnitude squared). */
|
||||||
@ -569,6 +576,12 @@ int tx_callback(hackrf_transfer* transfer)
|
|||||||
bytes_to_read - bytes_read,
|
bytes_to_read - bytes_read,
|
||||||
file);
|
file);
|
||||||
|
|
||||||
|
/* If no more bytes, error or file empty, use what we have. */
|
||||||
|
if (extra_bytes_read == 0) {
|
||||||
|
tx_complete = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Accumulate power for the additional samples. */
|
/* Accumulate power for the additional samples. */
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (i = 0; i < extra_bytes_read; i++) {
|
for (i = 0; i < extra_bytes_read; i++) {
|
||||||
|
Reference in New Issue
Block a user