#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include "bcm_host.h"
#pragma GCC diagnostic pop
//-------------------------------------------------------------------------
int main(void)
{
bcm_host_init();
char response[1024];
uint32_t serial = 0;
memset(response, 0, sizeof(response));
if (vc_gencmd(response, sizeof(response), "otp_dump") == 0)
{
char *saveptr = NULL;
char *token = strtok_r(response, "\n", &saveptr);
while (token != NULL)
{
int index;
char value[100];
if (sscanf(token, "%d:%s", &index, value) == 2)
{
if (index == 28)
{
serial = strtoul(value, 0, 16);
}
}
token = strtok_r(NULL, "\n", &saveptr);
}
}
printf("serial: %016"PRIx32"\n", serial);
return 0;
}
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#include "bcm_host.h"
#pragma GCC diagnostic pop
//-------------------------------------------------------------------------
int main(void)
{
bcm_host_init();
char response[1024];
uint32_t serial = 0;
memset(response, 0, sizeof(response));
if (vc_gencmd(response, sizeof(response), "otp_dump") == 0)
{
char *saveptr = NULL;
char *token = strtok_r(response, "\n", &saveptr);
while (token != NULL)
{
int index;
char value[100];
if (sscanf(token, "%d:%s", &index, value) == 2)
{
if (index == 28)
{
serial = strtoul(value, 0, 16);
}
}
token = strtok_r(NULL, "\n", &saveptr);
}
}
printf("serial: %016"PRIx32"\n", serial);
return 0;
}