To overcome this problem I am trying to use Serial driver kit by subclassing the driver from IOUserSerial class.
https://developer.apple.com/documentation/serialdriverkit/iouserserial
As per the link above , we need to overload the function
TxDataAvailable
https://developer.apple.com/documentation/serialdriverkit/iouserserial/3433803-txdataavailable
My overloaded function is getting called whenever data is available from the application. (I got hold of the application buffer by overloading the ConnectQueues method)
For sending the data to USB I also need the size of the data.
From the Connect Queue method I have the IOBufferMemoryDescriptor.
The getLength method of IOMemoryDescriptor gives me the length of the full buffer which was allocated.
It does not give me the actual data length.
How can I get the data length in this case