1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
// Copyright 2017 the gousb Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package gousb
// fake devices connected through the fakeLibusb stack.
type fakeDevice struct {
devDesc *DeviceDesc
strDesc map[int]string
alt uint8
}
var fakeDevices = []fakeDevice{
// Bus 001 Device 001: ID 9999:0001
// One config, one interface, one setup,
// two endpoints: 0x01 OUT, 0x82 IN.
{
devDesc: &DeviceDesc{
Bus: 1,
Address: 1,
Port: 1,
Spec: Version(2, 0),
Device: Version(1, 0),
Vendor: ID(0x9999),
Product: ID(0x0001),
Protocol: 255,
Configs: map[int]ConfigDesc{1: {
Number: 1,
MaxPower: Milliamperes(100),
Interfaces: []InterfaceDesc{{
Number: 0,
AltSettings: []InterfaceSetting{{
Number: 0,
Alternate: 0,
Class: ClassVendorSpec,
Endpoints: map[EndpointAddress]EndpointDesc{
0x01: {
Address: 0x01,
Number: 1,
Direction: EndpointDirectionOut,
MaxPacketSize: 512,
TransferType: TransferTypeBulk,
},
0x82: {
Address: 0x82,
Number: 2,
Direction: EndpointDirectionIn,
MaxPacketSize: 512,
TransferType: TransferTypeBulk,
},
},
}},
}},
}},
},
},
// Bus 001 Device 002: ID 8888:0002
// One config, two interfaces. interface #0 with no endpoints,
// interface #1 with two alt setups with different packet sizes for
// endpoints. Two isochronous endpoints, 0x05 OUT and 0x86 OUT.
{
devDesc: &DeviceDesc{
Bus: 1,
Address: 2,
Port: 2,
Spec: Version(2, 0),
Device: Version(1, 3),
Vendor: ID(0x8888),
Product: ID(0x0002),
Protocol: 255,
Configs: map[int]ConfigDesc{1: {
Number: 1,
MaxPower: Milliamperes(100),
iConfiguration: 5,
Interfaces: []InterfaceDesc{{
Number: 0,
AltSettings: []InterfaceSetting{{
Number: 0,
Alternate: 0,
Class: ClassVendorSpec,
iInterface: 6,
}},
}, {
Number: 1,
AltSettings: []InterfaceSetting{{
Number: 1,
Alternate: 0,
Class: ClassVendorSpec,
Endpoints: map[EndpointAddress]EndpointDesc{
0x05: {
Address: 0x05,
Number: 5,
Direction: EndpointDirectionOut,
MaxPacketSize: 3 * 1024,
TransferType: TransferTypeIsochronous,
UsageType: IsoUsageTypeData,
},
0x86: {
Address: 0x86,
Number: 6,
Direction: EndpointDirectionIn,
MaxPacketSize: 3 * 1024,
TransferType: TransferTypeIsochronous,
UsageType: IsoUsageTypeData,
},
},
iInterface: 7,
}, {
Number: 1,
Alternate: 1,
Class: ClassVendorSpec,
Endpoints: map[EndpointAddress]EndpointDesc{
0x05: {
Address: 0x05,
Number: 5,
Direction: EndpointDirectionOut,
MaxPacketSize: 2 * 1024,
TransferType: TransferTypeIsochronous,
},
0x86: {
Address: 0x86,
Number: 6,
Direction: EndpointDirectionIn,
MaxPacketSize: 2 * 1024,
TransferType: TransferTypeIsochronous,
},
},
iInterface: 8,
}, {
Number: 1,
Alternate: 2,
Class: ClassVendorSpec,
Endpoints: map[EndpointAddress]EndpointDesc{
0x05: {
Address: 0x05,
Number: 5,
Direction: EndpointDirectionIn,
MaxPacketSize: 1024,
TransferType: TransferTypeIsochronous,
},
0x86: {
Address: 0x86,
Number: 6,
Direction: EndpointDirectionIn,
MaxPacketSize: 1024,
TransferType: TransferTypeIsochronous,
},
},
}},
}, {
// Malformed descriptior, non contiguous interface
// number (previous interface is #1), alt settings
// not starting from 0.
// See https://github.com/google/gousb/issues/65
Number: 3,
AltSettings: []InterfaceSetting{{
Number: 3,
Alternate: 2,
Class: ClassVendorSpec,
iInterface: 9,
}},
}},
}},
iManufacturer: 1,
iProduct: 2,
iSerialNumber: 3,
},
strDesc: map[int]string{
1: "ACME Industries",
2: "Fidgety Gadget",
3: "01234567",
5: "Weird configuration",
6: "Boring setting",
7: "Fast streaming",
8: "Slower streaming",
9: "Interface for https://github.com/google/gousb/issues/65",
},
},
// Bus 001 Device 003: ID 9999:0002
// One config, one interface, one setup,
// two endpoints: 0x01 OUT, 0x81 IN.
{
devDesc: &DeviceDesc{
Bus: 1,
Address: 3,
Port: 3,
Spec: Version(2, 0),
Device: Version(1, 0),
Vendor: ID(0x1111),
Product: ID(0x1111),
Protocol: 255,
Configs: map[int]ConfigDesc{1: {
Number: 1,
MaxPower: Milliamperes(100),
Interfaces: []InterfaceDesc{{
Number: 0,
AltSettings: []InterfaceSetting{{
Number: 0,
Alternate: 0,
Class: ClassVendorSpec,
Endpoints: map[EndpointAddress]EndpointDesc{
0x01: {
Address: 0x01,
Number: 1,
Direction: EndpointDirectionOut,
MaxPacketSize: 512,
TransferType: TransferTypeBulk,
},
0x81: {
Address: 0x81,
Number: 1,
Direction: EndpointDirectionIn,
MaxPacketSize: 512,
TransferType: TransferTypeBulk,
},
},
}},
}},
}},
},
},
}
|