0

I'm using DriverKit in iPadOS.

I've got a call to read data synchronously, which is working fine.

So I'm trying to do the asynchronous one.

For this I'm calling IOConnectCallAsyncStructMethod with

ret = IOConnectCallAsyncStructMethod(connection, MessageType_AsyncReadRequest, callback_port, asynRequestRef, kIOAsyncCalloutCount, nullptr, 0, output, &outputSizeT);

Where:

arraySize = 248
uint64_t output[arraySize] = {}; 
size_t outputSizeT = sizeof(uint64_t) * arraySize;

When I got the data from the USB device, I return it with AsyncCompletion

With:

    uint64_t *read // This will contain the data from the device

    const uint32_t size = 32;
    
    uint64_t asyncData[size] = { };
    memcpy(asyncData, read, (sizeof(uint64_t) * size));


        AsyncCompletion(ivars->readSampleCallbackAction, kIOReturnSuccess, asyncData, size);
        ivars->readSampleCallbackAction->release();

My problem is when the call of IOConnectCallAsyncStructMethod returns. ret would be 0 as successful but output won't contain the data.

I know there is data in asyncData because if I inspect the variable in debug mode I can see the data I expect.

Any ideas?

Thanks

1 Answer 1

0

Ok, I had two problems here.

One the data is not returned in the output variable. The data is returned in the AsyncCallback method.

Also I think there is another problem in my call to asynccompletion

Because I'm passing an array of uint64_t of size 32, probably that's producing a problem because the maximum is 16 ( https://developer.apple.com/documentation/driverkit/3325601-arguments_array_maximum/kiouserclientasyncargumentscountmax )

https://developer.apple.com/documentation/driverkit/iouserclient/3325613-asynccompletion

If I change the size from const uint32_t size = 32; to const uint32_t size = 8;

I would get the call in AsyncCallback

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.