Skip navigation.
Home
The QNX Community Portal

View topic - Reading address from the command line in Resource Manager

Reading address from the command line in Resource Manager

Discussion about the QNX6 OS.

Reading address from the command line in Resource Manager

Postby newbie_learner » Mon May 13, 2013 2:07 pm

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 [b]from the command line[/b] and return the corresponding data from that register.
Any pointers on this are greatly appreciated.

Thanks in advance.
newbie_learner
Active Member
 
Posts: 18
Joined: Wed Mar 27, 2013 10:12 pm

Re: Reading address from the command line in Resource Manage

Postby maschoen » Mon May 13, 2013 4:53 pm

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.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Reading address from the command line in Resource Manage

Postby newbie_learner » Tue May 14, 2013 1:50 pm

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?


Thanks
newbie_learner
Active Member
 
Posts: 18
Joined: Wed Mar 27, 2013 10:12 pm

Re: Reading address from the command line in Resource Manage

Postby maschoen » Tue May 14, 2013 4:37 pm

Sorry,

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;

}
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Reading address from the command line in Resource Manage

Postby mario » Wed May 15, 2013 1:47 pm

mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am


Return to QNX6 - OS

Who is online

Users browsing this forum: Bing [Bot] and 1 guest