+/*
+ * piBoardId:
+ * Do more digging into the board revision string as above, but return
+ * as much details as we can.
+ *********************************************************************************
+ */
+
+const char *piModelNames [] =
+{
+ "Model A",
+ "Model B",
+ "Compute Module",
+} ;
+
+const char *piRevisionNames[] =
+{
+ "1",
+ "1.1",
+ "2",
+} ;
+
+void piBoardId (int *model, int *rev, int *mem, char **maker)
+{
+ FILE *cpuFd ;
+ char line [120] ;
+ char *c ;
+
+ piBoardRev () ; // Call this first to make sure all's OK. Don't care about the result.
+
+ if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
+ piBoardRevOops ("Unable to open /proc/cpuinfo") ;
+
+ while (fgets (line, 120, cpuFd) != NULL)
+ if (strncmp (line, "Revision", 8) == 0)
+ break ;
+
+ fclose (cpuFd) ;
+
+ if (strncmp (line, "Revision", 8) != 0)
+ piBoardRevOops ("No \"Revision\" line") ;
+
+// Chomp trailing CR/NL
+
+ for (c = &line [strlen (line) - 1] ; (*c == '\n') || (*c == '\r') ; --c)
+ *c = 0 ;
+
+ if (wiringPiDebug)
+ printf ("piboardId: Revision string: %s\n", line) ;
+
+// Scan to first digit
+
+ for (c = line ; *c ; ++c)
+ if (isdigit (*c))
+ break ;
+
+// Make sure its long enough
+
+ if (strlen (c) < 4)
+ piBoardRevOops ("Bogus \"Revision\" line") ;
+
+// Extract last 4 characters:
+
+ c = c + strlen (c) - 4 ;
+
+// Fill out the replys as appropriate
+
+ /**/ if (strcmp (c, "0002") == 0) { *model = 1 ; *rev = 0 ; *mem = 256 ; *maker = "China" ; }
+ else if (strcmp (c, "0003") == 0) { *model = 1 ; *rev = 1 ; *mem = 256 ; *maker = "China" ; }
+ else if (strcmp (c, "0004") == 0) { *model = 1 ; *rev = 2 ; *mem = 256 ; *maker = "Sony" ; }
+ else if (strcmp (c, "0005") == 0) { *model = 1 ; *rev = 2 ; *mem = 256 ; *maker = "Qisda" ; }
+ else if (strcmp (c, "0006") == 0) { *model = 1 ; *rev = 2 ; *mem = 256 ; *maker = "Egoman" ; }
+ else if (strcmp (c, "0007") == 0) { *model = 0 ; *rev = 2 ; *mem = 256 ; *maker = "Egoman" ; }
+ else if (strcmp (c, "0008") == 0) { *model = 0 ; *rev = 2 ; *mem = 256 ; *maker = "Sony" ; }
+ else if (strcmp (c, "0009") == 0) { *model = 1 ; *rev = 2 ; *mem = 256 ; *maker = "Qisda" ; }
+ else if (strcmp (c, "000d") == 0) { *model = 1 ; *rev = 2 ; *mem = 512 ; *maker = "Egoman" ; }
+ else if (strcmp (c, "000e") == 0) { *model = 1 ; *rev = 2 ; *mem = 512 ; *maker = "Sony" ; }
+ else if (strcmp (c, "000f") == 0) { *model = 1 ; *rev = 2 ; *mem = 512 ; *maker = "Egoman" ; }
+ else if (strcmp (c, "0011") == 0) { *model = 2 ; *rev = 1 ; *mem = 512 ; *maker = "Sony" ; }
+ else { *model = 0 ; *rev = 0 ; *mem = 0 ; *maker = "Unkn" ; }
+}
+
+
+