mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 21:23:09 +02:00
lpc111x-isp/lpc111x.c (identify): retrieve and print the chip's unique ID
This commit is contained in:
parent
eda1135cb0
commit
505caf997b
@ -225,7 +225,7 @@ static const struct device {
|
|||||||
static void identify(void)
|
static void identify(void)
|
||||||
{
|
{
|
||||||
const char *res;
|
const char *res;
|
||||||
unsigned id;
|
unsigned id, serial[4];
|
||||||
|
|
||||||
res = dialog_rc(100, "J");
|
res = dialog_rc(100, "J");
|
||||||
if (sscanf(res, "%u", &id) != 1) {
|
if (sscanf(res, "%u", &id) != 1) {
|
||||||
@ -233,12 +233,21 @@ static void identify(void)
|
|||||||
exit(1);
|
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++)
|
for (device = devices; device->name; device++)
|
||||||
if (device->id == id) {
|
if (device->id == id) {
|
||||||
if (!quiet)
|
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->name, id >> 16, id & 0xffff,
|
||||||
device->flash_kb);
|
device->flash_kb,
|
||||||
|
serial[0], serial[1], serial[2], serial[3]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user