Subclassing Serial Driver Kit (IOUserSerial)

I have a custom serial Device, I have made a driver using USB Serial Driver Kit by sub classing IOUserUSBSerail. Driver Works fine. However I don't have any Control over Read and Write Operations since its taken care by the USBSerialDriver Kit.

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



Hi ,
I am trying write driver for my device ,
Having similar issue, Can you suggest me how you solved this issue ?,

I have also tried subclassing IOUserUSBSerial,
  • Permission denied Error is coming

can you help me resolve this issue

detailed here :
https://developer.apple.com/forums/thread/676862

Any input is appriciated

Don't know if you have figured out the solution. I believe the size information is in the "IOBufferMemoryDescriptor *ifmd". This seems to be a descriptor for interface and the interface seems to describe a ring buffer structure. If you look at "struct SerialPortInterface" defined in "SerialPortInterface.h", you will see the producer index and consumer index defined there. I think every time TxDataAvailable() is called, the txPI will be increased by the size of the new data.

I have a different problem and I want to see if anyone can help me. I'm trying to create a virtual serial port driver using DriverKit. I have a basic implementation that subclassess IOUserSerial. I've got as far as to be able to have the serial port shown as sth like /dev/tty.serial-100000B5A. When using picocom to write to this virtual serial port, I can see TxDataAvailable() gets called and the size information is updated correctly in the ifmd. However, upon checking the content of the TX buffer, it's all zeros. I don't know how to debug as I can't think of anything I did wrong. Really appreciate it if anyone can provide any suggestion! Thanks!

Subclassing Serial Driver Kit (IOUserSerial)
 
 
Q