⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 porting

📁 最新的libusb库
💻
字号:
PORTING LIBUSB TO OTHER PLATFORMSIntroduction============This document is aimed at developers wishing to port libusb to unsupportedplatforms. I believe the libusb API is OS-independent, so by supportingmultiple operating systems we pave the way for cross-platform USB devicedrivers.Implementation-wise, the basic idea is that you provide an interface tolibusb's internal "backend" API, which performs the appropriate operations onyour target platform.In terms of USB I/O, your backend provides functionality to submitasynchronous transfers (synchronous transfers are implemented in the higherlayers, based on the async interface). Your backend must also providefunctionality to cancel those transfers.Your backend must also provide an event handling function to "reap" ongoingtransfers and process their results.The backend must also provide standard functions for other USB operations,e.g. setting configuration, obtaining descriptors, etc.File descriptors for I/O polling================================For libusb to work, your event handling function obviously needs to be calledat various points in time. Your backend must provide a set of file descriptorswhich libusb and its users can pass to poll() or select() to determine whenit is time to call the event handling function.On Linux, this is easy: the usbfs kernel interface exposes a file descriptorwhich can be passed to poll(). If something similar is not true for yourplatform, you can emulate this using an internal library thread to reap I/O asnecessary, and a pipe() with the main library to raise events. The filedescriptor of the pipe can then be provided to libusb as an event source.Interface semantics and documentation=====================================Documentation of the backend interface can be found in libusbi.h inside theusbi_os_backend structure definition.Your implementations of these functions will need to call various internallibusb functions, prefixed with "usbi_". Documentation for these functionscan be found in the .c files where they are implemented.You probably want to skim over *all* the documentation before starting yourimplementation. For example, you probably need to allocate and store privateOS-specific data for device handles, but the documentation for the mechanismfor doing so is probably not the first thing you will see.The Linux backend acts as a good example - view it as a referenceimplementation which you should try to match the behaviour of.Getting started===============1. Modify configure.ac to detect your platform appropriately (see the OS_LINUXstuff for an example).2. Implement your backend in the libusb/os/ directory, modifyinglibusb/os/Makefile.am appropriately.3. Add preprocessor logic to the top of libusb/core.c to statically assign theright usbi_backend for your platform.4. Produce and test your implementation.5. Send your implementation to libusb-devel mailing list.Implementation difficulties? Questions?=======================================If you encounter difficulties porting libusb to your platform, please raisethese issues on the libusb-devel mailing list. Where possible and sensible, Iam interested in solving problems preventing libusb from operating on otherplatforms.The libusb-devel mailing list is also a good place to ask questions andmake suggestions about the internal API. Hopefully we can produce somebetter documentation based on your questions and other input.You are encouraged to get involved in the process; if the library needssome infrastructure additions/modifications to better support your platform,you are encouraged to make such changes (in cleanly distinct patchsubmissions). Even if you do not make such changes yourself, please do raisethe issues on the mailing list at the very minimum.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -