libbladeRF: image: bladerf_image_print_metadata added
Ex: Magic: bladeRF Version: 0.1.0 Timestamp: 655e530f Serial: Address: 0 Length: 0
This commit is contained in:
parent
986c3a3353
commit
eb3d128a8d
2 changed files with 38 additions and 0 deletions
|
|
@ -3432,6 +3432,27 @@ struct bladerf_image *CALL_CONV bladerf_alloc_cal_image(
|
|||
API_EXPORT
|
||||
void CALL_CONV bladerf_free_image(struct bladerf_image *image);
|
||||
|
||||
/**
|
||||
* @brief Prints the metadata of a bladeRF image structure.
|
||||
*
|
||||
* This function displays the metadata of a provided `bladerf_image` structure.
|
||||
* It includes information such as the magic number, version, timestamp, serial number,
|
||||
* address, and length of the image. The function will return an error code if the
|
||||
* provided image pointer is `NULL`.
|
||||
*
|
||||
* @pre The image should have been allocated using bladerf_alloc_image().
|
||||
*
|
||||
* @note This function only prints the metadata of the image and does not
|
||||
* perform any operations on the image data itself.
|
||||
*
|
||||
* @param[in] image Pointer to the `bladerf_image` structure whose metadata is to be printed.
|
||||
* It should not be `NULL`.
|
||||
*
|
||||
* @return 0 on success, BLADERF_ERR_MEM if the image pointer is `NULL`.
|
||||
*/
|
||||
API_EXPORT
|
||||
int CALL_CONV bladerf_image_print_metadata(const struct bladerf_image *image);
|
||||
|
||||
/**
|
||||
* Write a flash image to a file.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -281,6 +281,23 @@ static int unpack_image(struct bladerf_image *img, uint8_t *buf, size_t len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bladerf_image_print_metadata(const struct bladerf_image *image) {
|
||||
if (!image) {
|
||||
return BLADERF_ERR_MEM;
|
||||
}
|
||||
|
||||
printf("Magic: %s\n", image->magic);
|
||||
printf("Version: %d.%d.%d\n",
|
||||
image->version.major, image->version.minor, image->version.patch);
|
||||
printf("Timestamp: %" PRIx64 "\n", image->timestamp);
|
||||
printf("Serial: %s\n", image->serial);
|
||||
printf("Address: %x\n", image->address);
|
||||
printf("Length: %u\n", image->length);
|
||||
fflush(stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bladerf_image_write(struct bladerf *dev,
|
||||
struct bladerf_image *img, const char *file)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue