USBDriverKit

RSS for tag

Develop drivers for USB-based devices using USBDriverKit.

USBDriverKit Documentation

Posts under USBDriverKit tag

44 Posts
Sort by:
Post not yet marked as solved
1 Replies
487 Views
After DriverKit being released last year, I wonder if the background mode External accessory communication in Background Modes applies also for drivers made with DriverKit. Is this mode only for products in the MFi group? If so, is there any plans to include DriverKit in this group in order to get data from an external device in the background, which is not in the MFi group?
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.7k Views
I'm trying to built a USBDriverKit driver on the Mac. The driver loads properly but when my device is inserted the driver is ignored and instead the com.apple.AppleUserHIDDrivers driver is loaded. I do not understand what is causing this. The device both have USB and HID cababilities but I want it to work with USBDriverKit so that the driver can be used on the Ipad as well. How can I get the driver to match properly? Entitlements: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.developer.driverkit</key> <true/> <key>com.apple.developer.driverkit.transport.usb</key> <array> <dict> <key>idVendor</key> <integer>1240</integer> </dict> </array> <key>com.apple.developer.driverkit.userclient-access</key> <true/> <key>com.apple.security.app-sandbox</key> <true/> </dict> </plist> Info.plist: ... <dict> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>IOKitPersonalities</key> <dict> <key>ClickerDriver</key> <dict> <key>IOKitDebug</key> <string>65535</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>IOClass</key> <string>IOUserService</string> <key>IOProviderClass</key> <string>IOUSBHostInterface</string> <key>IOUserClass</key> <string>ClickerDriver</string> <key>IOUserServerName</key> <string>example.Clicker.driver</string> <key>bInterfaceClass</key> <string>3</string> <key>bInterfaceSubClass</key> <string>0</string> <key>bConfigurationValue</key> <string>1</string> <key>bInterfaceNumber</key> <string>0</string> <key>idProduct</key> <integer>63</integer> <key>idVendor</key> <integer>1240</integer> <key>UserClientProperties</key> <dict> <key>IOClass</key> <string>IOUserUserClient</string> <key>IOUserClass</key> <string>ClickerDriverUserClient</string> </dict> </dict> </dict> <key>OSBundleUsageDescription</key> <string>The app interprets monitors key presses. </string> </dict> </plist> Output of ioreg -b -n "Simple HID Device Demo" -r -l is attacheded. ioreg.log
Posted Last updated
.
Post not yet marked as solved
1 Replies
636 Views
In Apple Developer Documentation / DriverKit, Notes that "The base DriverKit framework is available ... and iPadOS for devices with an M1 processor.", There is no mention of the M2 and subsequent Apple Silicon chipsets, Does DriverKit work on iPads with M2 and subsequent Apple Silicon chipsets? Apple Developer Documentation / DriverKit : https://developer.apple.com/documentation/driverkit
Posted
by KhKwak.
Last updated
.
Post not yet marked as solved
0 Replies
550 Views
Why is using control type transfer on the MAC m2 architecture slower than other platforms? The following is my test code, which was tested using the same USB device in Mac m2, Mac x64, and Ubuntu x64 environments. #include <stdio.h> #include <string.h> #include <stdlib.h> #include <libusb.h> #include <sys/time.h> uint64_t get_us() { uint64_t time = 0; struct timeval tv; gettimeofday(&tv, NULL); time = tv.tv_sec * 1000 * 1000 + tv.tv_usec; return time; } int main() { // open usb handle int ret; ret = libusb_init(NULL); libusb_device_handle *usb_handle; usb_handle = libusb_open_device_with_vid_pid(NULL, 0x248a, 0x8266); if (usb_handle == NULL) { exit(1); } ret = libusb_set_auto_detach_kernel_driver(usb_handle, 1); ret = libusb_claim_interface(usb_handle, 0); uint64_t start = get_us(); unsigned char buf[256]; ret = libusb_control_transfer(usb_handle, 0xC1, 0x02, 0x8014, 0, buf, 12, 1000); ret = libusb_control_transfer(usb_handle, 0xC1, 0x02, 0x8014, 0, buf, 12, 1000); ret = libusb_control_transfer(usb_handle, 0xC1, 0x02, 0x8014, 0, buf, 12, 1000); ret = libusb_control_transfer(usb_handle, 0xC1, 0x02, 0x8014, 0, buf, 12, 1000); memset(buf, 0, 256); ret = libusb_control_transfer(usb_handle, 0x41, 0x02, 0x9548, 0, buf, 16, 1000); ret = libusb_control_transfer(usb_handle, 0x41, 0x02, 0x9548, 0, buf, 16, 1000); ret = libusb_control_transfer(usb_handle, 0x41, 0x02, 0x9548, 0, buf, 16, 1000); ret = libusb_control_transfer(usb_handle, 0x41, 0x02, 0x9548, 0, buf, 16, 1000); uint64_t end = get_us(); printf("spent time %ld(us)\n", end - start); libusb_close(usb_handle); libusb_exit(NULL); return 0; } Finally, my conclusion is to call libusb_control_transfer() function on the MAC m2 architecture takes about 10 times slower than the average in x64 architecture. The following are the software running records and wireshark software packet capture records on the MAC m2 architecture. MacBook-Pro % ./libusb_test spent time 22949(us) The following are the running records and wireshark software packet capture records on Ubuntu20 X64. ubuntu20:~$ ./libusb_test spent time 1246(us) From the data captured by Wireshark software, it can be seen that on the MAC m2 architecture, a control transmission takes about 3ms from submission to reply. On the x64 architecture, only around 200us is required. I also tested bulk type transmission, and the performance on the MAC m2 architecture is consistent with that on the x64 architecture. Is this the reason for the MAC m2 architecture USB driver? Is there a solution to this problem?
Posted
by gorilla.
Last updated
.