make addr() part of EndpointInfo

This commit is contained in:
Sebastian Zagrodzki
2017-04-09 18:55:41 +02:00
parent 13f4e95f2f
commit f58798160d
2 changed files with 8 additions and 8 deletions

View File

@@ -44,14 +44,18 @@ type EndpointInfo struct {
UsageType UsageType
}
// String returns the human-readable description of the endpoint.
func (e EndpointInfo) String() string {
func (e EndpointInfo) addr() uint8 {
addr := e.Number
if e.Direction == EndpointDirectionIn {
addr |= 0x80
}
return addr
}
// String returns the human-readable description of the endpoint.
func (e EndpointInfo) String() string {
ret := make([]string, 0, 3)
ret = append(ret, fmt.Sprintf("Endpoint #%d %s (address 0x%02x) %s", e.Number, e.Direction, addr, e.TransferType))
ret = append(ret, fmt.Sprintf("Endpoint #%d %s (address 0x%02x) %s", e.Number, e.Direction, e.addr(), e.TransferType))
switch e.TransferType {
case TransferTypeIsochronous:
ret = append(ret, fmt.Sprintf("- %s %s", e.IsoSyncType, e.UsageType))