Upload
danghanh
View
218
Download
0
Embed Size (px)
Citation preview
C#LibUsbDotNet2.2.8Introduction
LibUsbDotNetisa.NETC#USBlibraryforWinUsb,libusb-win32,andLinuxlibusbv1.xdevelopers.AllbasicUSBdevicefunctionalitycanbeperformedthroughcommondeviceclassesallowingyoutowriteOSanddriverindependentcode.
LibUsbDotNet-Adevelopmenttoolwrittenfor.NETsoftwaredeveloperswhodesireafastandeasywaytocreateacompletecustomUSBdriversolutionforunix-likeandwindowsplatforms.
Caution:LibUsbDotNetisnotinanywayanend-userdriverorareplacementdriverforexistingwindowsclassdrivers.
Note:LibUsbDotNetversions2.2.4andabovesupporttheLibusb-1.0driver.
Libusb-1.0issupportedunderbothunix-likeandwindowsplatforms.UnderwindowsthenewLibusb-1.0windows-backenddriverisused.Alternatively,MonoLibUsbcanbeuseddirectlytosupportusbdeviceusingonlytheLibusb-1.0driver.
LibUsbDotNet2.1.0andabovesupportsthegenuinelibusb-win32driverpackage.However,accesstobasicdeviceinformationviathewindowsregistryisnotavailable.SeetheLegacyUsbRegistryclassformoreinformation.
Features
FullsupportforWinUSB.AllWinUSBinterfacesaretreatedasseperatedevices.IEeachinterfacecanbeusedbyadifferentapplication.
Extendedkernellevelsupportforlibusb-win32.
http://sourceforge.net/projects/libusbdotnethttp://www.libusb.org/wiki/Libusb1.0http://www.libusb.org/wiki/windows_backendhttp://www.libusb.org/wiki/Libusb1.0http://sourceforge.net/projects/libusb-win32
Supportsunix-likeoperatingsystemsusingmono.NETandLibusb-1.0.
Commondeviceclassesallowforasinglecodebasetosupportmultipledriversandplatforms.
IncludesaUsbInfWizardutility(windowsonly)forgeneratingusbinstallationpackages,removingdevices,andinstallingdrivers.
Devicediscoveryusinganyorallofthefolowingcriteria:
VendorID
ProductID
RevisionCode
SerialNumber
DeviceInterfaceGUID
Sourcepackageincludesmanysmallexampleapplications.
ProjectLinks
DownloadPage
SupportForum
SubmitaBug
ViewOutstandingBugs
libusb-win32ProjectPage
libusb-1.0ProjectPage
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
http://www.mono-project.comhttp://sourceforge.net/projects/libusb/files/libusb-1.0/http://sourceforge.net/projects/libusbdotnet/files/http://sourceforge.net/apps/phpbb/libusbdotnethttp://sourceforge.net/tracker/?func=add&group_id=206606&atid=1140572http://sourceforge.net/tracker/?limit=50&func=&group_id=206606&atid=1140572&status=1&submit=Filterhttp://sourceforge.net/apps/trac/libusb-win32/wikihttp://libusb.orgmailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#LibUsbDotNet2.2.8VersionHistory
ProjectLinks
DownloadPage
SupportForum
SubmitaBug
ViewOutstandingBugs
libusb-win32ProjectPage
libusb-1.0ProjectPage
v2.2.8(10/29/2010)FixedissuewithDataReceivedevent.
WhendisablingtheDataReceviedevent,thepropertywouldreturnbeforetheactionhadbeenfullycarriedout.
Fixedmemoryleakindevicelistfunction.
AnallocatedGCHandlewasnotfreedinthedevicelistingfunctionsresultinginaapplicationmemoryleak.
PreviousVersionsv2.2.7(07/31/2010)
Fixedlibusb-1.0support.
ThiswasbrokenwhenISOendpointsupportwasadded.
HasLibUsbDriver()property
Thispropertywillalwaysreturntrue.
http://sourceforge.net/projects/libusbdotnet/files/http://sourceforge.net/apps/phpbb/libusbdotnethttp://sourceforge.net/tracker/?func=add&group_id=206606&atid=1140572http://sourceforge.net/tracker/?limit=50&func=&group_id=206606&atid=1140572&status=1&submit=Filterhttp://sourceforge.net/apps/trac/libusb-win32/wikihttp://libusb.org
Fixed32bitapplicationsnotrunningon64bitoperatingsystems.(Windows)
IfLibUsbDotNetiscompiledasWin32insteadofAnyCPUitwouldnotworkon64bitoperatingsystemswithlibusb-win32.
UpdatedInfWizardwithembeddedlibusb-win32v1.2.1driverresourcepackage.UpdateddefaultUsbEndpointBase.MaxReadWritechangedbackto65536.Thisisthelimitatwhichlibusbdotnetbeginssplittingtransfers.
v2.2.6(07/10/2010)Removedlibusb-win32(ludn)sourcebranch.
TheLUDNeditionoflibusb-win32hasbeendiscontinuedasitisnolongerneeded.LibUsbDotNetv2.2.6andabovearepackagedwiththeofficiallibusb-win32signeddrivers.(http://sourceforge.net/projects/libusb-win32)
AddedIsochronousendpointsupport.AddedAdditionalsupportforasynchronousI/O.SeetheUsbTransferQueueclassandtheRead.Isochronousexample.UpdatedInfWizardtoincludeanembeddedlibusb-win32driverresourcepackage.
PreviousversionoftheInfWizardrequiredtheusertodownloaddriverresourcepackage(s)beforeitcouldbeused.InfWizardwillcontinuetosupportthesedownloadabledriverpackagesbutnowcomeswithalibusb-win32driverresourcepackageembeddedintoInfWizard.exe.
v2.2.5(04/22/2010)AddedDataReceivedEnabledChangedevent
ThiseventisfiredontheDataReceivedEnabledpropertychangesstate.
UpdatedTheLibUsbDotNetInfWizardhasbeenre-workedand
includesmanynewfeatures.
InfWizardnolongerusesthe'FindDrivers'option.Instead,itusesdriverresourcepackagesthatcontainthedrivers/coinstallers,inf/catfiletemplates,andallotherfilesthatmayberequiredbytheinstallation.DriverresourcepackagescanbedownloadedautomaticallybyInfWizardorfromhttp://sites.google.com/site/libusbdotnet/driver_resources.Asofv2.2.5Winusb1.9andlibusb-win320.1.12.2packagesareavailable.
InfWiardhasaninstallnowfeature,thankstoPeterBatardandtheLibusb-1.0team.Afteradriverpackageiscreated,itcanbeautomaticallyinstalled.
InfWizardremovedevicefunctionenhancements.Theremovedevicefunctioncanremoveusbdevicesbythedeviceinstanceidoralldevicesmatchingthehardwareid.ItnowcallsSetupDiUnintallOEMInfaswellasSetupDIRemoveDevice.
Detailedloggingadded.MostoftheInfWizardpageshavealogstatusrtfboxwhichindicatesthecurrentprogressofanoperation.Alllogstatusboxescanbesaved,copiedandclearedviathecontextmenu.
UpdatedWinUsbRegistryclass
Improvedsupportforcompositedevices.AddedDeviceIDandInterfaceIDproperty
AddedEndpointTypeparametertoOpenEndpointReaderandOpenEndpointWritermethods.
TheendpointtypemustbespecifiedforlinuxLibusb-1.0compatibility.
AddedBenchmarkConsoleapplication.
ThankXiaofan(http://mcuee.blogspot.com)forhelpingdebugthisapplicationandgettingitreadyforrelease.
FixedUsbdevicesrunnningbenchmarkfirmwaredonotworkcorrectlyifpluggedinwhilebootingunderlinux.UpdatedBenchmarkfirmwareforMicrochipPICUSBdevicesupdatedtoMCHPFSUSBFrameworkv2.6a.Addedsupportfornopingpongbufferingbenchmarktests.
v2.2.4(03/13/2010)FixedBugID:2969931-Linuxxbuildissue.
ThexbuildutilityfailedtobuildtheLibUsbDotNet.sln.ThiswascausedbyaninvalidresourceintheInfWizardapplicationandacastingissueforfunctionthattakeaPredicateasaparameter.
FixedBugID:2956665-UsbDeviceFinderfailstofindVIDandPIDs>0x7FFF.
USBdevicesthathaveVIDorPIDsgreaterthan0x7FFFarenotfoundbytheUsbDeviceFinderclass.
AddedAsynchronoustransferfunctionstoUsbEndpointBase.
FormoredetailsseetheNewAsyncTransfer()andSubmitAsyncTransfer()functionsintheUsbEndpointBaseclass.
AddedLow-level.NETMonoLibUsbAPIforLibusb-1.0.
Thelow-levelMonoLibUsbAPI(Libusb-1.0)issupportedonmanyplatformsincludingwindowsviatheLibusb-1.0windows-backendport.
UnliketheLibUsbDotNetAPI,MonoLibUsbhasfullsupportforallLibusb-1.0functions.
AddedUsbRegistry.ForceSetupApioption.
ThisoptionforcesLibUsbDotNettogatherextradeviceinformationviathewindowssetupapifordevicesusingdriversthatdonotsupportthesetupapi.
AddedUsbDevice.ForceLibUsbWinBackoption.
http://sourceforge.net/tracker/?func=detail&aid=2969931&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2956665&group_id=206606&atid=1140572http://www.libusb.org/http://www.libusb.org/wiki/windows_backend
ThisoptionforcesLibUsbDotNettouseonlytheLibusb-1.0windowsbackenddriver.
v2.2.3(01/30/2010)Removed-GetConfigurationcallinUsbDevice.Openmethod.
TheUsbDevice.Open()methodrequeststheusbdevicescurrentconfigurationuponopening.Thiscausesproblemsinsomesituations.
AddedIUsbDevice.ResetDevice()method.FixedBugID:2937372-ReadFailed:WaitHandle.WaitOnemissingmemberexception.
If.NET3.5isnotinstalled,aSystem.Threading.WaitHandle.WaitOnemissingmemberexceptionisthrown.LibUsbDotNetshouldnotrequirethe3.5runtime.Itshouldworkwith2.0andgreater.
FixedBugID:2935627-Stackoverflowwhenreadinganepthatdoesnotexists.
Ifanattemptismadetoopenandtransmittoanon-existentendpointastackoverflowoccurs.Expectedbehavioristothrowanexception.
FixedBugID:2935456-UsbDevice.KernelTypepropertynotsetcorrecty.
[WindowsOnly]IftheUsbDevice.KernelTypeisaccessedwhennodeviceareconnecteditdoesnotupdateproperlywhenadeviceisconnected.
v2.2.2(01/19/2010)FixedBugID:2934547-DeviceNotifiernotworking.
OnLinuxlikeOSestheDeviceNotifierneverfiresevents.OnWindows,aDllNotFoundexceptionisthrown.
http://sourceforge.net/tracker/?func=detail&aid=2937372&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2935627&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2935456&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2934547&group_id=206606&atid=1140572
FixedBugID:2933530-CompositeWinUSBnotfound.
WinUSBinterfacesthatarepartofacompositedevicedonotappearintheWinUsbRegistry.DeviceList.
v2.2.1(01/13/2010)FixedBugID:2930836-[OSXPPC]GetDescriptorrequestfails.
Onbig-endianplatforms,thedescriptortypeandindexbytesarereversed.
FixedBugID:2927179-Wrongversioning.LibUsbDotNet2.2.0allAssemblyInfo.cscontains[assembly:AssemblyVersion("2.1.0.13")]UpdatedBenchmarkapplication:RemovedallcallstoControl.Invoke.
Thebenchmarkapplicationnowusesatimercontroltoperiodicallyupdatethedisplayinsteadof"Invoking"anupdateeverytimedataistransferred.Thisprovidesamoreaccuratebenchmarkreadingaswellasawork-a-roundforMono.NETruntimesonplatformsthatdonotproperlyimplementtheControl.Invokemethod.
RemovedLINUXcompileroption.
TheLINUXcompileroptionisnolongerused.LibUsbDotNet(v2.2.1andabove)isfullyplatformindependent.
v2.2.0(12/29/2009)AddedLinuxsupport.
LibUsbDotNetsupportslinuxviathelinuxlibusbv1.xdriver.
UpdatedUsbDevice.OpenEndpointReaderandUsbDevice.OpenEndpointWritermemberstofirstlookuptheendpointdescriptorforthecurrentconfiguration.
Ifanattemptismadetoopenanendpointonaunconfigureddevice(GetConfiguration=0)anexceptionisthrown.
http://sourceforge.net/tracker/?func=detail&aid=2933530&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2930836&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2927179&group_id=206606&atid=1140572
Ifanattemptismadetoopenanon-existentorinvalidendpointanexceptionisthrown.
AddedendpointdescriptorinformationtoUsbEndpointBaseclass.
ANewproperty,'EndpointInfo'isavailablefromtheUsbEndpointBaseclass.
RemovedDepricatedUsbGlobalsclass.
TheUsbGlobalsclasshasbeenrenderedobsoleteandwillberemovedinfuturerelease.UpdateyourcodeyouusetheUsbDeviceclassinstead.
v2.1.0(11-02-2009)FixedBugID:2886021-Problemwithseveralinstancesofthesamedevice(WinUsb)
Whenconnecting2(ormore)identicalUSBdevices,thelibraryhasproblemsopeningeachdeviceinstance.
FixedBugID:2873320BugID:2874172-ErrorgettingKey"SymbolicName"
SomedeviceshavingnoSymbolicName.Inthiscase,themainapplicationor.NETframeworkcrashes.
FixedBugID:2853283-Infwizardexceptionthrownonload
TheInfWizardthrowsanexceptionwhenloaded.
Addedsupportforthegenuinelibusb-win32kerneldriver.
IftheLibUsbDotNetnativekerneldriverisnotdetecteditfallsbacktotheoriginallibusb-win32kerneldriver.Usingthenativedriverisrecommended.
AddedstaticopenmethodtotheLibUsbDeviceclass.
OpensalibUsbdevicefromausersuppileddevicefilename.
http://sourceforge.net/tracker/?func=detail&aid=2886021&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2873320&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2874172&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2853283&group_id=206606&atid=1140572
publicstaticboolOpen(stringdeviceFilename,outLibUsbDeviceusbDevice)
AddedstaticopenmethodtotheWinUsbDeviceclass.
OpensaWinUSBdevicefromausersuppileddevicepath(symboliclink).
publicstaticboolOpen(stringdevicePath,outWinUsbDeviceusbDevice)
RemovedDeviceInterfaceGuidpropertyfromWinUsbDeviceclass.
ADeviceInterfaceGuidisnotrequiredforaWinUsbDevice.
RemovedUsbRegistryInfopropertyfromUsbDeviceclasses.
AUsbRegistryinstanceisnotrequiredfortheUsbDeviceclasses.
Removeddeviceandendpointlevellockingfeatures.
Thedeviceandendpointlevellockingfeatureshadspecficrequirementspertainingtotheusbsymbolicnamethatcouldnotalwaysbemet.
v2.0.3(09-03-2009)FixedBugID:2845680-LibUsbDotNet-libusb-win32v2.1.12.1GET_INTERFACErequestfailsinXPSP3
TheGET_INTERFACErequestinthelibusbkerneldriverfailsonWindowsXPSP3butworksunderwindowsVista.
FixedBugID:2845679-InfWizardSpawndriverfunctionproblems.
TheInfWizardspawndriverfunctionfailstolocateWinUSBsupportdriversfromtheDDKinstalldirectory.
AddedUsbExceptiononnon-existentendpoint.
http://sourceforge.net/tracker/?func=detail&aid=2845680&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2845679&group_id=206606&atid=1140572
Ifananattemptismadetoopenanendpointthatdoesnotexists,aUsbExceptionisthrown.
UpdatedLibUsbDotNet-libusb-win32kerneldriver.
AppliedLibUsbDotNetkerneldriverpatchestolibusb-win32v0.1.12.2.LibUsbDotNet-libusb-win32v2.1.12.2kernelcreated.
UpdatedTest_Bulkapplication.
Removedallreferencestobenchmarkdevice.TheTest_Bulkapllicationismoreuniversalandeasiertotailortospecificdevices.
Updateddocumentation.
v2.0.2(08-16-2009)FixedBugID:2833695-USBrev.codetreatedashexinsteadofbcd.
TheUSBSymbolicNameclassisconvertingthebcdrevisionnumbertoahexnumber.
FixedBugID:2833701-InfWizardneverpopulatesthe"DriverInformation"property.
OnthefinalwizardpageoftheInfWizardthe"DriverInformation"propertyunderthe"Info"categoryisneverpopulated.
AddedInfWizardremovedeviceoptionsform.AddedInfWizarddisclaimers.AddedBenchmarkPICdevicefirmwareforMCP2.5USBstack.Updateddocumentation.
v2.0.1(07-09-2009)FixedBugID:2816121-UsbGlobals.OpenDevice(UsbDeviceFinder)Nullreferenceexception
http://sourceforge.net/tracker/?func=detail&aid=2833695&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2833701&group_id=206606&atid=1140572http://sourceforge.net/tracker/?func=detail&aid=2816121&group_id=206606&atid=1140572
CallingUsbGlobals.OpenDevice(UsbDeviceFinder)generatesanexceptionifthedeviceisnotfound.
FixedBugID:2818621-DeviceNotifierInvalidMarshalfieldNameException
Fieldpassedinisnotamarshaledmemberofthetype'LibUsbDotNet.DeviceNotify.Internal.DevBroadcastPort'.Parametername:fieldName.
Added3exampleprojects.Updateddocumentation.
v2.0.0(07-01-2009)AddedSupportforMicrosoftsgenericuser-modeusbdriver,WinUsb.AddedAddedkernellevelsupportforlibusb-win32.AddedAddedanewandimprovedInfWizard.AddedAddedadvancedUSBlockingstrategiesforprocess/threadlevelusbdevicesharing.AddedAddedAdditionalread/writefunctionsaddedtotheendpointreader/writerclasses.UpdatedUpdateddocumentationwithSandCastle(SHFB).DocumentationisnowavailableinhtmlandMicrosoftHelp.chmformat.UpdatedUpdatedLibUsbDotNettypeandmembernames;theynowadheretostrictnamingconventions.AddedAddedadditionalmembersandtypesformoreeasilylocatingandopeningusbdevicesby:
VendorIDProductIDRevisionCodeSerialNumberDeviceInterfaceGUID
v1.0.1(10-09-2007)UpdatedPortedtoC#2.0!ManyAPIchanges.Seedocumentation.AddedAddedTest_DeviceNotifysampleproject.
http://sourceforge.net/tracker/?func=detail&aid=2818621&group_id=206606&atid=1140572
FixedFixedmisingdataissuewiththeDataReceivedevent.UpdatedRebuiltlibusbcorecomponentswithWINDDK2003(SP1).AddedAddedItanium64bitsupport.FixedFixedx64installationerror.
v0.1.4(07-18-2007)RemovedDebugruntimesremovedfromthedistributionstoavoidconfusion.AddedNewClassAdded.TheDeviceNotifyclassisusedforreceivingdeviceinsertion/removalevents.Seedocumentationforfulldetails.
v0.1.3(01-04-2007)AddedAddedlockroutinestointernalread/writefunctionstoincreasemulti-threadingstability.RemovedRemoveddependenciesonmsvcmrt.lib.UpdatedProjectdefaultschangedtocompiledwith/clr:puresyntax.AddedAdded64bitsupport.FixedFixedfunctionClibUsb.Open(InfoDevice).Itwillnowopendifferentdeviceswiththesamevendorandproductid.AddedAddedremovefunctionstotheCLibUsb.ActiveEndPointsproperty(CEndPontsclass)
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
mailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
LibUsbDotNet2.2.8GettingStartedWithLinux
LibUsbDotNetiscompatiblewithlinux/unix-likeoperatingsystemsthatsupportmono.net2.0andlibusbv1.x.
PrerequisitesNote:
Theusermusthaveappropriateaccesspermissionstotheusbdevicebeforeitcanbeusedwithlinux.Thisistrueformostunix-likeOSes.
1. Ifyourplatformhasitsownpackagemanager(Aptitude,Synaptic,etc),useittodownloadandinstalltherequiredsoftwarepackagesbelow.
2. Downloadandinstallthelibusb-1.0package.
Iflibusb-1.0binariesdonotexistsforyourplatform,youmustbuildthemfromsource.Buildinglibusb-1.0fromsourceisverystraightforward.SeetheINSTALLdocumentationfileinthelibusb-1.0sourcepackageformoredetails.
3. DownloadandinstalltheMono.Net2.xpackage.
Thepre-compiledMono.Netruntimebinariesareavailablefornearlyallplatforms.However,forinformationonbuldingthemono.netruntimefromsourceseeCompiling_Mono.
Usingthepre-builtLibUsbDotNetBinarypackage.
1. DownloadtheLibUsbDotNet_Binpackageandunzipittoanewsub-directory(LibUsbDotNet_Bin).
2. OpenaterminalwindowandnavigatetothenewLibUsbDotNet_Bindirectory.
http://sourceforge.net/projects/libusb/files/libusb-1.0/http://www.go-mono.com/mono-downloads/download.htmlhttp://www.mono-project.com/Compiling_Monohttp://sourceforge.net/projects/libusbdotnet/files/
3. RuntheTest_Infoapplicationbytyping:monoTest_Info.exe
Test_InfoshouldfindallUSBdevicestheuserhasaccesstoandprovidesadevicecountinthestatusbar.Ifnodevicesarefound,verifytheuserhassufficientaccesspermissions,ortryrunningastherootuser.
BuildingLibUsbDotNetFromSource
1. DownloadtheLibUsbDotNet_Srcpackageandunzipittoanewsub-directory(LibUsbDotNet_Src).
2. OpenaterminalwindowandnavigatetothenewLibUsbDotNet_Srcdirectory.
3. TheLibUsbDotNet.slncanbebuiltwiththexbuildtool:
xbuildLibUsbDotNet.sln
NextStepsAllLibUsbDotNetexampleapplication,withtheexceptionoftheInfWizard,arecompatiblewithlinux.
AllexampleandtestapplicationsotherthanTest_Infohavespecialrequirementsoftheusbdevice(generallyaloopbackonEp1).TheInfWizardisincompatiblewithLinux.
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
http://sourceforge.net/projects/libusbdotnet/files/mailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
LibUsbDotNet2.2.8GettingStartedWithWindows
BeforeLibUsbDotNetcanaccessausbdeviceonaWindowsoperatingsystemthedevicemustbeinstalledwitheitherWinUSBorlibusb-win32usbdrivers.Optionally,libusb-win32hastheuniqueabilitytooperateasafilterservice.Whenthefilterservicemodeisenabled,libusb-win32willallowaccesstoeveryusbdeviceonthesystemwithouttheneedfordriversetup/installationpackages.
TolearnhowtoautomaticallygenerateaUSBInstallpackagessee:CreatingaUsbInstallPackage.TolearnmoreabouttheInfWizardutilitysee:UsingtheInfWizardUtility.
Usingthelibusb-win32FilterService
ThefilterserviceisinstalledbytheLibUsbDotNetSetuppackageandisdisabledbydefault.ItcanbeenabledanddisabledfromtheLibUsbDotNetsub-menu.
Start->Programs->LibUsbDotNet->libusb-win32->Enablefilterservice
Start->Programs->LibUsbDotNet->libusb-win32->Disablefilterservice
Thelibusb-win32filterserviceshouldonlybeusedinadevelopmentenvironmentasitcaninterferewithnormalUSBoperation.
ForcingLibusb-1.0UsageOnWindows
LibUsbDotNetcanbeforcedtousetheLibusb-1.0APIonwindowsbysettingthestaticForceLibUsbWinBackfieldtotrue.Withthisfieldset,allcustomHIDdevicesandWinUSBdevicesarepresentinthedevicelist.
NOTE:Libusb-1.0doesnottreatmultipleWinUSBinterfacesasseperate
devices.Keepthisinmindwhenusingacompositedeviceandmulti-platformsupportisrequired.
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
mailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#LibUsbDotNet2.2.8UsingtheInfWizard
LibUsbDotNetINFWizardcreatescompletewindowsUSBinf/setuppackagesforusbdevices.CurrentlydriverresourcesareavailableforbothWinUSBandlibusb-win32.
FeaturesCreatesUSBinstallationpackagesRemovesUSBdevicesInstallsUSBdevicedriversUsesconfigurabledriverresourcepackages
GettingDriverResourcePackages
TheInfWizardutilityrequiresoneormoredriverresourcepackagestooperate.Adriverresourcepackagecontainsthedriverandinffiletemplatesneededtobuildausbsetuppackage.InfWizardcandownloadtheseautomaticallyortheycanbedownloadedmanuallyfromtheLibUsbDotNetDriverResourcePage
Note:DriverresourcesthataredownloadedmanuallymustbeplacedintheworkingdirectoryortheInfWizard.exepathdirectory.
Adriverresourcepackageisastandard.NETresourcefile.UserscanmodifyexistingpackagesorcreatenewonesfromscratchandusethemwithInfWizardtogeneratecustom-tailoreddeviceinstallations.
SeeAlsoCreatingaUSBInstallPackageRemovingaUSBInstallPackage
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
http://libusbdotnet.sourceforge.net/driver_resourcesmailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
LibUsbDotNet2.2.8CreatingaUsbInstallPackage
InfWizardcreatesusbsetuppackagesusingInfWizarddriverresourcepackages.
BuildingaGenericSetupPackagewithInfWizard
1. Plugintheusbdevice.IfWindowsdisplaystheFoundNewHardwareWizard,closeitnow.
LaunchtheInfWizardandclickNext.
Welcome
2. IfInfWizarddoesnotfindanydriverresourcepackages,thedownloaddriverresourcepageisshown.
ClicktheDownloaddriverresourcesfromtheinternetradiobutton.Thisgetsthelistofdriverresourcepackagesavailablefordownload.Bydefault,allpackagesareselectedfordownload.
ClicktheDownloadbuttonandwaitforthepackagedownloadstocomplete.
DriverResourceDownloader
DownloadDriverResourceList
DownloadDriverResources
3. Selectausbdevicetogenerateaninstallationpackagefor.Bydefault,InfWizardwilldisplayonlydevicesthatarecurrentlyconnectedtothepc(Connected)anddonotalreadyhavedriversinstalled.(Driverless)
ClickNext.
DeviceSelection
4. Selectthedriverresourcepackagethatwillbeusedtogeneratethissetuppackage.
SelectaSaveDirectorywherethesetuppackagewillbewritten.IftheCreateDriverDirectorypropertyistrue,thesetuppackageiswrittentoasub-directoryoftheSaveDirectorynamedtotheBaseFilenameIE:SaveDirectory\BaseFilename
Optionally,fine-tunethedevicedescription,manufacturer,andanyotherofthepropertiesinthegrid.
Beforeclickingnext,theprofilecanbesavedandloadedatlatertimeforfurthermodification.
ClickNextandthesetuppackagewillbegeneratedandwrittentotheSaveDirectory.
DeviceConfiguration
PackageGeneration
5. AtthispointthesetuppackageshouldhavebeengeneratedandresidingintheSaveDirectory.
Ifdesired,thispackagecanbeinstalledbyclickingtheInstallNowbutton.
Copy
DriverInstaller
Example
SetupInf
[Version]Signature="$WindowsNT$"Class=WinUsbDevicesClassGuid={A219BCD5-74D8-4d79-A91F-01F749642227}Provider=%ProviderName%CatalogFile=Benchmark_Device.catDriverVer=04/14/2010,1.0.0.0
;==========Manufacturer/Modelssections===========;.ntx86,.ntia64,and.ntamd64
[Manufacturer]%ProviderName%=Benchmark_Device,ntx86,ntamd64,ntia64
[Benchmark_Device.ntx86]%USB\Benchmark_Device.DeviceDesc%=Benchmark_Device_Install,USB\VID_04D8&PID_0053
[Benchmark_Device.ntamd64]%USB\Benchmark_Device.DeviceDesc%=Benchmark_Device_Install,USB\VID_04D8&PID_0053
[Benchmark_Device.ntia64]%USB\Benchmark_Device.DeviceDesc%=Benchmark_Device_Install,USB\VID_04D8&PID_0053
;===================Installation===================
;=========================================================================================;ClassInstall32andClassInstall_AddRegsectionsusedtomakenewdevicemanagercategory.;=========================================================================================[ClassInstall32]AddReg=ClassInstall_AddReg
[ClassInstall_AddReg]HKR,,,,%DEVICEMANAGERCATEGORY%HKR,,Icon,,"-20"
[Benchmark_Device_Install]Include=winusb.infNeeds=WINUSB.NT
[Benchmark_Device_Install.Services]Include=winusb.infAddService=WinUSB,0x00000002,WinUSB_ServiceInstall
[WinUSB_ServiceInstall]DisplayName=%WinUSB_SvcDesc%ServiceType=1StartType=3ErrorControl=1ServiceBinary=%12%\WinUSB.sys
[Benchmark_Device_Install.Wdf]KmdfService=WINUSB,WinUsb_Install
[WinUSB_Install]KmdfLibraryVersion=1.9
[Benchmark_Device_Install.HW]AddReg=Dev_AddReg
[Dev_AddReg]HKR,,DeviceInterfaceGUIDs,0x10000,"{591a9b4c-cc1c-40ed-a9c2-bbd698899f3b}"
[Benchmark_Device_Install.CoInstallers]AddReg=CoInstallers_AddRegCopyFiles=CoInstallers_CopyFiles
[CoInstallers_AddReg]HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01009.dll,WdfCoInstaller"
[CoInstallers_CopyFiles]WinUSBCoInstaller2.dllWdfCoInstaller01009.dll
[DestinationDirs]CoInstallers_CopyFiles=11
;=================SourceMediaSection=====================[SourceDisksNames]1=%DISK_NAME%,,,\x862=%DISK_NAME%,,,\amd643=%DISK_NAME%,,,\ia64
[SourceDisksFiles.x86]WinUSBCoInstaller2.dll=1WdfCoInstaller01009.dll=1
[SourceDisksFiles.amd64]WinUSBCoInstaller2.dll=2WdfCoInstaller01009.dll=2
[SourceDisksFiles.ia64]WinUSBCoInstaller2.dll=3WdfCoInstaller01009.dll=3
;===================Strings===================[Strings]ProviderName="TravisRobinson"USB\Benchmark_Device.DeviceDesc="BenchmarkDevice"WinUSB_SvcDesc="BenchmarkDeviceService04/14/2010,1.0.0.0"DISK_NAME="BenchmarkDeviceInstallDisk"DEVICEMANAGERCATEGORY="WinUsbDevices"
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
mailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
LibUsbDotNet2.2.8RemovingaUsbInstallPackage
TheInfWizardcanbeusedtoremove/cleanupusbinstallpackages.
UnknownListClassRemoveaUsbDeviceInstallPackage
1. LaunchtheInfWizardandclickNext.
Welcome
2. SelecttheusbdevicetoremoveandclickRemoveDevicetodisplaytheInfWizardRemoveDevicewindow.
RemoveDeviceOptions
3. ThedeviceremovalfunctionfirstcallsthewindowsapifunctionSetupDiRemoveDeviceandthenSetupUninstallOEMInf.
IftheDeepCleanpropertywassettotrue,theremovedevicefunctionwillscanALLinffilesinthe[Windows]\InffortheselecteddevicesVIDandPID.Allmatchinginffilearemarkedfordeletioninthefinalconfirmationdialog.
http://msdn.microsoft.com/en-us/library/ff552097.aspxhttp://msdn.microsoft.com/en-us/library/aa377446%28v=VS.85%29.aspx
RemoveUSBDevice
4. Thedialogremainsopenafterthedeviceisremovedsostatuscanbereviewed.
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
mailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
LibUsbDotNet2.2.8LibUsbDotNetExampleCode
Note:Allexamplesarecompleteapplications.Theycanbecreatedandcompiledbyfollowingthebuildinstructionsatthebottom.VisualBasicNote:TogetexamplecodeforVB.NET,downloadandinstallSharpDevelop.SharpdevelopcanconvertcodetoandfromC#,VB.NET,andBOO.SeeAlsoGettingStartedExampleReadOnly(Polling)ExampleRead/Write(Polling)ExampleRead/Write(EventDriven)ExampleDeviceNotificationExampleAsyncRead/WriteExampleReadIsochronous(AsyncTransferQueue)
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
http://www.icsharpcode.net/OpenSource/SDmailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
Copy
LibUsbDotNet2.2.8ShowInfo
ShowInfo:ConsoleApplicationDescription
1. OpensaUSBdevicebyvendorandproductid.
2. GetsanddisplaystheUsbDeviceDescriptorandtheUsbConfigDescriptor.
3. GetsanddisplaystheManufacturerString,ifoneexists.
4. GetsanddisplaystheProductString,ifoneexists.
5. GetsanddisplaystheSerialString,ifoneexists.
Example
C#
usingSystem;usingLibUsbDotNet;usingLibUsbDotNet.Info;usingLibUsbDotNet.Main;usingSystem.Collections.ObjectModel;
namespaceExamples{internalclassShowInfo{publicstaticUsbDeviceMyUsbDevice;
publicstaticvoidMain(string[]args){//Dumpalldevicesanddescriptorinformationtoconsoleoutput.UsbRegDeviceListallDevices=UsbDevice.AllDevices;foreach(UsbRegistryusbRegistryinallDevices){
Copy
if(usbRegistry.Open(outMyUsbDevice)){Console.WriteLine(MyUsbDevice.Info.ToString());for(intiConfig=0;iConfig{//ifTRANFER_ENDPOINTis0x80or0x00,LookupEndpointInfowillreturnthe//firstreadorwrite(respectively).if(UsbEndpointBase.LookupEndpointInfo(MyUsbDevice.Configs[outusbInterfaceInfo,break;
MyUsbDevice.Close();MyUsbDevice=null;}}}
//Ifthedeviceisopenandreadyif(MyUsbDevice==null)thrownewException(
//Ifthisisa"whole"usbdevice(libusb-win32,linuxlibusb-1.0)//itexposesanIUsbDeviceinterface.Ifnot(WinUSB)the//'wholeUsbDevice'variablewillbenullindicatingthisis//aninterfaceofadevice;itdoesnotrequireorsupport//configurationandinterfaceselection.IUsbDevicewholeUsbDevice=MyUsbDeviceif(!ReferenceEquals(wholeUsbDevice,{//Thisisa"whole"USBdevice.Beforeitcanbeused,//thedesiredconfigurationandinterfacemustbeselected.
//Selectconfig#1wholeUsbDevice.SetConfiguration(
//Claiminterface#0.wholeUsbDevice.ClaimInterface(usbInterfaceInfo.Descriptor.InterfaceID);}
//openreadendpoint.UsbEndpointReaderreader=MyUsbDevice.OpenEndpointReader((ReadEndpointID)usbEndpointInfo.Descriptor.EndpointID,0,(EndpointType)(usbEndpointInfo.Descriptor.Attributes&
if(ReferenceEquals(reader,null)){thrownewException("Failedlocatingreadendpoint."}
reader.Reset();
//ThebenchmarkdevicefirmwareworkswiththisexamplebutitmustbeputintoPCreadmode.#ifIS_BENCHMARK_DEVICEinttransferred;byte[]ctrlData=newbyte[1];UsbSetupPacketsetTestTypePacket=newUsbSetupPacket((byte)(UsbCtrlFlags.Direction_In|UsbCtrlFlags.Recipient_Device|UsbCtrlFlags.RequestType_Vendor),0x0E,0x01,usbInterfaceInfo.Descriptor.InterfaceID,MyUsbDevice.ControlTransfer(refsetTestTypePacket,ctrlData,#endifTRANFER_SIZE-=(TRANFER_SIZE%usbEndpointInfo.Descriptor.MaxPacketSize);
UsbTransferQueuetransferQeue=newUsbTransferQueue(reader,TRANFER_MAX_OUTSTANDING_IO,TRANFER_SIZE,usbEndpointInfo.Descriptor.MaxPacketSize);
do{UsbTransferQueue.Handlehandle;
//BeginsubmittingtransfersuntilTRANFER_MAX_OUTSTANDING_IOhasbennreached.//thenwaitfortheoldestoutstandingtransfertocomplete.//ec=transferQeue.Transfer(outhandle);if(ec!=ErrorCode.Success)
thrownewException("Failedgettingasyncresult"
//Showsomeinformationonthecompletedtransfer.showTransfer(handle,mTransferCount);}while(mTransferCount++'ifTRANFER_ENDPOINTis0x80or0x00,LookupEndpointInfowillreturnthe'firstreadorwrite(respectively).IfUsbEndpointBase.LookupEndpointInfo(MyUsbDevice.Configs(ExitForEndIf
MyUsbDevice.Close()MyUsbDevice=NothingEndIfEndIfNext
'IfthedeviceisopenandreadyIfMyUsbDeviceIsNothingThenThrowNewException("DeviceNotFound."EndIf
'Ifthisisa"whole"usbdevice(libusb-win32,linuxlibusb-1.0)'itexposesanIUsbDeviceinterface.Ifnot(WinUSB)the''wholeUsbDevice'variablewillbenullindicatingthisis'aninterfaceofadevice;itdoesnotrequireorsupport'configurationandinterfaceselection.DimwholeUsbDeviceAsIUsbDevice=TryCastIfNotReferenceEquals(wholeUsbDevice,'Thisisa"whole"USBdevice.Beforeitcanbeused,'thedesiredconfigurationandinterfacemustbeselected.
'Selectconfig#1wholeUsbDevice.SetConfiguration(
'Claiminterface#0.wholeUsbDevice.ClaimInterface(usbInterfaceInfo.Descriptor.InterfaceID)EndIf
'openreadendpoint.DimreaderAsUsbEndpointReader=MyUsbDevice.OpenEndpointReader(
IfReferenceEquals(reader,Nothing)ThrowNewException("Failedlocatingreadendpoint."EndIf
reader.Reset()
'ThebenchmarkdevicefirmwareworkswiththisexamplebutitmustbeputintoPCreadmode.#IfIS_BENCHMARK_DEVICEThenDimtransferredAsIntegerDimctrlDataAsByte()=NewByte(0){}DimsetTestTypePacketAsNewUsbSetupPacket(MyUsbDevice.ControlTransfer(setTestTypePacket,ctrlData,#EndIfTRANFER_SIZE-=(TRANFER_SIZEModusbEndpointInfo.Descriptor.MaxPacketSize)
DimtransferQeueAsNewUsbTransferQueue(reader,TRANFER_MAX_OUTSTANDING_IO,TRANFER_SIZE,
DoDimhandleAsUsbTransferQueue.Handle
'BeginsubmittingtransfersuntilTRANFER_MAX_OUTSTANDING_IOhasbennreached.'thenwaitfortheoldestoutstandingtransfertocomplete.'ec=transferQeue.Transfer(handle)IfecErrorCode.SuccessThenThrowNewException("Failedgettingasyncresult"EndIf
'Showsomeinformationonthecompletedtransfer.showTransfer(handle,mTransferCount)LoopWhileSystem.Math.Max(System.Threading.Interlocked.Increment(mTransferCount),mTransferCount-
'Cancelsanyoustandingtransfersandfree'sthetransferqueuehandles.'NOTE:Atransferqueuecanbereusedafterit'sfreed.transferQeue.Free()
Console.WriteLine(vbCr&vbLf&"Done!"CatchexAsExceptionConsole.WriteLine()Console.WriteLine((If(ecErrorCode.None,ec&FinallyIfMyUsbDeviceIsNotNothingThenIfMyUsbDevice.IsOpenThen'Ifthisisa"whole"usbdevice(libusb-win32,linuxlibusb-1.0)'itexposesanIUsbDeviceinterface.Ifnot(WinUSB)the''wholeUsbDevice'variablewillbenullindicatingthisis'aninterfaceofadevice;itdoesnotrequireorsupport'configurationandinterfaceselection.DimwholeUsbDeviceAsIUsbDevice=IfNotReferenceEquals(wholeUsbDevice,'Releaseinterface#0.wholeUsbDevice.ReleaseInterface(EndIf
MyUsbDevice.Close()EndIfMyUsbDevice=NothingEndIf
'Waitforuserinput..Console.ReadKey()
'FreeusbresourcesUsbDevice.[Exit]()EndTryEndSub
PrivateSharedSubshowTransfer(handleAsUsbTransferQueue.Handle,transferIndexIfmStartTime=DateTime.MinValueThenmStartTime=DateTime.NowConsole.WriteLine("Synchronizing..")
ReturnEndIf
mTotalBytes+=handle.TransferredDimbytesSecAsDouble=mTotalBytes/(DateTime.Now-mStartTime).TotalSeconds
Console.WriteLine("#{0}complete.{1}bytes/sec({2}bytes)Data[1]={3:X2}"EndSubEndClassEndNamespace
CompilingtheCode
1. Createanewconsoleapplicationinyourfavoritedesigner.
2. Verifyyourprojectreferences:
System.dll
LibUsbDotNet.dll
3. Add/editthemainclass.Copy/Pastecodefromoneoftheexamplesabove.
Note:Exampleusbdevicefirmwareislocatedinthe[InstallDirectory]\Benchmark\Firmware\[Manufacturer]directory.
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
http://www.icsharpcode.net/OpenSource/SDmailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
LibUsbDotNet2.2.8MonoLibUsb-[Libusb1.0APILibrary]
TheMonoLibUsbLibusb-1.0low-levelAPIlibraryisacompleteimplementationofLibusb-1.0.
PrerequisitesWindowsRequirestheLibusb-1.0windowsbackenddriver.Uniux-likeplatformsRequirestheLibusb-1.0driver.
GettingStartedwithMonoLibUsb
MuchoftheofficialLibusb-1.0APIDocumentationalsoappliestothe.NETMonoLibUsblow-levelAPIlibrary.Thisisanexcellentreferenceforbothnoviceandadvancedusers.UsersunfamiliarwithLibusb-1.0areencouragedtoreviewtheofficialdocumentationupongettingstarted.
BeforeusingMonoLibUsbaMonoUsbSessionHandlemustbecreated.Asessionhandleisrequiredformanyofthelibraryfunctions.
TheMonoUsbProfileListisyourstartingpointfordiscovering,queryingandopeningUSBdevices.SeetheShowInfoConsoleApplicationExample.
TheMonoLibUsbsourcecodecanbebuiltasastandalonelibrary,seperatefromLibUsbDotNet.Seethe[BaseDir]\LibWinUsb\MonoLibUsb\MonoUsb.slnintheLibUsbDotNetsource.
MigratingfromtheLibusb-1.0CAPItotheMonoLibUsb.NETAPI
TheMonoUsbApifunctionshaveno"libusb_"prefix.andthenamingconventionisUpperCamelCase.Forexample,MonoUsbApi.GetConfiguration()insteadoflibusb_get_configuration().
http://www.libusb.org/http://www.libusb.org/wiki/windows_backendhttp://www.libusb.org/http://libusb.sourceforge.net/api-1.0/
Copy
Copy
Functionsthatdealwithfreeing,openingandclosing(withtheexceptionofasynchronoustranfers)aremanagedbyaSafeContextHandleclass.ThisensuresallunsafeLibusb-1.0memorypointersgetclosed/freed.
TheuserisrequiredtoFree()asynchronoustransfers.Failuretodosowillresultinmemoryleaks.
ThefollowingfunctionsdonotexistintheMonoUsbApi:
libusb_init()libusb_exit()
AMonoUsbSessionHandleclassisusedtomanagealibusb_context.
C++
//InitializeContextlibusb_context*context;libusb_init(&context);
//ExitContextlibusb_exit(context);
C#
//InitializeContextMonoUsbSessionHandlecontext=newMonoUsbSessionHandle();
//ExitContextcontext.Close();
libusb_free_device_list()
AMonoUsbProfileListHandleclassisusedtomanageadevicelisthandle.Tofreeadevicelisthandle,callthelisthandlesClose()method.
libusb_free_config_descriptor()
http://libusb.sourceforge.net/api-1.0/group__lib.html#ga9517c37281bba0b51cc62eba728be48bhttp://libusb.sourceforge.net/api-1.0/group__lib.html#ga9517c37281bba0b51cc62eba728be48bhttp://libusb.sourceforge.net/api-1.0/group__dev.html#gad3b8561d064bb3e1b8851ddeed3cd7d6http://libusb.sourceforge.net/api-1.0/group__desc.html#ga18d2b08a065857ff7ae4f3f719c115cc
Copy
Copy
AMonoUsbConfigHandleclassisusedtomanageaconfigdescriptor.Tofreeaconfigdescriptor,calltheconfighandlesClose()method.
libusb_open()libusb_close()
AMonoUsbDeviceHandleclassisusedtomanagealibusb_device_handle.
C++
//OpenDevicelibusb_device_handle*device_handle;libusb_open(profileHandle,&device_handle);
//CloseDevicelibusb_close(device_handle);
C#
//OpenDeviceMonoUsbDeviceHandledeviceHandle=newMonoUsbDeviceHandle(profileHandle);
//CloseDevicedeviceHandle.Close();
libusb_ref_device()libusb_unref_device()
DevicereferencingishandledinternallybytheMonoUsbProfileHandleclass.
libusb_alloc_transfer()libusb_submit_transfer()libusb_cancel_transfer()libusb_free_transfer()
AsynchronousdeviceI/Ofunctionsareimplementedinthe
http://libusb.sourceforge.net/api-1.0/group__dev.html#ga8163100afdf933fabed0db7fa81c89d1http://libusb.sourceforge.net/api-1.0/group__dev.html#ga779bc4f1316bdb0ac383bddbd538620ehttp://libusb.sourceforge.net/api-1.0/group__dev.html#gaabaa4193adcabba1789cc1165ac41a03http://libusb.sourceforge.net/api-1.0/group__dev.html#ga3cc62e6a191b7a9f213e62b81ec30f4dhttp://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga13cc69ea40c702181c430c950121c000http://libusb.sourceforge.net/api-1.0/group__asyncio.html#gabb0932601f2c7dad2fee4b27962848cehttp://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga685eb7731f9a0593f75beb99727bbe54http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga6ab8b2cff4de9091298a06b2f4b86cd6
MonoUsbTransferstructure.
AsynchronoustransfersmustbefreedbytheuserwiththeFree()method.Failuretodosowillresultinmemoryleaks.
SendcommentsonthistopictoLibUsbDotNetSupportCopyright(C)2010TravisRobinson.AllRightsReserved.
mailto:libusbdotnet%40gmail.com?Subject=LibUsbDotNet 2.2.8http://www.gnu.org/licenses/lgpl.html
C#
Copy
LibUsbDotNet2.2.8ShowInfoExample
MonoLibUsbShowInfo:ConsoleApplicationDescription
1. Initializestheusbcontext.
2. Writesthedevicedescriptorforallknownusbdevicestoconsoleoutput.
3. Exitstheusbcontext.
Example
C#
usingSystem;usingMonoLibUsb.Profile;usingUsb=MonoLibUsb.MonoUsbApi;
namespaceMonoLibUsb.ShowInfo{internalclassShowInfo{//ThefirsttimetheSessionpropertyisuseditcreatesanewsession//handleinstancein'__sessionHandle'andreturnsit.Subsequent//requestsimplyreturn'__sessionHandle'.privatestaticMonoUsbSessionHandle__sessionHandle;publicstaticMonoUsbSessionHandleSession{get{if(ReferenceEquals(__sessionHandle,__sessionHandle=newMonoUsbSessionHandle();return__sessionHandle;}}
Copy
publicstaticvoidMain(string[]args){intret;MonoUsbProfileListprofileList=null;
//Initializethecontext.if(Session.IsInvalid)thrownewException("Failedtoinitializecontext."
MonoUsbApi.SetDebug(Session,0);//CreateaMonoUsbProfileListinstance.profileList=newMonoUsbProfileList();
//Thelistisinitiallyempty.//Eachtimerefreshiscalledthelistcontentsareupdated.ret=profileList.Refresh(Session);if(ret