USBDriverKit

RSS for tag

Develop drivers for USB-based devices using USBDriverKit.

Posts under USBDriverKit tag

190 Posts

Post

Replies

Boosts

Views

Activity

How to get data from the device using IOBufferMemoryDescriptor in driverKit
I'm trying to create a driver for my usb device, using iOS and DriverKit. I'm basing my code in the example used in WWDC: https://github.com/knightsc/USBApp My driver starts fine when the device is connected and the readCompleted method is called fine, but the action->GetReference() gets only \0 characteres. Also in order to know that the usb device is actually working I've connected it to my mac first and using PyUSB I can see that it's returning data in chunks of 1024 bytes in the interface 0. This is the data I get in PyUSB: array('B', [6, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, 105, 0, 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, 0, 118, 0, 119, 0, 120, 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0, 127, 0, 128, 0, 129, 0, 130, 0, 131, 0, 132, 0, 133, 0, 134, 0, 135, 0, 136, 0, 137, 0, 138, 0, 139, 0, 140, 0, 141, 0, 142, 0, 143, 0, 144, 0, 145, 0, 146, 0, 147, 0, 148, 0, 149, 0, 150, 0, 151, 0, 152, 0, 153, 0, 154, 0, 155, 0, 156, 0, 157, 0, 158, 0, 159, 0, 160, 0, 161, 0, 162, 0, 163, 0, 164, 0, 165, 0, 166, 0, 167, 0, 168, 0, 169, 0, 170, 0, 171, 0, 172, 0, 173, 0, 174, 0, 175, 0, 176, 0, 177, 0, 178, 0, 179, 0, 180, 0, 181, 0, 182, 0, 183, 0, 184, 0, 185, 0, 186, 0, 187, 0, 188, 0, 189, 0, 190, 0, 191, 0, 192, 0, 193, 0, 194, 0, 195, 0, 196, 0, 197, 0, 198, 0, 199, 0, 200, 0, 201, 0, 202, 0, 203, 0, 204, 0, 205, 0, 206, 0, 207, 0, 208, 0, 209, 0, 210, 0, 211, 0, 212, 0, 213, 0, 214, 0, 215, 0, 216, 0, 217, 0, 218, 0, 219, 0, 220, 0, 221, 0, 222, 0, 223, 0, 224, 0, 225, 0, 226, 0, 227, 0, 228, 0, 229, 0, 230, 0, 231, 0, 232, 0, 233, 0, 234, 0, 235, 0, 236, 0, 237, 0, 238, 0, 239, 0, 240, 0, 241, 0, 242, 0, 243, 0, 244, 0, 245, 0, 246, 0, 247, 0, 248, 0, 249, 0, 250, 0, 251, 0, 252, 0, 253, 0, 254, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) This is the Ivars: struct Mk1dDriver_IVars { IOUSBHostInterface *interface; IOUSBHostPipe *inPipe; OSAction *ioCompleteCallback; IOBufferMemoryDescriptor *inData; uint16_t maxPacketSize; }; This is the Start method: kern_return_t IMPL(Mk1dDriver, Start) { kern_return_t ret; IOUSBStandardEndpointDescriptors descriptors; ret = Start(provider, SUPERDISPATCH); __Require(kIOReturnSuccess == ret, Exit); ret = RegisterService(); if (ret != kIOReturnSuccess) { Log("Start() - Failed to register service with error: 0x%08x.", ret); goto Exit; } ivars->interface = OSDynamicCast(IOUSBHostInterface, provider); __Require_Action(NULL != ivars->interface, Exit, ret = kIOReturnNoDevice); ret = ivars->interface->Open(this, 0, NULL); __Require(kIOReturnSuccess == ret, Exit); ret = ivars->interface->CopyPipe(kMyEndpointAddress, &ivars->inPipe); __Require(kIOReturnSuccess == ret, Exit); ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn, 1024, &ivars->inData); __Require(kIOReturnSuccess == ret, Exit); ret = OSAction::Create(this, Mk1dDriver_ReadComplete_ID, IOUSBHostPipe_CompleteAsyncIO_ID, 0, &ivars->ioCompleteCallback); __Require(kIOReturnSuccess == ret, Exit); ret = ivars->inPipe->AsyncIO(ivars->inData, ivars->maxPacketSize, ivars->ioCompleteCallback, 0); __Require(kIOReturnSuccess == ret, Exit); os_log(OS_LOG_DEFAULT,"Finish"); // WWDC slides don't show the full function // i.e. this is still unfinished Exit: return ret; } The only difference in this compared with the code from Apple is that I set capacity in the method CreateIOBuffer to 1024. This is because if I leave it to 0 it will return an error that memory could not be allocated: kIOReturnNoMemory And the ReadComplete method: void IMPL(Mk1dDriver, ReadComplete) { char output[1024]; memcpy(action->GetReference(), &output, 1024); os_log(OS_LOG_DEFAULT,"ReadComplete"); If I put a breakpoint in the log, I can see all the positions in output will be \0 Any idea what I'm doing wrong? Could this be because the iPad is a device under Supervision? Thanks
0
0
2.2k
Nov ’22
Allow Third Party User Clients capability missing error
We have a working DriverKit driver running on iPadOS and a User Client that can communicate from our own app (ie same Development Team bundle identifier). However, we want to share our framework with other vendors to write apps that can communicate with the driver. When we turn on com.apple.developer.driverkit.allow-third-party-userclients in entitlements file, Xcode complains the capability is missing. However, it is clearly "checked on" in the matching identifier (and provisioning profile) on developer portal. We've tried both automatic signing and manual signing. Same error. We have been granted the DriverKit USBTransport - VendorID entitlement already (shows up under additional capabilities). Is there some detail we are missing?
1
0
980
Oct ’22
USB-C custom device on iPads with iOS16
Hi, I wanted to confirm if it is possible to communicate through the USB-C ports of the newer iPads with USB devices that aren't supported natively by iOS. More specifically, we want to be able to interface CCID (smart cards / USB crypto tokens) devices from our app. It seems that, since iOS 16, the IOKit/DriverKit frameworks are now made available. Does it mean we have everything to interface any kind of USB devices from a mobile app? Will there be constraints when submitting the app to the app store later on? On which devices exactly is this possible? All devices that have a USB-C port (newer iPad Pro / iPad Air / iPad mini)? Only a subset of them? Thank you.
0
1
2.0k
Oct ’22
Replacing CoreMediaIO DAL Plug-in with Camera Extension + DriverKit Extension
Hello, According to Create camera extensions with Core Media IO from WWDC2002, one can use driverkit-extension (dext) to communicate with hardware. Does it mean there will be a .dext and a .systemextension in the SystemExtensions folder and they both need to be activated via user prompt separately? We looked into Communicating Between a DriverKit Extension and a Client App and USBApp as our starting point. With NewUserClient implemented, we could open our dext via IOServiceOpen in a user space program. We have been unable to apply similar approach in a cameraextension code sample with the sandbox violation: Violation: deny(1) iokit-open-user-client IOUserUserClient In the plist we did add com.apple.security.temporary-exception.iokit-user-client-class entitlement array with IOUserUserClient like in our other test app. Our goal is to let CMIOExtension exchange data / information with our usb device via function calls like IOConnectCallAsyncStructMethod upon successful opening our userClient Has anyone run into similar problem or is this not the right way to do it? Thanks for your time.
1
0
2k
Sep ’22
Serial Port Communication in Xamarin iOS
Hello Guys, I'm developing Xamarin form cross-platform application. My Requirement is to communicate with the hardware component using Wi-Fi, Bluetooth LE, and USB. I've already completed Wi-Fi and Ble communication functionalities. Now, I'm trying to implement USB port communication on the iOS app. I don't know the proper way to communicate using USB Port. In the past weeks searched about it on the internet, But Most of the suggestions as need to Register for the MFI Program, and a few suggestions were not needed for MFI. Still, I'm not clear . How to integrate USB communication. Please share with me, if you are guys experienced in the USB port communication Thanks Manikandan K
1
0
1.8k
Sep ’22
IOUSBHostPipe::IO hangs on data greater than 256 bytes
We are developing driver for our USB device. We've implemented commutation using IOUSBHostPipe::IO and it perfectly works for data packets that less than 256 bytes. However it hangs when reply from USB device is about 512 bytes. We see 0x2ed // device not responding error when we unplug our device and driver is stopped. Here is our code for setup: constexpr uint32_t kOutEndpointAddress = 1; constexpr uint32_t kInEndpointAddress = 129; constexpr uint16_t kBufferSize = 256; ..... struct ForcePlateDriver_IVars { ....     IOUSBHostPipe            *inPipe;     IOBufferMemoryDescriptor *inData;     uint16_t                  maxPacketSize; }; .....     ret = ivars->interface->CopyPipe(kInEndpointAddress, &ivars->inPipe);     ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn,                                            ivars->maxPacketSize,                                            &ivars->inData); We use following code for reading data from USB device:     uint32_t bytesTransferred = 0;     ret = ivars->inPipe->IO(                             ivars->inData,                             ivars->maxPacketSize,                             &bytesTransferred,                             0); What we tried: Increase kBufferSize to 512 but drive still hangs Change 0 to 2000 (timeout) for inPipe->IO method. Result method returns - 0x2d6(// I/O Timeout)
1
4
1.3k
Sep ’22
USB problems with ANT+ dongle
I have just purchased MacBook Pro with M1 Pro chip. All was fine until the virtual cycling app Rouvy lost ANT+ connection to my smart trainer, cadence and heart rate data. OS is 12.6. I then discovered using System Report that if I remove the dongle it is on the end of a short USB-C to USB-A (female) cable is is not reflected in System report (leaving USB field and returning). The Rouvy app reports the dongle is disconnected. Eventually after several removals and inserting the dongle the Rouvy app see it as connected. A system restart works every time. Any ideas of how to fix this problem. Thanks Truck50
2
0
2.2k
Sep ’22
USB Serial Communication In C/C++
Hello all, I am new to using USB port communications on the Mac; and I was wondering how do I open read and write to an Arduino or similar board with C++ on the MacOS? I know how to do this in python but I HAVE to do it in C/C++ for my particular project. I have read docs like these but they are very outdated: https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBOverview/USBOverview.html#//apple_ref/doc/uid/TP40002644-BBIHAIAG Anything will help thanks!
1
1
4.3k
Aug ’22
DriverKit: limitations of AsyncCallback in IOConnectCallAsyncStructMethod?
We implemented communication between Swift App and DriverKit driver using IOConnectCallAsyncStructMethod. So in Swift App we have following code to setup AsyncDataCallback: func AsyncDataCallback(refcon: UnsafeMutableRawPointer?, result: IOReturn, args: UnsafeMutablePointer<UnsafeMutableRawPointer?>?, numArgs: UInt32) -> Void { // handle args } var asyncRef: [io_user_reference_t] = .init(repeating: 0, count: 8) asyncRef[kIOAsyncCalloutFuncIndex] = unsafeBitCast(AsyncDataCallback as IOAsyncCallback, to: UInt64.self) asyncRef[kIOAsyncCalloutRefconIndex] = unsafeBitCast(self, to: UInt64.self) ...... let notificationPort = IONotificationPortCreate(kIOMasterPortDefault) let machNotificationPort = IONotificationPortGetMachPort(notificationPort) let runLoopSource = IONotificationPortGetRunLoopSource(notificationPort)! CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource.takeUnretainedValue(), CFRunLoopMode.defaultMode) var input = "someinput".map { UInt8($0.asciiValue!) } let inputSize = input.count IOConnectCallAsyncStructMethod(             connection,             123,             machNotificationPort,             &asyncRef,             UInt32(kIOAsyncCalloutCount),             &input,             inputSize,             nil,             nil ) In the driver's ExternalMethod we save callback in ivars: ivars->callbackAction = arguments->completion; ivars->callbackAction->retain(); Next we start communication with our device in a separate thread and execute callback when we get data from device: SendDataAsync(void *data, uint32_t dataLength) { const int asyncDataCount = 16; if (ivars->callbackAction != nullptr) {         Log("SendDataAsync() - got %u bytes", dataLength);         uint64_t asyncData[asyncDataCount] = { };         asyncData[0] = dataLength;         memcpy(asyncData + 1, data, dataLength);         AsyncCompletion(ivars->callbackAction, kIOReturnSuccess, asyncData, asyncDataCount);     } Limitation 1: Our device produces data packet every 10 ms. So driver gets 100 data packets per second. Receive rate is good and we verified it by logs. However we see some delay in AsyncCallback in Swift App. It looks like async calls are queued since we see that Swift App gets callbacks for a few seconds when we stopped to send data from Driver. We measured receive rate in Swift App and it is about 50 data packets per second. So what's a minimum call rate for AsyncCompletion? Is it higher than 10 ms? Maybe there is other more efficient way to asynchronously pass data from Driver to Swift App? Limitation 2: We thought we can buffer data packets and decrease AsyncCompletion call rate. However asyncData could be only 16 of uint64_t by declaration typedef uint64_t IOUserClientAsyncArgumentsArray[16];. Size of our data packer is 112 bytes that perfectly fits to max args size(8*16 = 128 bytes). So we can't cache and send 2 data packets. How we can avoid this limitation and send more data via AsyncCompletion? Is there any other API for asynchronous communication that allows send more data back?
3
1
2k
Aug ’22
USBDriverKit trying to change IOProviderClass and create a IOUSBHostDevice subclass
I have a project that runs correctly when this is set in the dext Info.plist: IOClass: IOUserService IOProviderClass: IOUserResources IOUserClass: MyCustomDriver IOUserServerName: $(PRODUCT_BUNDLE_IDENTIFIER) I'm trying to adjust this so that I can do Driverkit development with USB. I've gotten my development entitlements correct (driverkit.transport.usb) and my dext is [activated, ready]. I've tried changing the IOProviderClass to IOUSBHostDevice. I've tried IOClass set to IOService as well as IOUserService. I've also added idProduct and idVendor keys to both Info.plist and the Driverkit Entitlements file. My dext is properly set up in the system with these changes, but Console.app lists that it has loaded it as a codeless dext. I need my dext implementation to execute. Does anyone have any suggestions? Thanks.
5
1
2.7k
Aug ’22
How to do async IO using IOUSBHostPipe?
We followed WWDC Session: System Extensions and DriverKit and recreated a code to do USB device communication via IOUSBHostPipe: struct MyDriver_IVars {     IOUSBHostInterface       *interface;     IOUSBHostPipe            *inPipe;     OSAction                 *ioCompleteCallback;     IOBufferMemoryDescriptor *inData;     uint16_t                  maxPacketSize; }; kern_return_t IMPL(MyDriver, Start) { ...     ivars->maxPacketSize = 64;     ret = ivars->interface->CreateIOBuffer( kIOMemoryDirectionInOut,                                            ivars->maxPacketSize,                                            &ivars->inData);     ret = CreateActionReadComplete(0, &ivars->ioCompleteCallback); ret = ivars->inPipe->AsyncIO(ivars->inData,                                  ivars->maxPacketSize,                                  ivars->ioCompleteCallback,                                  0); ... } Our Driver is started by OS when device is connected. We see that ReadComplete callback is called: void IMPL(MyDriver, ReadComplete) {     Log("ReadComplete() - status - %d; bytes count - %d", status, actualByteCount); } However it's not obvious how to read data received in this callback. I suspect that we should use IOBufferMemoryDescriptor *inData but we didn't find any good example/sample and documentation is poor. Our callback is called only once. It's not clear how to read a series of data from device? Should we create some loop and call inPipe->AsyncIO from callback? Also it would be helpful to see how to pass data to device. I hope we should fill IOBufferMemoryDescriptor *inData.
5
2
1.4k
Jul ’22
DriverKit on iOS - can't actually communicate with a driver in seed 1?
I watched the session multiple times, but it just gives a high level overview that doesn't really say much about this very exciting and complex new feature. It only mentions actually talking to the driver in passing with a single sentence "apps use the IOKit framework to open user clients". Then the presenter says for an example of that we can check out "communicating between a driverkit extension and a client app", which is a macOS app that doesn't even use IOKit, and trying to import IOKit into an iPadOS target doesn't work anyway because the framework is not there. Am I missing something, or is this simply not available in Xcode 14 seed 1? Release notes don't mention anything either, and docs are only updated to reflect that some of this stuff is now available on iPadOS 16...
7
0
2.8k
Jul ’22
IOUSBHostPipe AsynIO transfer size
I am working on a DriverKit system extension that handles some kind of USB Ethernet adapter. I'm trying to receive data from a Bulk endpoint. Each USB transfer should be up to 512kB, but the actual size of the transfer is not known in advance. What I do is the following: Allocate an IOBufferMemoryDescriptor with IOUSBHostInterface::CreateIOBuffer: ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn, 524288, &b->buffer); Create an OSAction to be used as transfer complete callback: ret = CreateActionReadComplete(0, &b->action); Start the I/O request: ret = ivars->pipe->AsyncIO(b->buffer, 524288, b->action, 0); At that point, I see that instead of starting a single 524288 bytes transfer, it starts 14 36864 bytes transfers and a 8192 bytes one. Which will absolutely not work with the USB device. Is there a transfer size limit I am not aware of?
0
0
806
Jul ’22
USBSerialDriverKit CH340g Not Appearing in /dev
I have a CH340g connected to my M1 MacBook Air running the latest Big Sur 11.2.3. It appeared only one time in /dev, and now will not re-appear. I've tried plugging it in to both ports, unplugging everything except for the CH340g, and also kextunload, kextload on AppleUSBSerial.kext. It does not appear in /dev Has anyone had any luck with this device? Or perhaps some advice?
6
1
6.0k
Jul ’22
Cannot include com.apple.developer.driverkit.transport.usb into provision profile
We requested com.apple.developer.driverkit.transport.usb entitlement a few days ago and it looks like it was granted since we see(can select) it at: App Id -> Additional Capabilities Tab -> DriverKit USB Transport - Vendor ID. We tried to choose both options at Additional Entitlements page Default and Driver Kit and System Extension Template for **** Mac Dev. Generated profile displays DriverKit USB Transport - Vendor ID in Enabled Capabilities in browser. However downloaded profile doesn't include com.apple.developer.driverkit.transport.usb. As a result our Driver fails to start and in Console we see: Driver: Unsatisfied entitlements: com.apple.developer.driverkit.transport.usb /Library/SystemExtensions/675FA894-8985-4D86-B0FF-B892B9AEA27B/Driver.dext/Driver signature not valid: -67671 BTW, we tried to modify existing profile and create a new one. Did we miss something? Is any way to check entitlement status with Apple support?
3
2
2.4k
Jul ’22
DriverKit by Third Party question
I understand that a Company’s hardware vendor ID is required for requesting Entitlements for DriverKit. Does this means DriverKit is only targeted for hardware vendors? Does Apple allows third party (not the hardware vendor) entitlements for DriverKit? Our company is exploring the development of generic open source drivers on iPad for label printers such as those by Zebra. Is this allowed?
1
0
1.7k
Jun ’22
IOUSBHostDevice fails and throws error in sandboxed app
I get the following errors when running the code below in a sandboxed app (it works when not sandboxed) and I have the com.apple.security.device.usb entitlement enabled. Error:Unable to open io_service_t object and create user client. with reason: IOServiceOpen failed. Error Domain=IOUSBHostErrorDomain Code=-536870174 "Failed to create IOUSBHostObject." UserInfo={NSLocalizedRecoverySuggestion=, NSLocalizedDescription=Failed to create IOUSBHostObject., NSLocalizedFailureReason=IOServiceOpen failed.} import Foundation import IOKit import IOKit.usb import IOKit.usb.IOUSBLib import IOKit.serial import IOUSBHost import IOUSBHost.IOUSBHostInterface class USBService {     enum UsbError: Error {         case noDeviceMatched         case deviceCriteriaNotUnique     }          init() {              }          func getDevice(idVendor: Int?, idProduct: Int?) throws {         let deviceSearchPattern: [IOUSBHostMatchingPropertyKey : Int] = [                    .vendorID : idVendor!,                    .productID : idProduct!,                ]                let deviceDomain = [ "IOProviderClass": "IOUSBHostDevice" ]                let searchRequest = (deviceSearchPattern as NSDictionary).mutableCopy() as! NSMutableDictionary                searchRequest.addEntries(from: deviceDomain)         let service = IOServiceGetMatchingService(kIOMasterPortDefault, searchRequest)         guard service != 0 else {                    throw UsbError.noDeviceMatched         }                       let device = try IOUSBHostDevice.init(__ioService: service, options: [], queue: nil, interestHandler: nil)                  print(device.deviceDescriptor?.pointee.idProduct)     } }
3
0
2.5k
May ’22
How to get data from the device using IOBufferMemoryDescriptor in driverKit
I'm trying to create a driver for my usb device, using iOS and DriverKit. I'm basing my code in the example used in WWDC: https://github.com/knightsc/USBApp My driver starts fine when the device is connected and the readCompleted method is called fine, but the action->GetReference() gets only \0 characteres. Also in order to know that the usb device is actually working I've connected it to my mac first and using PyUSB I can see that it's returning data in chunks of 1024 bytes in the interface 0. This is the data I get in PyUSB: array('B', [6, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 47, 0, 48, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, 0, 105, 0, 106, 0, 107, 0, 108, 0, 109, 0, 110, 0, 111, 0, 112, 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, 0, 118, 0, 119, 0, 120, 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0, 127, 0, 128, 0, 129, 0, 130, 0, 131, 0, 132, 0, 133, 0, 134, 0, 135, 0, 136, 0, 137, 0, 138, 0, 139, 0, 140, 0, 141, 0, 142, 0, 143, 0, 144, 0, 145, 0, 146, 0, 147, 0, 148, 0, 149, 0, 150, 0, 151, 0, 152, 0, 153, 0, 154, 0, 155, 0, 156, 0, 157, 0, 158, 0, 159, 0, 160, 0, 161, 0, 162, 0, 163, 0, 164, 0, 165, 0, 166, 0, 167, 0, 168, 0, 169, 0, 170, 0, 171, 0, 172, 0, 173, 0, 174, 0, 175, 0, 176, 0, 177, 0, 178, 0, 179, 0, 180, 0, 181, 0, 182, 0, 183, 0, 184, 0, 185, 0, 186, 0, 187, 0, 188, 0, 189, 0, 190, 0, 191, 0, 192, 0, 193, 0, 194, 0, 195, 0, 196, 0, 197, 0, 198, 0, 199, 0, 200, 0, 201, 0, 202, 0, 203, 0, 204, 0, 205, 0, 206, 0, 207, 0, 208, 0, 209, 0, 210, 0, 211, 0, 212, 0, 213, 0, 214, 0, 215, 0, 216, 0, 217, 0, 218, 0, 219, 0, 220, 0, 221, 0, 222, 0, 223, 0, 224, 0, 225, 0, 226, 0, 227, 0, 228, 0, 229, 0, 230, 0, 231, 0, 232, 0, 233, 0, 234, 0, 235, 0, 236, 0, 237, 0, 238, 0, 239, 0, 240, 0, 241, 0, 242, 0, 243, 0, 244, 0, 245, 0, 246, 0, 247, 0, 248, 0, 249, 0, 250, 0, 251, 0, 252, 0, 253, 0, 254, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) This is the Ivars: struct Mk1dDriver_IVars { IOUSBHostInterface *interface; IOUSBHostPipe *inPipe; OSAction *ioCompleteCallback; IOBufferMemoryDescriptor *inData; uint16_t maxPacketSize; }; This is the Start method: kern_return_t IMPL(Mk1dDriver, Start) { kern_return_t ret; IOUSBStandardEndpointDescriptors descriptors; ret = Start(provider, SUPERDISPATCH); __Require(kIOReturnSuccess == ret, Exit); ret = RegisterService(); if (ret != kIOReturnSuccess) { Log("Start() - Failed to register service with error: 0x%08x.", ret); goto Exit; } ivars->interface = OSDynamicCast(IOUSBHostInterface, provider); __Require_Action(NULL != ivars->interface, Exit, ret = kIOReturnNoDevice); ret = ivars->interface->Open(this, 0, NULL); __Require(kIOReturnSuccess == ret, Exit); ret = ivars->interface->CopyPipe(kMyEndpointAddress, &ivars->inPipe); __Require(kIOReturnSuccess == ret, Exit); ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn, 1024, &ivars->inData); __Require(kIOReturnSuccess == ret, Exit); ret = OSAction::Create(this, Mk1dDriver_ReadComplete_ID, IOUSBHostPipe_CompleteAsyncIO_ID, 0, &ivars->ioCompleteCallback); __Require(kIOReturnSuccess == ret, Exit); ret = ivars->inPipe->AsyncIO(ivars->inData, ivars->maxPacketSize, ivars->ioCompleteCallback, 0); __Require(kIOReturnSuccess == ret, Exit); os_log(OS_LOG_DEFAULT,"Finish"); // WWDC slides don't show the full function // i.e. this is still unfinished Exit: return ret; } The only difference in this compared with the code from Apple is that I set capacity in the method CreateIOBuffer to 1024. This is because if I leave it to 0 it will return an error that memory could not be allocated: kIOReturnNoMemory And the ReadComplete method: void IMPL(Mk1dDriver, ReadComplete) { char output[1024]; memcpy(action->GetReference(), &output, 1024); os_log(OS_LOG_DEFAULT,"ReadComplete"); If I put a breakpoint in the log, I can see all the positions in output will be \0 Any idea what I'm doing wrong? Could this be because the iPad is a device under Supervision? Thanks
Replies
0
Boosts
0
Views
2.2k
Activity
Nov ’22
Allow Third Party User Clients capability missing error
We have a working DriverKit driver running on iPadOS and a User Client that can communicate from our own app (ie same Development Team bundle identifier). However, we want to share our framework with other vendors to write apps that can communicate with the driver. When we turn on com.apple.developer.driverkit.allow-third-party-userclients in entitlements file, Xcode complains the capability is missing. However, it is clearly "checked on" in the matching identifier (and provisioning profile) on developer portal. We've tried both automatic signing and manual signing. Same error. We have been granted the DriverKit USBTransport - VendorID entitlement already (shows up under additional capabilities). Is there some detail we are missing?
Replies
1
Boosts
0
Views
980
Activity
Oct ’22
USB-C custom device on iPads with iOS16
Hi, I wanted to confirm if it is possible to communicate through the USB-C ports of the newer iPads with USB devices that aren't supported natively by iOS. More specifically, we want to be able to interface CCID (smart cards / USB crypto tokens) devices from our app. It seems that, since iOS 16, the IOKit/DriverKit frameworks are now made available. Does it mean we have everything to interface any kind of USB devices from a mobile app? Will there be constraints when submitting the app to the app store later on? On which devices exactly is this possible? All devices that have a USB-C port (newer iPad Pro / iPad Air / iPad mini)? Only a subset of them? Thank you.
Replies
0
Boosts
1
Views
2.0k
Activity
Oct ’22
Ventura usb-c to HDMI doesn’t work
Ventura beta 5 and later doesn’t work with external monitor usb-c to HDMI on Mac book air M1 2020. Does someone decide this problem?
Replies
3
Boosts
2
Views
1.3k
Activity
Oct ’22
Replacing CoreMediaIO DAL Plug-in with Camera Extension + DriverKit Extension
Hello, According to Create camera extensions with Core Media IO from WWDC2002, one can use driverkit-extension (dext) to communicate with hardware. Does it mean there will be a .dext and a .systemextension in the SystemExtensions folder and they both need to be activated via user prompt separately? We looked into Communicating Between a DriverKit Extension and a Client App and USBApp as our starting point. With NewUserClient implemented, we could open our dext via IOServiceOpen in a user space program. We have been unable to apply similar approach in a cameraextension code sample with the sandbox violation: Violation: deny(1) iokit-open-user-client IOUserUserClient In the plist we did add com.apple.security.temporary-exception.iokit-user-client-class entitlement array with IOUserUserClient like in our other test app. Our goal is to let CMIOExtension exchange data / information with our usb device via function calls like IOConnectCallAsyncStructMethod upon successful opening our userClient Has anyone run into similar problem or is this not the right way to do it? Thanks for your time.
Replies
1
Boosts
0
Views
2k
Activity
Sep ’22
Serial Port Communication in Xamarin iOS
Hello Guys, I'm developing Xamarin form cross-platform application. My Requirement is to communicate with the hardware component using Wi-Fi, Bluetooth LE, and USB. I've already completed Wi-Fi and Ble communication functionalities. Now, I'm trying to implement USB port communication on the iOS app. I don't know the proper way to communicate using USB Port. In the past weeks searched about it on the internet, But Most of the suggestions as need to Register for the MFI Program, and a few suggestions were not needed for MFI. Still, I'm not clear . How to integrate USB communication. Please share with me, if you are guys experienced in the USB port communication Thanks Manikandan K
Replies
1
Boosts
0
Views
1.8k
Activity
Sep ’22
IOUSBHostPipe::IO hangs on data greater than 256 bytes
We are developing driver for our USB device. We've implemented commutation using IOUSBHostPipe::IO and it perfectly works for data packets that less than 256 bytes. However it hangs when reply from USB device is about 512 bytes. We see 0x2ed // device not responding error when we unplug our device and driver is stopped. Here is our code for setup: constexpr uint32_t kOutEndpointAddress = 1; constexpr uint32_t kInEndpointAddress = 129; constexpr uint16_t kBufferSize = 256; ..... struct ForcePlateDriver_IVars { ....     IOUSBHostPipe            *inPipe;     IOBufferMemoryDescriptor *inData;     uint16_t                  maxPacketSize; }; .....     ret = ivars->interface->CopyPipe(kInEndpointAddress, &ivars->inPipe);     ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn,                                            ivars->maxPacketSize,                                            &ivars->inData); We use following code for reading data from USB device:     uint32_t bytesTransferred = 0;     ret = ivars->inPipe->IO(                             ivars->inData,                             ivars->maxPacketSize,                             &bytesTransferred,                             0); What we tried: Increase kBufferSize to 512 but drive still hangs Change 0 to 2000 (timeout) for inPipe->IO method. Result method returns - 0x2d6(// I/O Timeout)
Replies
1
Boosts
4
Views
1.3k
Activity
Sep ’22
USB problems with ANT+ dongle
I have just purchased MacBook Pro with M1 Pro chip. All was fine until the virtual cycling app Rouvy lost ANT+ connection to my smart trainer, cadence and heart rate data. OS is 12.6. I then discovered using System Report that if I remove the dongle it is on the end of a short USB-C to USB-A (female) cable is is not reflected in System report (leaving USB field and returning). The Rouvy app reports the dongle is disconnected. Eventually after several removals and inserting the dongle the Rouvy app see it as connected. A system restart works every time. Any ideas of how to fix this problem. Thanks Truck50
Replies
2
Boosts
0
Views
2.2k
Activity
Sep ’22
How to get LUN id of SCSI connected devices
Hi all I needed some help in getting the LUN id of all devices connected to the system especially for SCSI devices. I'm not able to find any such system command or a SCSI command. Thanks in advance.
Replies
2
Boosts
0
Views
1.6k
Activity
Sep ’22
USB Serial Communication In C/C++
Hello all, I am new to using USB port communications on the Mac; and I was wondering how do I open read and write to an Arduino or similar board with C++ on the MacOS? I know how to do this in python but I HAVE to do it in C/C++ for my particular project. I have read docs like these but they are very outdated: https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBOverview/USBOverview.html#//apple_ref/doc/uid/TP40002644-BBIHAIAG Anything will help thanks!
Replies
1
Boosts
1
Views
4.3k
Activity
Aug ’22
DriverKit: limitations of AsyncCallback in IOConnectCallAsyncStructMethod?
We implemented communication between Swift App and DriverKit driver using IOConnectCallAsyncStructMethod. So in Swift App we have following code to setup AsyncDataCallback: func AsyncDataCallback(refcon: UnsafeMutableRawPointer?, result: IOReturn, args: UnsafeMutablePointer<UnsafeMutableRawPointer?>?, numArgs: UInt32) -> Void { // handle args } var asyncRef: [io_user_reference_t] = .init(repeating: 0, count: 8) asyncRef[kIOAsyncCalloutFuncIndex] = unsafeBitCast(AsyncDataCallback as IOAsyncCallback, to: UInt64.self) asyncRef[kIOAsyncCalloutRefconIndex] = unsafeBitCast(self, to: UInt64.self) ...... let notificationPort = IONotificationPortCreate(kIOMasterPortDefault) let machNotificationPort = IONotificationPortGetMachPort(notificationPort) let runLoopSource = IONotificationPortGetRunLoopSource(notificationPort)! CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource.takeUnretainedValue(), CFRunLoopMode.defaultMode) var input = "someinput".map { UInt8($0.asciiValue!) } let inputSize = input.count IOConnectCallAsyncStructMethod(             connection,             123,             machNotificationPort,             &asyncRef,             UInt32(kIOAsyncCalloutCount),             &input,             inputSize,             nil,             nil ) In the driver's ExternalMethod we save callback in ivars: ivars->callbackAction = arguments->completion; ivars->callbackAction->retain(); Next we start communication with our device in a separate thread and execute callback when we get data from device: SendDataAsync(void *data, uint32_t dataLength) { const int asyncDataCount = 16; if (ivars->callbackAction != nullptr) {         Log("SendDataAsync() - got %u bytes", dataLength);         uint64_t asyncData[asyncDataCount] = { };         asyncData[0] = dataLength;         memcpy(asyncData + 1, data, dataLength);         AsyncCompletion(ivars->callbackAction, kIOReturnSuccess, asyncData, asyncDataCount);     } Limitation 1: Our device produces data packet every 10 ms. So driver gets 100 data packets per second. Receive rate is good and we verified it by logs. However we see some delay in AsyncCallback in Swift App. It looks like async calls are queued since we see that Swift App gets callbacks for a few seconds when we stopped to send data from Driver. We measured receive rate in Swift App and it is about 50 data packets per second. So what's a minimum call rate for AsyncCompletion? Is it higher than 10 ms? Maybe there is other more efficient way to asynchronously pass data from Driver to Swift App? Limitation 2: We thought we can buffer data packets and decrease AsyncCompletion call rate. However asyncData could be only 16 of uint64_t by declaration typedef uint64_t IOUserClientAsyncArgumentsArray[16];. Size of our data packer is 112 bytes that perfectly fits to max args size(8*16 = 128 bytes). So we can't cache and send 2 data packets. How we can avoid this limitation and send more data via AsyncCompletion? Is there any other API for asynchronous communication that allows send more data back?
Replies
3
Boosts
1
Views
2k
Activity
Aug ’22
USBDriverKit trying to change IOProviderClass and create a IOUSBHostDevice subclass
I have a project that runs correctly when this is set in the dext Info.plist: IOClass: IOUserService IOProviderClass: IOUserResources IOUserClass: MyCustomDriver IOUserServerName: $(PRODUCT_BUNDLE_IDENTIFIER) I'm trying to adjust this so that I can do Driverkit development with USB. I've gotten my development entitlements correct (driverkit.transport.usb) and my dext is [activated, ready]. I've tried changing the IOProviderClass to IOUSBHostDevice. I've tried IOClass set to IOService as well as IOUserService. I've also added idProduct and idVendor keys to both Info.plist and the Driverkit Entitlements file. My dext is properly set up in the system with these changes, but Console.app lists that it has loaded it as a codeless dext. I need my dext implementation to execute. Does anyone have any suggestions? Thanks.
Replies
5
Boosts
1
Views
2.7k
Activity
Aug ’22
How to do async IO using IOUSBHostPipe?
We followed WWDC Session: System Extensions and DriverKit and recreated a code to do USB device communication via IOUSBHostPipe: struct MyDriver_IVars {     IOUSBHostInterface       *interface;     IOUSBHostPipe            *inPipe;     OSAction                 *ioCompleteCallback;     IOBufferMemoryDescriptor *inData;     uint16_t                  maxPacketSize; }; kern_return_t IMPL(MyDriver, Start) { ...     ivars->maxPacketSize = 64;     ret = ivars->interface->CreateIOBuffer( kIOMemoryDirectionInOut,                                            ivars->maxPacketSize,                                            &ivars->inData);     ret = CreateActionReadComplete(0, &ivars->ioCompleteCallback); ret = ivars->inPipe->AsyncIO(ivars->inData,                                  ivars->maxPacketSize,                                  ivars->ioCompleteCallback,                                  0); ... } Our Driver is started by OS when device is connected. We see that ReadComplete callback is called: void IMPL(MyDriver, ReadComplete) {     Log("ReadComplete() - status - %d; bytes count - %d", status, actualByteCount); } However it's not obvious how to read data received in this callback. I suspect that we should use IOBufferMemoryDescriptor *inData but we didn't find any good example/sample and documentation is poor. Our callback is called only once. It's not clear how to read a series of data from device? Should we create some loop and call inPipe->AsyncIO from callback? Also it would be helpful to see how to pass data to device. I hope we should fill IOBufferMemoryDescriptor *inData.
Replies
5
Boosts
2
Views
1.4k
Activity
Jul ’22
DriverKit on iOS - can't actually communicate with a driver in seed 1?
I watched the session multiple times, but it just gives a high level overview that doesn't really say much about this very exciting and complex new feature. It only mentions actually talking to the driver in passing with a single sentence "apps use the IOKit framework to open user clients". Then the presenter says for an example of that we can check out "communicating between a driverkit extension and a client app", which is a macOS app that doesn't even use IOKit, and trying to import IOKit into an iPadOS target doesn't work anyway because the framework is not there. Am I missing something, or is this simply not available in Xcode 14 seed 1? Release notes don't mention anything either, and docs are only updated to reflect that some of this stuff is now available on iPadOS 16...
Replies
7
Boosts
0
Views
2.8k
Activity
Jul ’22
IOUSBHostPipe AsynIO transfer size
I am working on a DriverKit system extension that handles some kind of USB Ethernet adapter. I'm trying to receive data from a Bulk endpoint. Each USB transfer should be up to 512kB, but the actual size of the transfer is not known in advance. What I do is the following: Allocate an IOBufferMemoryDescriptor with IOUSBHostInterface::CreateIOBuffer: ret = ivars->interface->CreateIOBuffer(kIOMemoryDirectionIn, 524288, &b->buffer); Create an OSAction to be used as transfer complete callback: ret = CreateActionReadComplete(0, &b->action); Start the I/O request: ret = ivars->pipe->AsyncIO(b->buffer, 524288, b->action, 0); At that point, I see that instead of starting a single 524288 bytes transfer, it starts 14 36864 bytes transfers and a 8192 bytes one. Which will absolutely not work with the USB device. Is there a transfer size limit I am not aware of?
Replies
0
Boosts
0
Views
806
Activity
Jul ’22
USBSerialDriverKit CH340g Not Appearing in /dev
I have a CH340g connected to my M1 MacBook Air running the latest Big Sur 11.2.3. It appeared only one time in /dev, and now will not re-appear. I've tried plugging it in to both ports, unplugging everything except for the CH340g, and also kextunload, kextload on AppleUSBSerial.kext. It does not appear in /dev Has anyone had any luck with this device? Or perhaps some advice?
Replies
6
Boosts
1
Views
6.0k
Activity
Jul ’22
Cannot include com.apple.developer.driverkit.transport.usb into provision profile
We requested com.apple.developer.driverkit.transport.usb entitlement a few days ago and it looks like it was granted since we see(can select) it at: App Id -> Additional Capabilities Tab -> DriverKit USB Transport - Vendor ID. We tried to choose both options at Additional Entitlements page Default and Driver Kit and System Extension Template for **** Mac Dev. Generated profile displays DriverKit USB Transport - Vendor ID in Enabled Capabilities in browser. However downloaded profile doesn't include com.apple.developer.driverkit.transport.usb. As a result our Driver fails to start and in Console we see: Driver: Unsatisfied entitlements: com.apple.developer.driverkit.transport.usb /Library/SystemExtensions/675FA894-8985-4D86-B0FF-B892B9AEA27B/Driver.dext/Driver signature not valid: -67671 BTW, we tried to modify existing profile and create a new one. Did we miss something? Is any way to check entitlement status with Apple support?
Replies
3
Boosts
2
Views
2.4k
Activity
Jul ’22
DriverKit entitlement request ETA
Earlier this week, I requested a DriverKit entitlement (#801892899). Just wanted to see if there was an expected ETA on such requests. Thank you, Neal
Replies
2
Boosts
1
Views
1.3k
Activity
Jun ’22
DriverKit by Third Party question
I understand that a Company’s hardware vendor ID is required for requesting Entitlements for DriverKit. Does this means DriverKit is only targeted for hardware vendors? Does Apple allows third party (not the hardware vendor) entitlements for DriverKit? Our company is exploring the development of generic open source drivers on iPad for label printers such as those by Zebra. Is this allowed?
Replies
1
Boosts
0
Views
1.7k
Activity
Jun ’22
IOUSBHostDevice fails and throws error in sandboxed app
I get the following errors when running the code below in a sandboxed app (it works when not sandboxed) and I have the com.apple.security.device.usb entitlement enabled. Error:Unable to open io_service_t object and create user client. with reason: IOServiceOpen failed. Error Domain=IOUSBHostErrorDomain Code=-536870174 "Failed to create IOUSBHostObject." UserInfo={NSLocalizedRecoverySuggestion=, NSLocalizedDescription=Failed to create IOUSBHostObject., NSLocalizedFailureReason=IOServiceOpen failed.} import Foundation import IOKit import IOKit.usb import IOKit.usb.IOUSBLib import IOKit.serial import IOUSBHost import IOUSBHost.IOUSBHostInterface class USBService {     enum UsbError: Error {         case noDeviceMatched         case deviceCriteriaNotUnique     }          init() {              }          func getDevice(idVendor: Int?, idProduct: Int?) throws {         let deviceSearchPattern: [IOUSBHostMatchingPropertyKey : Int] = [                    .vendorID : idVendor!,                    .productID : idProduct!,                ]                let deviceDomain = [ "IOProviderClass": "IOUSBHostDevice" ]                let searchRequest = (deviceSearchPattern as NSDictionary).mutableCopy() as! NSMutableDictionary                searchRequest.addEntries(from: deviceDomain)         let service = IOServiceGetMatchingService(kIOMasterPortDefault, searchRequest)         guard service != 0 else {                    throw UsbError.noDeviceMatched         }                       let device = try IOUSBHostDevice.init(__ioService: service, options: [], queue: nil, interestHandler: nil)                  print(device.deviceDescriptor?.pointee.idProduct)     } }
Replies
3
Boosts
0
Views
2.5k
Activity
May ’22