Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - problem in transfering data between application and driver: (7 Items)
   
problem in transfering data between application and driver  
Hi,

I am working on WLAN driver which follows io-net framework. I have an application, which looks as follows:


struct mystruct{
int count;
char *data;
};
uint8_t buf[SCAN_MAX_DATA];

struct mystruct var;
var.data = buf;

and i am calling devctl as follows.

if(devctl(fd,cmd,&var,sizeof(var),NULL) >= 0)
 {
}


I am filling up this data( var. data which is pointing to buf in application) in my driver. But in my appliction when i 
read the buffer i am not able get the data which is filled by the driver.
My doubt is as both application and driver runs as separate processes, the buf from the application is not being copied 
to derivers process space. 
How do i get the correct datain application which is modified by my driver?

Please let me know.


Thanks & Regards
-------------------------------------------------------
 
Arun L Hegde

Re: problem in transfering data between application and driver  
On Thu, Mar 20, 2008 at 12:03:37PM -0400, Arun Hegde wrote:
> Hi,
> 
> I am working on WLAN driver which follows io-net framework. I have an application, which looks as follows:
> 
> 
> struct mystruct{
> int count;
> char *data;
> };
> uint8_t buf[SCAN_MAX_DATA];
> 
> struct mystruct var;
> var.data = buf;
> 
> and i am calling devctl as follows.
> 
> if(devctl(fd,cmd,&var,sizeof(var),NULL) >= 0)
>  {
> }
> 
> 
> I am filling up this data( var. data which is pointing to buf in application) in my driver. But in my appliction when 
i read the buffer i am not able get the data which is filled by the driver.
> My doubt is as both application and driver runs as separate processes, the buf from the application is not being 
copied to derivers process space. 
> How do i get the correct datain application which is modified by my driver?

That's the problem exactly.  You can't pass pointers
between processes (io-net isn't a monolithic kernel).
Change mystruct to:

struct mystruct{
int count;
char data[SCAN_MAX_DATA];
};

-seanb
Re: problem in transfering data between application and driver  
Thank you Sean. 
But passing a buffer itself, is a good practise in RTOS?
Do we have anything similar to Copytouser(), Copyfromyser() which is in linux?

Regards
Arun Hegde
Re: problem in transfering data between application and driver  
Hi Sean,

I tried by creating a buffer in the structure itself. But still i am facing the same problem. when i print the size 
passed to driver, it is same at both application and driver. And i am getting the correct size  which is size of buffer 
and int.

what else could be the problem?

Thanks and Regards
Arun Hegde
Re: problem in transfering data between application and driver  
On Fri, Mar 21, 2008 at 08:42:13AM -0400, Arun Hegde wrote:
> Hi Sean,
> 
> I tried by creating a buffer in the structure itself. But still i am facing the same problem. when i print the size 
passed to driver, it is same at both application and driver. And i am getting the correct size  which is size of buffer 
and int.
> 
> what else could be the problem?
> 

Do you get any of it?  Is the entire size of the struct
embedded in the cmd parameter properly? ioctl() boils
down to:

_devctl(fd, cmd, data, IOCPARM_LEN((unsigned)cmd), _DEVCTL_FLAG_NOTTY));
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^

Make sure this is correct or use devctl directly and pass the len.


-seanb
Re: problem in transfering data between application and driver  
On Thu, Mar 20, 2008 at 11:45:14PM -0400, Arun Hegde wrote:
> Thank you Sean. 
> But passing a buffer itself, is a good practise in RTOS?

Sure.

> Do we have anything similar to Copytouser(), Copyfromyser() which is in linux?

The closest is MsgRead(), MsgReadv() but the data has to be
explicitly sent via MsgSend() on the client side (can't
MsgRead() on a pointer).

-seanb
Re: problem in transfering data between application and driver  
Thanks for your reply sean. 
I got it working.

thanks & regards
Arun Hegde