Hi,
I have problem with return value of devctl()
function. I do on server side in io_devctl()
function (if there is no error) msg->o.ret_val = 0x10;
on client side (retval = devctl()) and retval
should be equal to 0x10, but retval is always
equal to 0.
Here is sample code downloaded from your side.
It deosn’t work for me too.
Where is problem? Can you help me?
Thanks Ales
avich@retia.cz
/*server side */
int handle_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T
*ocb)
{
int nbytes, status, previous;
union {
data_t data;
int data32;
// … other devctl types you can receive
} *rx_data;
if ((status = iofunc_devctl_default(ctp, msg, ocb)) != _RESMGR_DEFAULT)
return(status);
status = nbytes = 0;
rx_data = _DEVCTL_DATA(msg->i);
switch (msg->i.dcmd) {
case MY_DEVCTL_SETGET:
printf(“S: SETGET (%x) w/ data %d \n”, msg->i.dcmd, rx_data->data.tx);
previous = global_value;
global_value = rx_data->data.tx;
rx_data->data.rx = previous;
nbytes = sizeof(rx_data->data.rx);
break;
default:
printf(“S: Huh?\n”);
return(ENOSYS);
}
/* Clear the return message … note we saved our data after this */
memset(&msg->o, 0, sizeof(msg->o));
/*
If you wanted to pass something different to the return
field of the devctl() you could do it through this member.
*/
msg->o.ret_val = 0x10;
// Indicate the number of bytes and return the message
msg->o.nbytes = nbytes;
return(_RESMGR_PTR(ctp, &msg->o, sizeof(msg->o) + nbytes));
}
/* client side */
typedef union _data {
int tx;
int rx;
} data_t;
#define MY_DEVCTL_SETGET __DIOTF(_DCMD_MISC, MY_CMD_CODE + 2, union _data)
ret = devctl(fd, MY_DEVCTL_SETGET, &data, sizeof(data), NULL);