1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-23 19:47:30 +02:00

lpc111x-isp/lpc111x.c (identify): retrieve and print the chip's unique ID

This commit is contained in:
Werner Almesberger 2012-12-29 21:12:09 -03:00
parent eda1135cb0
commit 505caf997b

View File

@ -225,7 +225,7 @@ static const struct device {
static void identify(void)
{
const char *res;
unsigned id;
unsigned id, serial[4];
res = dialog_rc(100, "J");
if (sscanf(res, "%u", &id) != 1) {
@ -233,12 +233,21 @@ static void identify(void)
exit(1);
}
res = dialog_rc(100, "N");
if (sscanf(res, "%u %u %u %u",
serial, serial+1, serial+2, serial+3) != 4) {
fprintf(stderr, "N: cannot parse serial number\"%s\"\n", res);
exit(1);
}
for (device = devices; device->name; device++)
if (device->id == id) {
if (!quiet)
fprintf(stderr, "%s (0x%04x %04x) %d kB\n",
fprintf(stderr, "%s (0x%04x %04x) %d kB "
"serial %08x.%08x.%08x.%08x\n",
device->name, id >> 16, id & 0xffff,
device->flash_kb);
device->flash_kb,
serial[0], serial[1], serial[2], serial[3]);
return;
}