Post

Replies

Boosts

Views

Activity

memory leak of API IOCreatePlugInInterfaceForService in IOKit
we are developing USB hid library to interact with HID device, however we're facing on memory lacking when we calling IOCreatePlugInInterfaceForService then calling IODestroyPlugInInterface, the memory is not released and each time of calling it take about 0.3 MB Ram, after long time running, the program crash because runout of memory. what should we do in this case to avoid memory leak? // Create a device interface/HANDLE static BOOL CreateHidDeviceInterface(io_object_t deviceObject, HANDLE* pHandle) { BOOL retVal = FALSE; IOCFPlugInInterface** ppPluginInterface = NULL; SInt32 score = 0; IOReturn pluginResult; HRESULT interfaceResult; // Create a plugin so we can create an interface pluginResult = IOCreatePlugInInterfaceForService(deviceObject, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &ppPluginInterface, &score); if (pluginResult == kIOReturnSuccess) { // Create the interface (HANDLE) interfaceResult = (*ppPluginInterface)->QueryInterface(ppPluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void**)pHandle); if (interfaceResult == S_OK) { retVal = TRUE; } IODestroyPlugInInterface(ppPluginInterface); } return retVal; }
1
0
1.2k
Apr ’22
echo command missing some characters when sending to serial port
We are developing driver kit for usb to serial. we testing by connect two usb to serial devices together (rx of device 1 to tx of device 2 and vice versa). open two terminal windows one type echo "hello" > /dev/SerialDevice1 one type cat < /dev/SerialDevice2 on device 2 only receive "h" character. we capture by usb analyzer on device 1 and see that, the echo call to send out "hello" then it immediately call to HwResetFIFO causing the device 1 abort remaining characters. kern_return_t IMPL(NullDriver, HwResetFIFO) { &#9;&#9;uint8_t purgeMask = 0; &#9;&#9;if (tx) { &#9;&#9;&#9;&#9;purgeMask |= TX_CLR_MASK; &#9;&#9;} &#9;&#9;if (rx) { &#9;&#9;&#9;&#9;purgeMask |= RX_CLR_MASK; &#9;&#9;} &#9;&#9;return ivars->provider->DeviceRequest(USBmakeOutbmRequestType, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;CP210xRequests::PURGE, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;purgeMask, ivars->interfaceNumber, 0, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;nullptr, nullptr, 0); } what should we do in this case? in driver, should we wait for all characters in device 1 finish sending before calling purge command to clear all characters in device 1?
0
0
791
Jan ’21
Documentation for DriverKit Extension
Hi, I am developing a driver for a USBSerial device. I have the source code for this device based on your I/O Kit. Now, I have to port my old code to DriverKit. I found in Apple’s documentation that I have to use IOUserUSBSerial class to implement my driver. But currently, I can’t find any good documents or sample codes for USB2Serial DriverKit type. I found some documents from Apple website but they are very short and they don't have enough details for me to understand them. So can you provide me some documents or sample codes for it? Thanks.
1
0
933
Aug ’20