public void CreateUSBDevice() { SoftUSBDeviceQualifier piDeviceQual = new SoftUSBDeviceQualifier(); m_piSoftUSBDevice = new SoftUSBDevice(); //Setup the device qualifier piDeviceQual.USB = 0x0200; //binary coded decimal USB version 2.0 piDeviceQual.DeviceClass = 0xff; //FF=Vendor specfic device class piDeviceQual.DeviceSubClass = 0xff; //FF = Vendor specific device sub-class piDeviceQual.DeviceProtocol = 0xff; //FF = Vendor specific device protocol piDeviceQual.MaxPacketSize0 = 64; //max packet size endpoint 0 piDeviceQual.NumConfigurations = 1; //Number of configurations //Setup the device m_piSoftUSBDevice.USB = 0x0200; m_piSoftUSBDevice.DeviceClass = 0xff; //FF=Vendor specfic device class m_piSoftUSBDevice.DeviceSubClass = 0xff; //FF = Vendor specific device sub-class m_piSoftUSBDevice.DeviceProtocol = 0xff; //FF = Vendor specific device protocol m_piSoftUSBDevice.MaxPacketSize0 = 64; //max packet size endpoint 0 m_piSoftUSBDevice.Product = (short)usProductId; //product id - BulkUSB m_piSoftUSBDevice.Vendor = (short)usVendorId; //Vendor ID - Microsoft m_piSoftUSBDevice.Device = 0x0100; m_piSoftUSBDevice.RemoteWakeup = false; m_piSoftUSBDevice.Manufacturer = STRING_IDX_MANUFACTURER; m_piSoftUSBDevice.ProductDesc = STRING_IDX_PRODUCT_DESC; m_piSoftUSBDevice.HasExternalPower = true; CreateStrings(); m_piSoftUSBDevice.DeviceQualifier = piDeviceQual; }
public void RunSimulatedDevices() { try { dsf = new DSF.DSF(); object obj = Activator.CreateInstance(Type.GetTypeFromProgID("SoftUSBLoopback.LoopbackDevice")); LoopbackDev = (LoopbackDevice)obj; LoopbackDSFDev = LoopbackDev.DSFDevice; LoopbackUSBDev = LoopbackDSFDev.Object[IID_ISoftUSBDevice]; bus = dsf.HotPlug(LoopbackDSFDev, "USB2.0"); IsRunning = true; LoopbackDev.OnProcessingData += LoopbackDev_OnProcessingData; LoopbackDev.DoPolledLoopback(100); } catch (Exception ee) { UnPlugUSB(); LogHelper.GetLogger <USBDevice>().Error(string.Format("Run simulate USB device error. Error message is : {0} \n {1}", ee.Message, ee.StackTrace)); } }