Returning data from resmgr through devctl()...

Hi,

I working on a driver/resource manager and need to be able to return
some data to the client through devctl(). I have successfully been
able to send information to the driver with devctl() but I have not
been get anything back.

I’m using _DIOF() and have tried various things in the driver’s devctl
handler function but so far I haven’t been able to get anything back
to the client.

Does someone have a little example of how a resource manager returns
data to the client in devctl()? I’m interested in how to return data
into devctl()'s data parameter and how to return data into devctl()'s
info parameter.

Thanks,

Wayne


Wayne Fisher, Software Engineer | Focus Automation Systems Inc.
#include <std/disclaimer.h> | 101 Randall Drive
mailto:Wayne.Fisher@focusautomation.com | Waterloo, Ontario. N2V 1C5
http://www.focusautomation.com | (519)746-1100 Fax:(519)746-1170

Hi,

I’m still unable to figure out how to get data back to the client. I
haven’t been able to find anything to help me in the docs and my
experimentation hasn’t yielded the desired results either.

Wayne

Previously, Wayne Fisher wrote in qdn.public.qnxrtp.os:

Hi,

I working on a driver/resource manager and need to be able to return
some data to the client through devctl(). I have successfully been
able to send information to the driver with devctl() but I have not
been get anything back.

I’m using _DIOF() and have tried various things in the driver’s devctl
handler function but so far I haven’t been able to get anything back
to the client.

Does someone have a little example of how a resource manager returns
data to the client in devctl()? I’m interested in how to return data
into devctl()'s data parameter and how to return data into devctl()'s
info parameter.

Thanks,

Wayne


Wayne Fisher, Software Engineer | Focus Automation Systems Inc.
#include <std/disclaimer.h> | 101 Randall Drive
mailto:Wayne.Fisher@focusautomation.com | Waterloo, Ontario. N2V 1C5
http://www.focusautomation.com | (519)746-1100 Fax:(519)746-1170

Wayne Fisher <wayne@focus-systems.on.ca> wrote:

Hi,

I’m still unable to figure out how to get data back to the client. I
haven’t been able to find anything to help me in the docs and my
experimentation hasn’t yielded the desired results either.

I think the devctls have to be defined properly.

The devctls this code uses are:

#define DCMD_DEVTIME_SETFMT set_device_direction (0x3001, _POSIX_DEVDIR_TO)
#define DCMD_DEVTIME_GETFMT set_device_direction (0x3003, _POSIX_DEVDIR_FROM)

The code for io_devctl() looks something like:

int
io_devctl (resmgr_context_t *ctp, io_devctl_t *msg, Timeocb_t *tocb)
{
void *dptr;
int nbytes;
int device;
int status;

device = tocb->ocb.attr->device;

if (optv) {
printf ("%s: in io_devctl\n", progname);
}

if ((status = iofunc_devctl_default (ctp, msg, &tocb->ocb)) != _RESMGR_DEFAULT)
return (_RESMGR_ERRNO(status));

nbytes = 0;
dptr = _DEVCTL_DATA (msg → i);

switch (msg → i.dcmd) {
case DCMD_DEVTIME_SETFMT:
if (optv) {
printf ("%s: got SETFMT, format “%s”\n",
progname, (char *) dptr);
}
strcpy (tocb ->format, (char *) dptr);
break;
case DCMD_DEVTIME_GETFMT:
if (optv) {
printf ("%s: got GETFMT\n", progname);
}
strcpy ((char *) dptr, tocb → format);
nbytes = strlen (tocb → format) + 1;
break;
}

if (nbytes == 0) {
return (_RESMGR_ERRNO (EOK));
} else {
msg → o.ret_val = 0;
return (_RESMGR_PTR (ctp, &msg → o, sizeof (msg → o) + nbytes));
}
}

-David

David Gibbs <dagibbs@qnx.com> wrote:
: Wayne Fisher <wayne@focus-systems.on.ca> wrote:

:> Hi,

:> I’m still unable to figure out how to get data back to the client. I
:> haven’t been able to find anything to help me in the docs and my
:> experimentation hasn’t yielded the desired results either.

[Dave’s snippets on devctl removed]

You can also take a look a bit of an example that I
had put together. You can find it at:

http://staff.qnx.com/~thomasf/nto.html

I haven’t gone back to it in a while, but it should
demonstrate what you are looking for.

Thomas

Thomas (toe-mah) Fletcher QNX Software Systems
thomasf@qnx.com Neutrino Development Group
(613)-591-0931 http://www.qnx.com/~thomasf

Thanks. I’ve got it working now. I was using the SETIOV() macro,
etc. and didn’t have much luck with it.

However, I think that there may be a tiny bug in your code. See
below. The input and output structures are the currently the same
size so the code works fine as is.

Thanks again,

Wayne

Previously, David Gibbs wrote in qdn.public.qnxrtp.os:

Wayne Fisher <> wayne@focus-systems.on.ca> > wrote:

Hi,

I’m still unable to figure out how to get data back to the client. I
haven’t been able to find anything to help me in the docs and my
experimentation hasn’t yielded the desired results either.

I think the devctls have to be defined properly.

The devctls this code uses are:

#define DCMD_DEVTIME_SETFMT set_device_direction (0x3001, _POSIX_DEVDIR_TO)
#define DCMD_DEVTIME_GETFMT set_device_direction (0x3003, _POSIX_DEVDIR_FROM)

The code for io_devctl() looks something like:

int
io_devctl (resmgr_context_t *ctp, io_devctl_t *msg, Timeocb_t *tocb)
{
void *dptr;
int nbytes;
int device;
int status;

device = tocb->ocb.attr->device;

if (optv) {
printf ("%s: in io_devctl\n", progname);
}

if ((status = iofunc_devctl_default (ctp, msg, &tocb->ocb)) != _RESMGR_DEFAULT)
return (_RESMGR_ERRNO(status));

nbytes = 0;
dptr = _DEVCTL_DATA (msg → i);

switch (msg → i.dcmd) {
case DCMD_DEVTIME_SETFMT:
if (optv) {
printf ("%s: got SETFMT, format “%s”\n",
progname, (char *) dptr);
}
strcpy (tocb ->format, (char *) dptr);
break;
case DCMD_DEVTIME_GETFMT:
if (optv) {
printf ("%s: got GETFMT\n", progname);
}

dptr = _DEVCTL_DATA (msg → o);


strcpy ((char *) dptr, tocb → format);
nbytes = strlen (tocb → format) + 1;
break;
}

if (nbytes == 0) {
return (_RESMGR_ERRNO (EOK));
} else {
msg → o.ret_val = 0;
return (_RESMGR_PTR (ctp, &msg → o, sizeof (msg → o) + nbytes));
}
}

-David


Wayne Fisher, Software Engineer | Focus Automation Systems Inc.
#include <std/disclaimer.h> | 101 Randall Drive
mailto:Wayne.Fisher@focusautomation.com | Waterloo, Ontario. N2V 1C5
http://www.focusautomation.com | (519)746-1100 Fax:(519)746-1170

Wayne Fisher <wayne@focus-systems.on.ca> wrote:

Thanks. I’ve got it working now. I was using the SETIOV() macro,
etc. and didn’t have much luck with it.

However, I think that there may be a tiny bug in your code. See
below. The input and output structures are the currently the same
size so the code works fine as is.

It is my understanding that the _io_devctl and _io_devctl_reply
structures are always going to be the same size, so what I’m doing
is ok. (As in, the kernel people here at QSSL have said they
are guaranteed to be the same size.)

-David