Chris Rose <chris.rose@viasat.com> wrote:
In the atoz.c example, I don’t understand what you’re doing here.
“return (iofunc_open_default (ctp, msg, atoz_attrs + msg → connect.path
[0] - ‘a’, extra));”
specifically, what is (msg, atoz_attrs + msg → connect.path [0] - ‘a’)
doing?
It’s a “clever” hack
atoz_attrs[] is an array of attribute structures.
Each element of the atoz_attrs[] represents one “file” on the virtual filesystem.
Thus, the line could be rewritten as:
(msg, &atoz_attrs [msg → connect.path [0] - ‘a’])
which really means, “the attribute structure associated with the
file given by the first letter of the pathname (which will be the character
‘a’ through ‘z’) minus the letter ‘a’ (so it now goes from 0 … 26)”
Effectively, I’m binding the appropriate attributes structure to the OCB.
“Appropriate” in this case meaning one of the 26 attributes structures.
Why are we binding the attributes structure to the OCB? So that we can
answer your next question…
Also, once I haved returned a file descriptor for that channel of the
multi-io card back to the client. How does the resource manager know for
later read/write calls what channel that file descriptor is associated with.
ocb → attr
Since we bound the correct attribute structure in the io_open() call, we now
have it available for all further I/O messages, like read, write, etc.
By examining which attribute structure “ocb → attr” points to, you now know
which device that I/O message refers to.
So, in your case, you’d use the “2” after your mountpoint (the “/dev/mydevices/multiportdevice/”)
part as an index into your attribute structures, and then bind that to the OCB
using the helper routine “iofunc_open_default()” to do the actual binding for you.
Don’t forget that you can extend the attributes structure so that it contains additional
information that’s relevant to your device, e.g., serial baud rate, number of stop bits,
whatever you like…
Clear as mud? Don’t be shy about asking for more clarification…
Cheers,
-RK
“Robert Krten” <> nospam91@parse.com> > wrote in message
news:a39dip$hba$> 1@inn.qnx.com> …
Chris Rose <> chris.rose@viasat.com> > wrote:
I’m experimenting with my first resource manager. I want to make calls
to
the resmgr like this.
fd=open("/dev/mydevices/muliportdevice/2",O_WRONLY);
I’ve registered it and allowed it to handle everything below the
mountpoint
/dev/mydevices/multiportdevice
My question is how to I find the rest of the path i.e. “/2”?
What data structure is it in?
In your io_open(), it will be in the “path” member…
Look on > www.parse.com > in the book section under “download”, there’s a .tar
file that has the examples from my book. One of them is the “atoz”
directory
resource manager, which should give you some hints…
Cheers,
-RK
–
Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at > www.parse.com> .
Email my initials at parse dot com.
–
Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.