USBDriverKit

RSS for tag

Develop drivers for USB-based devices using USBDriverKit.

Posts under USBDriverKit tag

192 Posts

Post

Replies

Boosts

Views

Activity

How to communicate between USBDriverKit driver and Client app?
We are experimenting with DriverKit on macOS while DriverKit is still in beta on iPadOS. We want to build a Driver for iPad that will allow to communicate our iPad App with USB device. What we did: Configured and implemented a driver that uses USBDriverKit::IOUSBHostInterface as provider. This driver is automatically matched/started by macOS when we plug our device into USB port. Next we utilised USBDriverKit::IOUSBHostPipe to send/receive data from our device. We print data from device in logs for now. Studied Communicating Between a DriverKit Extension and a Client App Configured and implemented a driver that based on IOUserClient and allows to open communication channel by macOs App using IOServiceOpen API. Driver has callback to pass data to macOS Client App. Currently we want to combine 2 drivers and pass data received from USB device to our client App using callback. Unfortunately, we stuck since now we have 2 instances of driver: First instance is automatically run by macOS when device is plugged Second instance is created when we are connecting from Client App and virtual kern_return_t NewUserClient(uint32_t type, IOUserClient** userClient) method is called. So we can't use second instance to do USB device communication since it has wrong provider(IOUserClient) in kern_return_t Start(IOService * provider) but we need IOUSBHostInterface to start:     ivars->interface = OSDynamicCast(IOUSBHostInterface, provider);     if(ivars->interface == NULL) {         ret = kIOReturnNoDevice;         goto Exit;     } Are we doing it wrong? Maybe instead of automatic matching for IOUSBHostInterface we should do it manually from UserClient driver or use another approach? As we learned we have to create a new service instance in NewUserClient method and can't return driver that was run by OS: kern_return_t IMPL(MyDriver, NewUserClient) {     kern_return_t ret = kIOReturnSuccess;     IOService* client = nullptr;     ret = Create(this, "UserClientProperties", &client);     if (ret != kIOReturnSuccess)     {         goto Exit;     }     *userClient = OSDynamicCast(IOUserClient, client);     if (*userClient == NULL)     {         client->release();         ret = kIOReturnError;         goto Exit;     } Exit:     return ret; } BTW, maybe there is much easier way to forward data from USB device to iPadOS App?
2
2
2.3k
Mar ’23
Is it possible to show a popup when a device is plugin with no driver neither app installed
I wonder if it's possible to show a popup when a device is plugged in the iOS device but the driver/app is not installed. I've seen this before when old days without DriverKit where a notification was shown to help the user. If the user accepted the popup the Apple store opened with the page download the particular app to install the driver for the device. Thanks
0
0
773
Mar ’23
How to write kernel driver for USB on macOS ?
I am creating a macOS app that will send commands to a USB device when it is plugged into a Mac. There are only two steps to accomplish this: send request commands to the USB and receive response messages from it. The USB has an attached SCSI, but I am unsure of how to send SCSI commands to macOS. Research has indicated that a kernel driver must be written for the USB to function on macOS. I have a .cpp file that can be converted into a .dll file to work on the Windows side. Is it possible to reuse this .cpp file and convert it into a .so file that can run on the macOS side? Is there someone interested in this project? I am looking to outsource it.
0
0
1.1k
Feb ’23
USB serial port not showing up after Monterey OS upgrade
Past 8-9 months we've been working on Arduino/ ESP32 with no issues, but after upgrading the OS the port stopped showing up under /dev/tty.cuserial. We tried to install the driver from Silicon Labs CP210x VCP Driver for MacOS(installed w/ no issues) but in the system information, we are seeing the S/w is sitting under disabled S/w list com.silabs.driver.CP210xVCPDriver: unknown. How can we fix this and get it out of disabled S/w?
2
0
2.3k
Feb ’23
Audio Driver is not assigned with the default Driver
Hi, We finally managed to assign our Driver (based on the SimpleAudioDriver) to the right audio device. But we now have two devices showing up : one is assigned with our driver and the other one is assigned to the default driver. How can we override the original one with ours, to just have one device showing up ? If you have any hints, please get back to us. Thanks.
0
0
907
Jan ’23
General Audio Driver Development Questions
Hi, I need to develop a cross-plateform driver extension (similar to a Windows Audio Processing Object (APO)) for an Audio Device and I'm struggling with associating the driver to a USB Audio Device. I'm using the SimpleAudioDriver example and override the device_uid with the Product ID and the manufacturer_uid with the Vendor ID. As I understand it with this documentation : https://developer.apple.com/news/?id=zk5xdwbn it should associate my driver with the device but it creates a new device. If you have any hints, please get back to me. Thanks.
2
0
1.9k
Jan ’23
How can I use USBmakebmRequestType with DriverKit
I'm building a driver in C++ for my iPad using DriverKit. I'm trying to make a request to a control endpoint, so I'm trying to use DeviceRequest: https://developer.apple.com/documentation/usbdriverkit/iousbhostinterface/3182582-devicerequest But the first parameter ask for USBmakebmRequestType which it's a macro defined in IOKit > USB.h I tried to #include <IOKit/USB.h> and #include <IOKit/usb/USB.h> and  but it doesn't find the header. Any idea? thanks.
1
0
1.7k
Dec ’22
Different Drivers for Individual Interfaces
Hello We have a USB camera. My Mac can recognize it and we can get frames with any software. There is a physical button on it and the vendor says the camera is UVC-compliant. But button doesn't work anyway. I captured some USB traffic data and saw that it has two interfaces. One for streaming and other one for interrupting (like button click). I read UVC 1.5 standards to understand it and it is working like written in UVC 1.5. So, I can get a data with an interrupt transfer when clicking the button. I checked these two interfaces, they use UVCAssistant for driver(System Extension). I tried to use libusb, I can get data from button click. But for frames I had to use libuvc, but it wasn't work for my camera (I think it is related with USB descriptor parsing in libuvc). I thought that I should write a driver for single interface and so second interface will use same UVC assistant driver and first interface will use my driver. I wrote a driver and it matches with first interface. But second interface is empty (unhandled by any driver). I want to load UVCAssistant for second interface of USB port. How can I do this? Output before loading my driver After loading: IOKitPersonalities that I used:
2
0
1.8k
Dec ’22
The DriverKit problems to develop multiple serial USB device
Hi, I am developing a DriverKit driver for a USB device which has multiple serial UARTs connected. Each UART will represent a cu.USBX port on Mac. My driver inherits IOUSBHostDevice class and it matches device ID well. Now, I am going to crate a new class inherits IOUserSerial to implement serial port. However, compiler said no new operator on base class. It seems the base OSObject class prevent to new the subclass as I did in IOKit driver. Since the similar IOUserSerial/IOUserUSBSerial examples are hard to find, I would like to ask if anyone can help me to solve this problem. Any feedback and clue is appreciated. Following are some snippets to show my situation. My IOKit port driver inherits IORS232SerialStreamSync. class KextSerial : public IORS232SerialStreamSync { OSDeclareDefaultStructors( KextSerial ) ; // Constructor & Destructor stuff : } My USB driver could create new KextSerials and initiate them as well. KextSerial * newSerial = new KextSerial; if( !newSerial->init(0, 0) ){ goto FailExit; } However, in my DriverKit port driver inherits IOUserSerial. class DextSerial : public IOUserSerial { : } While I try to new the DextSerial as following. DextSerial * newSerial = new DextSerial; The compiler said "No matching function for call to 'operator new'" Parallelly I have tried IOUserUSBSerial and OSObject, I got the same error message.
3
0
1.1k
Nov ’22
DriverKit Share Memory from User Client to App for Streaming
Does anyone have an example of streaming video data from a user client to a client app? I have successfully set up a DriverKit USB hardware driver that commands a device to successfully fill the same IOBufferMemoryDescriptor at 30fps with new data (verified in driver). I have also managed to map this buffer to the application using CopyClientMemoryForType in the user client and IOConnectMapMemory64 in the app. I have also confirmed the data is the intended image data. What I CAN NOT do is see updates in the mapped memory in the app. I map and unmap the data, but the contents don't change. No matter how many times I map, CopyClientMemoryForType is called once. How should changes to the underlying dext space memory be reflected/synchronized to the app? Can I not share a single buffer (4-12MB, ringed) and synchronize updates?
1
0
1.2k
Nov ’22
DriverKit demo app doubts
Hello everyone, I downloaded the demo app from the driverkit demo located at https://developer.apple.com/documentation/driverkit/communicating_between_a_driverkit_extension_and_a_client_app, I downloaded the files and followed the process in the two possible ways by letting xcode automatically sign the app and by me creating the provisioning profiles, everything compiles but I am facing this particular issue whenever I try to invoke the system installation of the driver:2022-11-16 00:45:12.425147-0600 DriverKitSampleApp[5837:69830] sysex didFailWithError: The operation couldn’t be completed. (OSSystemExtensionErrorDomain error 9.) There is very little to none information on the web, and I dont know what else to do at this point.
1
0
1.4k
Nov ’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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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.1k
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
901
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
1.9k
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
1.9k
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.6k
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.2k
Sep ’22
How to communicate between USBDriverKit driver and Client app?
We are experimenting with DriverKit on macOS while DriverKit is still in beta on iPadOS. We want to build a Driver for iPad that will allow to communicate our iPad App with USB device. What we did: Configured and implemented a driver that uses USBDriverKit::IOUSBHostInterface as provider. This driver is automatically matched/started by macOS when we plug our device into USB port. Next we utilised USBDriverKit::IOUSBHostPipe to send/receive data from our device. We print data from device in logs for now. Studied Communicating Between a DriverKit Extension and a Client App Configured and implemented a driver that based on IOUserClient and allows to open communication channel by macOs App using IOServiceOpen API. Driver has callback to pass data to macOS Client App. Currently we want to combine 2 drivers and pass data received from USB device to our client App using callback. Unfortunately, we stuck since now we have 2 instances of driver: First instance is automatically run by macOS when device is plugged Second instance is created when we are connecting from Client App and virtual kern_return_t NewUserClient(uint32_t type, IOUserClient** userClient) method is called. So we can't use second instance to do USB device communication since it has wrong provider(IOUserClient) in kern_return_t Start(IOService * provider) but we need IOUSBHostInterface to start:     ivars->interface = OSDynamicCast(IOUSBHostInterface, provider);     if(ivars->interface == NULL) {         ret = kIOReturnNoDevice;         goto Exit;     } Are we doing it wrong? Maybe instead of automatic matching for IOUSBHostInterface we should do it manually from UserClient driver or use another approach? As we learned we have to create a new service instance in NewUserClient method and can't return driver that was run by OS: kern_return_t IMPL(MyDriver, NewUserClient) {     kern_return_t ret = kIOReturnSuccess;     IOService* client = nullptr;     ret = Create(this, "UserClientProperties", &client);     if (ret != kIOReturnSuccess)     {         goto Exit;     }     *userClient = OSDynamicCast(IOUserClient, client);     if (*userClient == NULL)     {         client->release();         ret = kIOReturnError;         goto Exit;     } Exit:     return ret; } BTW, maybe there is much easier way to forward data from USB device to iPadOS App?
Replies
2
Boosts
2
Views
2.3k
Activity
Mar ’23
Is it possible to show a popup when a device is plugin with no driver neither app installed
I wonder if it's possible to show a popup when a device is plugged in the iOS device but the driver/app is not installed. I've seen this before when old days without DriverKit where a notification was shown to help the user. If the user accepted the popup the Apple store opened with the page download the particular app to install the driver for the device. Thanks
Replies
0
Boosts
0
Views
773
Activity
Mar ’23
Is there Anyway to Enable/Disable USB Storage Device in Mac?
Hi, I want to enable/disable my USB Storage stick with using MQTT server. I can connect my server, listen and publish some datas. Is it possible to do change USB status with Swift, in XCode? It should be only change storage device, because i don't want to disconnect my mouse or etc.
Replies
0
Boosts
0
Views
1.1k
Activity
Mar ’23
How to write kernel driver for USB on macOS ?
I am creating a macOS app that will send commands to a USB device when it is plugged into a Mac. There are only two steps to accomplish this: send request commands to the USB and receive response messages from it. The USB has an attached SCSI, but I am unsure of how to send SCSI commands to macOS. Research has indicated that a kernel driver must be written for the USB to function on macOS. I have a .cpp file that can be converted into a .dll file to work on the Windows side. Is it possible to reuse this .cpp file and convert it into a .so file that can run on the macOS side? Is there someone interested in this project? I am looking to outsource it.
Replies
0
Boosts
0
Views
1.1k
Activity
Feb ’23
DISK NOT EJECTED PROPERLY keeps popping up Big Sur 11.3.1
After updating to Big Sur 11.3.1 my MacBook Pro 2013 keeps ejecting my 2TB Seagate external drive. As a result, I'm not able to back up using Time Machine. Would be happy to get support for this issue.
Replies
71
Boosts
4
Views
54k
Activity
Feb ’23
USB serial port not showing up after Monterey OS upgrade
Past 8-9 months we've been working on Arduino/ ESP32 with no issues, but after upgrading the OS the port stopped showing up under /dev/tty.cuserial. We tried to install the driver from Silicon Labs CP210x VCP Driver for MacOS(installed w/ no issues) but in the system information, we are seeing the S/w is sitting under disabled S/w list com.silabs.driver.CP210xVCPDriver: unknown. How can we fix this and get it out of disabled S/w?
Replies
2
Boosts
0
Views
2.3k
Activity
Feb ’23
Audio Driver is not assigned with the default Driver
Hi, We finally managed to assign our Driver (based on the SimpleAudioDriver) to the right audio device. But we now have two devices showing up : one is assigned with our driver and the other one is assigned to the default driver. How can we override the original one with ours, to just have one device showing up ? If you have any hints, please get back to us. Thanks.
Replies
0
Boosts
0
Views
907
Activity
Jan ’23
General Audio Driver Development Questions
Hi, I need to develop a cross-plateform driver extension (similar to a Windows Audio Processing Object (APO)) for an Audio Device and I'm struggling with associating the driver to a USB Audio Device. I'm using the SimpleAudioDriver example and override the device_uid with the Product ID and the manufacturer_uid with the Vendor ID. As I understand it with this documentation : https://developer.apple.com/news/?id=zk5xdwbn it should associate my driver with the device but it creates a new device. If you have any hints, please get back to me. Thanks.
Replies
2
Boosts
0
Views
1.9k
Activity
Jan ’23
How can I use USBmakebmRequestType with DriverKit
I'm building a driver in C++ for my iPad using DriverKit. I'm trying to make a request to a control endpoint, so I'm trying to use DeviceRequest: https://developer.apple.com/documentation/usbdriverkit/iousbhostinterface/3182582-devicerequest But the first parameter ask for USBmakebmRequestType which it's a macro defined in IOKit > USB.h I tried to #include <IOKit/USB.h> and #include <IOKit/usb/USB.h> and  but it doesn't find the header. Any idea? thanks.
Replies
1
Boosts
0
Views
1.7k
Activity
Dec ’22
Different Drivers for Individual Interfaces
Hello We have a USB camera. My Mac can recognize it and we can get frames with any software. There is a physical button on it and the vendor says the camera is UVC-compliant. But button doesn't work anyway. I captured some USB traffic data and saw that it has two interfaces. One for streaming and other one for interrupting (like button click). I read UVC 1.5 standards to understand it and it is working like written in UVC 1.5. So, I can get a data with an interrupt transfer when clicking the button. I checked these two interfaces, they use UVCAssistant for driver(System Extension). I tried to use libusb, I can get data from button click. But for frames I had to use libuvc, but it wasn't work for my camera (I think it is related with USB descriptor parsing in libuvc). I thought that I should write a driver for single interface and so second interface will use same UVC assistant driver and first interface will use my driver. I wrote a driver and it matches with first interface. But second interface is empty (unhandled by any driver). I want to load UVCAssistant for second interface of USB port. How can I do this? Output before loading my driver After loading: IOKitPersonalities that I used:
Replies
2
Boosts
0
Views
1.8k
Activity
Dec ’22
The DriverKit problems to develop multiple serial USB device
Hi, I am developing a DriverKit driver for a USB device which has multiple serial UARTs connected. Each UART will represent a cu.USBX port on Mac. My driver inherits IOUSBHostDevice class and it matches device ID well. Now, I am going to crate a new class inherits IOUserSerial to implement serial port. However, compiler said no new operator on base class. It seems the base OSObject class prevent to new the subclass as I did in IOKit driver. Since the similar IOUserSerial/IOUserUSBSerial examples are hard to find, I would like to ask if anyone can help me to solve this problem. Any feedback and clue is appreciated. Following are some snippets to show my situation. My IOKit port driver inherits IORS232SerialStreamSync. class KextSerial : public IORS232SerialStreamSync { OSDeclareDefaultStructors( KextSerial ) ; // Constructor & Destructor stuff : } My USB driver could create new KextSerials and initiate them as well. KextSerial * newSerial = new KextSerial; if( !newSerial->init(0, 0) ){ goto FailExit; } However, in my DriverKit port driver inherits IOUserSerial. class DextSerial : public IOUserSerial { : } While I try to new the DextSerial as following. DextSerial * newSerial = new DextSerial; The compiler said "No matching function for call to 'operator new'" Parallelly I have tried IOUserUSBSerial and OSObject, I got the same error message.
Replies
3
Boosts
0
Views
1.1k
Activity
Nov ’22
DriverKit Share Memory from User Client to App for Streaming
Does anyone have an example of streaming video data from a user client to a client app? I have successfully set up a DriverKit USB hardware driver that commands a device to successfully fill the same IOBufferMemoryDescriptor at 30fps with new data (verified in driver). I have also managed to map this buffer to the application using CopyClientMemoryForType in the user client and IOConnectMapMemory64 in the app. I have also confirmed the data is the intended image data. What I CAN NOT do is see updates in the mapped memory in the app. I map and unmap the data, but the contents don't change. No matter how many times I map, CopyClientMemoryForType is called once. How should changes to the underlying dext space memory be reflected/synchronized to the app? Can I not share a single buffer (4-12MB, ringed) and synchronize updates?
Replies
1
Boosts
0
Views
1.2k
Activity
Nov ’22
DriverKit demo app doubts
Hello everyone, I downloaded the demo app from the driverkit demo located at https://developer.apple.com/documentation/driverkit/communicating_between_a_driverkit_extension_and_a_client_app, I downloaded the files and followed the process in the two possible ways by letting xcode automatically sign the app and by me creating the provisioning profiles, everything compiles but I am facing this particular issue whenever I try to invoke the system installation of the driver:2022-11-16 00:45:12.425147-0600 DriverKitSampleApp[5837:69830] sysex didFailWithError: The operation couldn’t be completed. (OSSystemExtensionErrorDomain error 9.) There is very little to none information on the web, and I dont know what else to do at this point.
Replies
1
Boosts
0
Views
1.4k
Activity
Nov ’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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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.1k
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
901
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
1.9k
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
1.9k
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.6k
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.2k
Activity
Sep ’22