private WindowsUsbInterface GetInterface(SafeFileHandle interfaceHandle) { //TODO: We need to get the read/write size from a different API call... //TODO: Where is the logger/tracer? var isSuccess = WinUsbApiCalls.WinUsb_QueryInterfaceSettings(interfaceHandle, 0, out var interfaceDescriptor); var retVal = new WindowsUsbInterface(interfaceHandle, interfaceDescriptor.bInterfaceNumber, Logger, ReadBufferSizeProtected, WriteBufferSizeProtected); _ = WindowsHelpers.HandleError(isSuccess, "Couldn't query interface", Logger); Logger.LogInformation( "Found Interface Number: {interfaceNumber} Endpoint count: {endpointCount} Class: {class} Subclass: {subClass}", interfaceDescriptor.bInterfaceNumber, interfaceDescriptor.bNumEndpoints, interfaceDescriptor.bInterfaceClass, interfaceDescriptor.bInterfaceSubClass); for (byte i = 0; i < interfaceDescriptor.bNumEndpoints; i++) { isSuccess = WinUsbApiCalls.WinUsb_QueryPipe(interfaceHandle, 0, i, out var pipeInfo); _ = WindowsHelpers.HandleError(isSuccess, "Couldn't query endpoint", Logger); Logger.LogInformation("Found PipeId: {pipeId} PipeType: {pipeType} MaxPacketSize: {maxPacketSize}", pipeInfo.PipeId, pipeInfo.PipeType, pipeInfo.MaximumPacketSize); //TODO: We are dropping the max packet size here... retVal.UsbInterfaceEndpoints.Add(new WindowsUsbInterfaceEndpoint(pipeInfo.PipeId, pipeInfo.PipeType, pipeInfo.MaximumPacketSize)); } return(retVal); }
private WindowsUsbInterface GetInterface(SafeFileHandle interfaceHandle) { //TODO: We need to get the read/write size from a different API call... //TODO: Where is the logger/tracer? var isSuccess = WinUsbApiCalls.WinUsb_QueryInterfaceSettings(interfaceHandle, 0, out var interfaceDescriptor); var retVal = new WindowsUsbInterface(interfaceHandle, Logger, Tracer, interfaceDescriptor.bInterfaceNumber, _ReadBufferSize, _WriteBufferSize); WindowsDeviceBase.HandleError(isSuccess, "Couldn't query interface"); for (byte i = 0; i < interfaceDescriptor.bNumEndpoints; i++) { isSuccess = WinUsbApiCalls.WinUsb_QueryPipe(interfaceHandle, 0, i, out var pipeInfo); WindowsDeviceBase.HandleError(isSuccess, "Couldn't query endpoint"); retVal.UsbInterfaceEndpoints.Add(new WindowsUsbInterfaceEndpoint(pipeInfo.PipeId, pipeInfo.PipeType)); } return(retVal); }