From 505caf997b54140dddccb96dcfb315d4b84eecdf Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 29 Dec 2012 21:12:09 -0300 Subject: [PATCH] lpc111x-isp/lpc111x.c (identify): retrieve and print the chip's unique ID --- lpc111x-isp/lpc111x.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lpc111x-isp/lpc111x.c b/lpc111x-isp/lpc111x.c index 3f28ba5..ff92bdc 100644 --- a/lpc111x-isp/lpc111x.c +++ b/lpc111x-isp/lpc111x.c @@ -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; }