Re: Write/Read Bulk communication process in KEXT. How?
Re: Write/Read Bulk communication process in KEXT. How?
- Subject: Re: Write/Read Bulk communication process in KEXT. How?
- From: Chinki <email@hidden>
- Date: Thu, 25 May 2006 09:32:26 +0530
Dear all,
It seems there is some confusion going around, let me explain my problem in deatail(and its a quite simple one!)
-> " JUST want to read / write data from my USB BULK DEVICE."
I have a user application , i.e. myUserApp that communicates to my KEXT, myKEXT.kext
I send command request from "user space" to my KEXT which further needs to communicates with the USB BULK device and returns back the response data back to user.
As per the documentation given at Apple website about IOMemoryDescriptors, I have been finally able to communicate with the device!!!, BUT NEED YOUR EXPERT ADVICE if it is the CORRECT way of doing this.
Step1. Sending data from User level to Kernel level:
My user application and the user client of the KEXT agree on common index and data-structure.
i.e. enum{
kmyFirstCommand,
kmyCommandCounts
}
typedef structP{
mycommandpkt,
myresponsepkt.
}
Step2. I get the data at kernel level using the documented functionality
i.e. through getTargetandMethodForIndex
Step3. I open the device interface and the INPIPE and OUTPIPE ( there are three pipes in my USB Bulk device, default, IN and OUT)
Step4. Communicating with the KEY [ MAIN PART OF OUR DISCUSSION]
a) I get the structure (got from user level) and Allocate the memory using IOMemoryDescriptor in my communication module (kext)
i.e,
// assign for OUT pipe
IOMemoryDescriptor *memDescOut = NULL;
// assign for IN pipe
IOMemoryDescriptor *memDescIN = NULL;
// Now create and initialize an IOMemoryDescriptor for memory FOR WRITE
memDescOut = IOMemoryDescriptor::withAddress( (void*)&myOutStructure, sizeof(MY_OUTSTRUCTURE), kDirectionOUT)
// check for validation of memDescOut
// Fill myOutStructure
// Do write operation with the allocated outpipe
status = (pdx->fOUTPipe)->Write( memDescOut, (UInt32)1000, (UInt32)2000, size, NULL);
// Similarly for IN structure
// Now create and initialize an IOMemoryDescriptor for memory FOR READ
memDescIN = IOMemoryDescriptor::withAddress( (void*)&myINStructure, sizeof(MY_OUTSTRUCTURE), kDirectionOUT)
// check for validation of memDescIn
// Fill myOutStructure
// Do write operation with the allocated outpipe
status = (pdx->fINPipe)->Read( memDescIN , (UInt32)1000, (UInt32)2000, size, NULL, &gotsize);
// finally free the memory descriptor
memDescOut = NULL;
memDescIN = NULL;
///////////////////////////////////////
I have been able to succesfully pass the data to the key and get the response from the key . BUT I AM NOT SURE IF IT THE CORRECT way of doing it.
Please guide me, and require a lot of advices/ suggestions from all the experts present our this group,
'
Sincerely yours,
CHINKI
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden