Resource Manager io_devctl() question

Hi,

I am very new to this QNX resource manager stuff. I was trying out some simple code after going through the docuemts for several days and was convinced that I got a hang of it until I wrote my first piece of code.
I am facing a problem wherein my client program sends some info the server and the server doesn’t see that data at all. I am not sure where I am going wrong? Do I have to allocate any memory on the server side at all before receiving my message ? Any kind of useful pointers is greatly appreciated.

Thanks.

Here is my code snippet.
Client side:

typedef struct {
FPGA_CMD_E fpgaCmd_e;
unsigned int addr;
unsigned int data;
unsigned int numWords;
char buf[1024];
}FpgaCmd_ST;

int main(int argc, char **argv) {
int fd, ret, val, len = 0;

FpgaCmd_ST fpgaCmds_st;


printf("\r\nDevice name is %s", FPGA_DEVICE_NAME);
if ((fd = open("/dev/fpgaDev", O_RDONLY)) == -1) {
        return(1);
}

if (fd == -1) {
    printf( " Unable to open the device\n");
    exit(EXIT_FAILURE);
}

printf("\r\nFileDescriptor is %d", fd);

fpgaCmds_st.fpgaCmd_e = FPGA_READ;
fpgaCmds_st.addr = 0x100;

//send this info to server to read the data stored at this addr…

ret = devctl(fd, FPGA_READ, &fpgaCmds_st, sizeof(fpgaCmds_st), NULL);
printf("FPGA_READ returned addr: %08x and data: %08x\n", fpgaCmds_st.addr, fpgaCmds_st.data);

======================

Server side:

==============
FpgaCmd_ST fpgaCmd_st;

int io_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb)
{
int nbytes, status, previous;

if ((status = iofunc_devctl_default(ctp, msg, ocb)) != _RESMGR_DEFAULT) {
    return(status);
}
status = nbytes = 0;

int bytesRead = resmgr_msgread(ctp, &fpgaCmd_st, sizeof(fpgaCmd_st), sizeof(msg->i));


/* Print some useful information about the message */
printf( "\n\nServer Got Message:\n" );
printf( "  addr: %08x\n" , fpgaCmd_st.addr);
printf( "  data: %08x\n\n", fpgaCmd_st.data );

At this stage I dont see the data I sent… everything is set to 0.???

switch (msg->i.dcmd) {
   case FPGA_READ:
   printf("\r\nFPGA reg to be read");
   break;

case FPGA_WRITE:
    printf("\r\nFPGA reg to be written");
    break;

case FPGA_PROGRAM:
    printf("\r\nFPGA  to be programmed");
    break;

default:
    return(ENOSYS);
}

====================

I think I know where the problem is. The call to devctl is tricky. The devctl command includes some bits that indicate whether the call has data in, data out, neither or both. There are some macros that assist in this. You don’t seem to be
Here a cut from some docs:

Use these macros to set up the device-control commands:

__DIOF(class, cmd, data)
Get information from the device.
__DION(class, cmd)
A command with no associated data.
__DIOT(class, cmd, data)
Pass information to the device.
__DIOTF(class, cmd, data)
Pass some information to the device, and get some from it.

Take a look here : qnx.com/developers/docs/6.3. … l#Commands
for more info on this.

Thanks maschoen ,

Thats exactly my problem was. Once I used those macros, I started seeing the data.

Cheers,