Hi All,
I have an issue for devctl function. My client application needs the some data from a driver. So i started to do some R&d on it. I have implemented my own custom devctl function and replaced in the resource manager.
But i am unable to get correct values passed from driver to application. Please help me out to understand more on devctl functionality.
Please have a look on my driver code.
int
custom_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb)
{
int nbytes=0, status=0;
typedef union devctl_msg
{
int tx; //Filled by client on send
int rx; //Filled by server on reply
char errorString[512];
} data_t;
union
{
data_t data;
int data32;
}*rx_data;
if ((status = iofunc_devctl_default(ctp, msg, ocb)) != _RESMGR_DEFAULT)
{
return(status);
}
/*
Note this assumes that you can fit the entire data portion of
the devctl into one message. */
rx_data = _DEVCTL_DATA(msg->i);
switch (msg->i.dcmd)
{
case DEVCTL_DSCGETERRORSTRING:
printf("\n DEVCTL_DSCGETERRORSTRING command came");
rx_data->data.rx = 10; // Testing data
strcpy(rx_data->data.errorString,"Some Error came");
nbytes = sizeof(rx_data->data.errorString);
// return data to the client
memset(&msg->o,0,sizeof(msg->o));
msg->o.nbytes = nbytes;
SETIOV (ctp -> iov, &msg -> o, sizeof (msg -> o) + nbytes);
return (_RESMGR_NPARTS (2));
break;
default:
printf ("command unknown \n" );
}
return( _RESMGR_PTR(ctp, &msg->o, sizeof(msg->o) + nbytes));
}
On application side, i am getting correct string under rx_data->data.errorString but rx_data->data.rx is coming as wrong value(15645345).
It would be better, if i get good link on devctl for passing data.