2014-02-27 05:59:38 +05:30
|
|
|
package host
|
|
|
|
|
2014-03-01 20:19:44 +05:30
|
|
|
import "errors"
|
2014-02-27 05:59:38 +05:30
|
|
|
|
|
|
|
type Descriptor struct {
|
2014-03-01 20:19:44 +05:30
|
|
|
GPIO func() interface{}
|
|
|
|
I2C func() interface{}
|
2014-02-27 05:59:38 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
type Describer func(rev int) *Descriptor
|
|
|
|
|
|
|
|
var Describers = map[Host]Describer{}
|
|
|
|
|
|
|
|
func Describe() (*Descriptor, error) {
|
|
|
|
host, rev, err := Detect()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
describer, ok := Describers[host]
|
|
|
|
if !ok {
|
|
|
|
return nil, errors.New("host: invalid host")
|
|
|
|
}
|
|
|
|
|
|
|
|
return describer(rev), nil
|
|
|
|
}
|