new to QNX and c but reading your code you are anding with &0x3 woudl it
not be && instead of one &, Now I’m only learning so hopefully this isn’t
the completely wrong ie does one & mean hex and two not mean and I would
look at this, what is the value of msg->connect.ioflag
I think you are adding them together therefore your condition matches
add this line and test it
if(open_mode==O_RDWR)printf(“O_RDWR\n”);
new to QNX and c but reading your code you are anding with &0x3 woudl it
not be && instead of one &, Now I’m only learning so hopefully this isn’t
the completely wrong ie does one & mean hex and two not mean and I would
look at this, what is the value of msg->connect.ioflag
I think you are adding them together therefore your condition matches
add this line and test it
if(open_mode==O_RDWR)printf(“O_RDWR\n”);
“Martin Nylund” <> mnylund@emtrion.de> > wrote in message
news:cl8ek8$rfv$> 1@inn.qnx.com> …
What’s the correct way to map/handle/interpret the
O_* (O_RDONLY, O_RDWR …) in the _io_connect of the
io_open call at resource manager side?
Here’s my problem:
If I open my device with open() call:
fildes=open(device,O_RDONLY);
My resource manager io_open belowe prints “O_WRONLY”
int my_io_open (resmgr_context_t *ctp, io_open_t *msg, IOFUNC_ATTR_T
*mbox,
void *extra)
{
int mask=0,val=0,reg=0;
int open_mode=0;
What’s the correct way to map/handle/interpret the
O_* (O_RDONLY, O_RDWR …) in the _io_connect of the
io_open call at resource manager side?
Of course I could assume that mode in ioflag is mode in fcntl + 1…
This is indeed what happens. msg->connect.ioflag value has + 1 so
to convert the modes to a bitmask (see <sys/iomsg.h> and the
_IO_FLAG_RD and _IO_FLAG_WR manifests), which allows for write
access to be checked with “if (msg->connect.ioflag & _IO_FLAG_WR)”
rather than (O_WRONLY || O_RDWR). So, do not use the <fcntl.h>
values from within an IO manager, use the IO_FLAG* bit masks.
int my_io_open (resmgr_context_t *ctp, io_open_t *msg, IOFUNC_ATTR_T *mbox,
void *extra)
{
int mask=0,val=0;
int open_mode=0;
open_mode=msg->connect.ioflag&_IO_FLAG_MASK;
printf("opening for ");
if(open_mode&(_IO_FLAG_RD|_IO_FLAG_RD))printf(“reading and writing…”);
else if(open_mode&_IO_FLAG_RD)printf(“reading…”);
else if(open_mode&_IO_FLAG_WR)printf(“writing…”);
…
…
…
The documentation for _io_connect could be a bit more clear about this. It
simply states:
ioflag
One of:
a… O_RDONLY – open for reading only.
b… O_RDWR – open for reading and writing. Opening a FIFO for read-write
is unsupported.
c… O_WRONLY – open for writing only.
Martin Nylund wrote:
What’s the correct way to map/handle/interpret the
O_* (O_RDONLY, O_RDWR …) in the _io_connect of the
io_open call at resource manager side?
Of course I could assume that mode in ioflag is mode in fcntl + 1…
This is indeed what happens. msg->connect.ioflag value has + 1 so
to convert the modes to a bitmask (see <sys/iomsg.h> and the
_IO_FLAG_RD and _IO_FLAG_WR manifests), which allows for write
access to be checked with “if (msg->connect.ioflag & _IO_FLAG_WR)”
rather than (O_WRONLY || O_RDWR). So, do not use the <fcntl.h
values from within an IO manager, use the IO_FLAG* bit masks.
int my_io_open (resmgr_context_t *ctp, io_open_t *msg, IOFUNC_ATTR_T
*mbox, void *extra)
{
int mask=0,val=0;
int open_mode=0;
open_mode=msg->connect.ioflag&_IO_FLAG_MASK;
printf("opening for ");
if(open_mode&(_IO_FLAG_RD|_IO_FLAG_RD))printf(“reading and
writing…”);
else if(open_mode&_IO_FLAG_RD)printf(“reading…”);
else if(open_mode&_IO_FLAG_WR)printf(“writing…”);
.
.
.
The documentation for _io_connect could be a bit more clear about this. It
simply states:
ioflag
One of:
a… O_RDONLY – open for reading only.
b… O_RDWR – open for reading and writing. Opening a FIFO for read-write
is unsupported.
c… O_WRONLY – open for writing only.
“John Garvey” <> jgarvey@qnx.com> > schrieb im Newsbeitrag
news:cl8uoq$a97$> 1@inn.qnx.com> …
Martin Nylund wrote:
What’s the correct way to map/handle/interpret the
O_* (O_RDONLY, O_RDWR …) in the _io_connect of the
io_open call at resource manager side?
Of course I could assume that mode in ioflag is mode in fcntl + 1…
This is indeed what happens. msg->connect.ioflag value has + 1 so
to convert the modes to a bitmask (see <sys/iomsg.h> and the
_IO_FLAG_RD and _IO_FLAG_WR manifests), which allows for write
access to be checked with “if (msg->connect.ioflag & _IO_FLAG_WR)”
rather than (O_WRONLY || O_RDWR). So, do not use the <fcntl.h
values from within an IO manager, use the IO_FLAG* bit masks.