Use Protocol type for USB interface protocol.

This commit is contained in:
Sebastian Zagrodzki
2017-04-09 18:42:04 +02:00
parent d3428d9b35
commit f91d53931a
7 changed files with 20 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ func Describe(val interface{}) string {
func Classify(val interface{}) string {
var (
class, sub usb.Class
proto uint8
proto usb.Protocol
)
switch val := val.(type) {
case *usb.Descriptor:

View File

@@ -63,7 +63,7 @@ func (c Class) String() string {
// A SubClass contains the name of the subclass and any associated protocols.
type SubClass struct {
Name string
Protocol map[uint8]string
Protocol map[usb.Protocol]string
}
// String returns the name of the SubClass.
@@ -186,9 +186,9 @@ func ParseIDs(r io.Reader) (map[usb.ID]*Vendor, map[usb.Class]*Class, error) {
}
if subclass.Protocol == nil {
subclass.Protocol = make(map[uint8]string)
subclass.Protocol = make(map[usb.Protocol]string)
}
subclass.Protocol[uint8(id)] = name
subclass.Protocol[usb.Protocol(id)] = name
default:
return fmt.Errorf("too many levels of nesting for class")

View File

@@ -64,7 +64,7 @@ var (
0x01: {Name: "Direct Line"},
0x02: {
Name: "Abstract (modem)",
Protocol: map[uint8]string{
Protocol: map[usb.Protocol]string{
0x00: "None",
0x01: "AT-commands (v.25ter)",
0x02: "AT-commands (PCCA101)",