To get the PCB revision (because at least two pins are different) you should add to gpio_linux.go something like:
var pcbRevision int
func PcbRevision() int {
return pcbRevision
}
func getPcbRevision() int {
r := regexp.MustCompile(`Revision\s*:\s*[0-9a-f]*([0-9a-f]{4})`)
// See http://elinux.org/RPi_HardwareHistory#Board_Revision_History
bytes, err := ioutil.ReadFile("/proc/cpuinfo")
if err != nil {
panic(err)
}
result := r.FindSubmatch(bytes)
if result == nil {
panic("Failed to get Revision from /proc/cpuinfo")
}
revision, err := strconv.ParseInt(string(result[1]), 16, 0)
if err != nil {
panic("Failed to parse Revision from /proc/cpuinfo")
}
if revision < 4 {
return 1
} else {
return 2
}
}
func init() {
pcbRevision = getPcbRevision()
}
To get the PCB revision (because at least two pins are different) you should add to gpio_linux.go something like: