Reading address from the command line in Resource Manager

I have spent quite a bit of time trying to get my requirements to work but no success until now.

My requirement:

I have a resource manager which basically reads and writes data to registers specified by the client process.
But I want to make this work from the command line. The users should be able to specify the address offset from the shell and the io_read() should be able to read that offset and call specific driver function and return the corresponding data.

My problem is I don’t see the address I specified in any of the
int[color io_read (resmgr_context_t *ctp, io_read_t *msg, RESMGR_OCB_T *ocb)

parameters in the above function. I realize io_read() is not designed to take input from the user.

Is there anyway I can modify this function or any other function to take the address offset from the command line and return the corresponding data from that register.
Any pointers on this are greatly appreciated.

Thanks in advance.

I can suggest a way to do this, but it might not be what you want.

Build your resource manager so that it does I/O calls through the ioctl interface. This leaves read and write available for anything else.
In the read_io() function look for a numeric string.
Convert the string to the port address you want to read address.
Read the I/O port, convert the result to text and put the text in the write buffer.

Now you can read an I/O port from the command line using an appropriate utility, for example cat.

An alternative would be to just write a simple utility that uses the resource manager to get the information.

Thanks maschoen.

I am using io_devctl() function for reading/writing to registers in my program. That part is OK.

I was trying to make use of io_read() from the command line.
I was trying to avoid writing a separate application to read from the registers for the above requirement .
I was thinking one of the main advantage of going with resource manager is we can read/write to the device from the command line without the need to go with separate program.

Coming to your comments,

"In the read_io() function look for a numeric string. "
Which parameter in io_read() contains this input string. I couldn’t find my string in any of the parameters?



I said it backwards.   It's in the io_write() (The client writing) that you look for the numeric string.    Here's how you do it.

int io_write (…)
iov_t iov;

SETIOV(&iov, inbuf, sizeof(inbuf));
resmgr_msgreadv(ctp, &iov, 1,sizeof(msg->i));

/* Now inbuf has the string */
value = in8(ath(inbuf));
sprintf(outbuf,"%02x\n", value);
outbuf_bytes = strlen(outbuf) + 1;


Check out: … 307_2.html