Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - return value from PPS file read() incorrect: (18 Items)
   
return value from PPS file read() incorrect  
When I read() from a PPS file, I expect the number of bytes read to be returned.  However, I'm receiving the number of 
bytes of the PPS file.  This is the case even when my buffer size is smaller than the PPS file.  This doesn't appear to 
be following the standard POSIX read() behavior.
Re: return value from PPS file read() incorrect  
Normally it works as you expect.  Can you post your code and the contents of the pps file?
Re: return value from PPS file read() incorrect  
Code:
int fd;
	int size_read;
	char buffer[8];
	/* Open a file for input */
	fd = open("/pps/ppsfile?wait", O_RDONLY | O_LARGEFILE, 0666);

	while (1) {
		size_read = read(fd, buffer, 5);
		printf("sizeread %d \n",size_read);
	}

	/* Close the file */
	close(fd);

PPS file:
@ppsfile
attr::01234

Execution results:
sizeread 21
Re: return value from PPS file read() incorrect  
The pps object may contain multiple attributes, so it always returns the attribute name in front of "::".  You would 
never get "01234" as you seem to be expecting.

For example...

@ppsfile
attr::01234
attr2::56789

Re: return value from PPS file read() incorrect  
Andy: you need to contact your official support channels and get an updated
pps server.

Btw, what is the output of use -i pps on your system?



On 11-06-14 2:09 PM, "Dennis Kellly" <community-noreply@qnx.com> wrote:

> The pps object may contain multiple attributes, so it always returns the
> attribute name in front of "::".  You would never get "01234" as you seem to
> be expecting.
> 
> For example...
> 
> @ppsfile
> attr::01234
> attr2::56789
> 
> 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86609
> 
> 

Re: return value from PPS file read() incorrect  
Here's the details (which Andy is testing with) for PPS:

# use -i pps
NAME=pps
DESCRIPTION=Persistent Publish Subscribe manager
DATE=2010/09/16-14:25:29-EDT
STATE=stable
HOST=mainbuild
USER=pspbuild
VERSION=650-2092
TAGID=3546

This is delivered with the BSP provided to us by QNX for our project.

Can Victor M. or Alain provide us with something newer that provides different results?

Glenn
Re: return value from PPS file read() incorrect  
For clarity, the correct result per the spec is to get -1 as the return
value from the call.

On my box your test program outputs:
sizeread -1 
sizeread -1 
sizeread -1 
sizeread -1 
sizeread -1 
sizeread -1
 ...

My build is:
# use -i pps
NAME=pps
DESCRIPTION=Persistent Publish Subscribe manager
DATE=2011/05/27-14:20:13-EDT
STATE=internal
HOST=gusbuild5
USER=builder
VERSION=6.5.0
TAGID=1443


You likely have a priority support plan and this issue will get resolved
quickly if you raise a support ticket with your account manager.


On 11-06-14 2:28 PM, "Glenn Schmottlach" <community-noreply@qnx.com> wrote:

> Here's the details (which Andy is testing with) for PPS:
> 
> # use -i pps
> NAME=pps
> DESCRIPTION=Persistent Publish Subscribe manager
> DATE=2010/09/16-14:25:29-EDT
> STATE=stable
> HOST=mainbuild
> USER=pspbuild
> VERSION=650-2092
> TAGID=3546
> 
> This is delivered with the BSP provided to us by QNX for our project.
> 
> Can Victor M. or Alain provide us with something newer that provides different
> results?
> 
> Glenn
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86614
> 
> 

Re: return value from PPS file read() incorrect  
Default 6.5 has the bug described below, new one does not, but I don't think we have a patch for this publically 
available.

On 06/14/2011 02:38 PM, Mate Szarvas wrote:
> For clarity, the correct result per the spec is to get -1 as the return
> value from the call.
> 
> On my box your test program outputs:
> sizeread -1 
> sizeread -1 
> sizeread -1 
> sizeread -1 
> sizeread -1 
> sizeread -1
>  ...
> 
> My build is:
> # use -i pps
> NAME=pps
> DESCRIPTION=Persistent Publish Subscribe manager
> DATE=2011/05/27-14:20:13-EDT
> STATE=internal
> HOST=gusbuild5
> USER=builder
> VERSION=6.5.0
> TAGID=1443
> 
> 
> You likely have a priority support plan and this issue will get resolved
> quickly if you raise a support ticket with your account manager.
> 
> 
> On 11-06-14 2:28 PM, "Glenn Schmottlach" <community-noreply@qnx.com> wrote:
> 
>> Here's the details (which Andy is testing with) for PPS:
>>
>> # use -i pps
>> NAME=pps
>> DESCRIPTION=Persistent Publish Subscribe manager
>> DATE=2010/09/16-14:25:29-EDT
>> STATE=stable
>> HOST=mainbuild
>> USER=pspbuild
>> VERSION=650-2092
>> TAGID=3546
>>
>> This is delivered with the BSP provided to us by QNX for our project.
>>
>> Can Victor M. or Alain provide us with something newer that provides different
>> results?
>>
>> Glenn
>>
>>
>>
>> _______________________________________________
>>
>> OSTech
>> http://community.qnx.com/sf/go/post86614
>>
>>
> 
> 
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86615
> 
RE: return value from PPS file read() incorrect  
That's true: HEAD has a lot of fixes and changes not in 6.5 (although the documentation hasn't caught up yet).

________________________________

From: Elena Laskavaia [mailto:community-noreply@qnx.com]
Sent: Tue 2011-06-14 14:49
To: ostech-core_os
Subject: Re: return value from PPS file read() incorrect



Default 6.5 has the bug described below, new one does not, but I don't think we have a patch for this publically 
available.

On 06/14/2011 02:38 PM, Mate Szarvas wrote:
> For clarity, the correct result per the spec is to get -1 as the return
> value from the call.
>
> On my box your test program outputs:
> sizeread -1
> sizeread -1
> sizeread -1
> sizeread -1
> sizeread -1
> sizeread -1
>  ...
>
> My build is:
> # use -i pps
> NAME=pps
> DESCRIPTION=Persistent Publish Subscribe manager
> DATE=2011/05/27-14:20:13-EDT
> STATE=internal
> HOST=gusbuild5
> USER=builder
> VERSION=6.5.0
> TAGID=1443
>
>
> You likely have a priority support plan and this issue will get resolved
> quickly if you raise a support ticket with your account manager.
>
>
> On 11-06-14 2:28 PM, "Glenn Schmottlach" <community-noreply@qnx.com> wrote:
>
>> Here's the details (which Andy is testing with) for PPS:
>>
>> # use -i pps
>> NAME=pps
>> DESCRIPTION=Persistent Publish Subscribe manager
>> DATE=2010/09/16-14:25:29-EDT
>> STATE=stable
>> HOST=mainbuild
>> USER=pspbuild
>> VERSION=650-2092
>> TAGID=3546
>>
>> This is delivered with the BSP provided to us by QNX for our project.
>>
>> Can Victor M. or Alain provide us with something newer that provides different
>> results?
>>
>> Glenn
>>
>>
>>
>> _______________________________________________
>>
>> OSTech
>> http://community.qnx.com/sf/go/post86614
>>
>>
>
>
>
>
>
> _______________________________________________
>
> OSTech
> http://community.qnx.com/sf/go/post86615
>



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post86618



Re: return value from PPS file read() incorrect  
Seems to be a poor practice for co-opting traditional POSIX read semantics for use with PPS. Seems like you'd be better 
off providing a completely separate API instead of muddling with 'read' in this manner - in my opinion.

It would seem we have a bit of a Catch-22 situation here. If I don't know how large of a PPS buffer I may be reading, I 
don't know how large a buffer I should be allocating for the read. Is there is some mechanism in PPS that will allow me 
to determine the element size prior to the read? I don't want to pre-allocate a 64KB chunk of RAM just for reading an 
arbitrary PPS item (assuming 64KB is the maximum size chunk returned by PPS).

Recommendations???
Re: return value from PPS file read() incorrect  
recommendation:

long_pps_size = pathconf(PPS_PATH, _PC_REC_MAX_XFER_SIZE );


On 11-06-14 2:19 PM, "Glenn Schmottlach" <community-noreply@qnx.com> wrote:

> Seems to be a poor practice for co-opting traditional POSIX read semantics for
> use with PPS. Seems like you'd be better off providing a completely separate
> API instead of muddling with 'read' in this manner - in my opinion.
> 
> It would seem we have a bit of a Catch-22 situation here. If I don't know how
> large of a PPS buffer I may be reading, I don't know how large a buffer I
> should be allocating for the read. Is there is some mechanism in PPS that will
> allow me to determine the element size prior to the read? I don't want to
> pre-allocate a 64KB chunk of RAM just for reading an arbitrary PPS item
> (assuming 64KB is the maximum size chunk returned by PPS).
> 
> Recommendations???
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86611
> 
> 

Re: return value from PPS file read() incorrect  
Which sounds like 64KB as documented in the PPS docs . . . yuck.

At least it's a system definition although my call to getconf on a QNX 6.5.0 command-line doesn't seem to recognize 
_PC_REC_MAX_XFER_SIZE. Is this something new?

# getconf _PC_REC_MAX_XFER_SIZE /pps/hmiplayer/asResources
getconf: Can't find _PC_REC_MAX_XFER_SIZE
RE: return value from PPS file read() incorrect  
It should always have been there; whether the getconf command line utility knows it or not, I'm not certain (and can't 
get at the source at the moment to check).
 
If you are certain that the object won't change while you are reading it, you can stat() it to get its current size.  If
 it can change, you have no choice but to assume worst case.  If you know a priori that the object in question has a 
domain specific maximum size, you aren't obliged to use the PPS max, but that is always safest.

________________________________

From: Glenn Schmottlach [mailto:community-noreply@qnx.com]
Sent: Tue 2011-06-14 15:55
To: ostech-core_os
Subject: Re: return value from PPS file read() incorrect



Which sounds like 64KB as documented in the PPS docs . . . yuck.

At least it's a system definition although my call to getconf on a QNX 6.5.0 command-line doesn't seem to recognize 
_PC_REC_MAX_XFER_SIZE. Is this something new?

# getconf _PC_REC_MAX_XFER_SIZE /pps/hmiplayer/asResources
getconf: Can't find _PC_REC_MAX_XFER_SIZE



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post86620



Re: return value from PPS file read() incorrect  
The pathconf() function is different from the sysconf() function and the
getconf utility.


On 11-06-14 3:55 PM, "Glenn Schmottlach" <community-noreply@qnx.com> wrote:

> Which sounds like 64KB as documented in the PPS docs . . . yuck.
> 
> At least it's a system definition although my call to getconf on a QNX 6.5.0
> command-line doesn't seem to recognize _PC_REC_MAX_XFER_SIZE. Is this
> something new?
> 
> # getconf _PC_REC_MAX_XFER_SIZE /pps/hmiplayer/asResources
> getconf: Can't find _PC_REC_MAX_XFER_SIZE
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86620
> 
> 

Re: return value from PPS file read() incorrect  
I think in the release it will be fixed to return error in this case - because buffer cannot be smaller.

On 06/14/2011 01:40 PM, Andy Naegle wrote:
> When I read() from a PPS file, I expect the number of bytes read to be returned.  However, I'm receiving the number of
 bytes of the PPS file.  This is the case even when my buffer size is smaller than the PPS file.  This doesn't appear to
 be following the standard POSIX read() behavior.
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86602
> 
Re: return value from PPS file read() incorrect  
According to this from p23 of the document, the read() is supposed to FAIL.

"A read returns the length of the data read, in bytes. If the allocated read buffer is too
small for the data being read in, the read fails."

Seems to say partial, successive reads are not allowed.
Re: return value from PPS file read() incorrect  
On Tue, 2011-06-14 at 13:51 -0400, Dennis Kellly wrote:
> Seems to say partial, successive reads are not allowed.

This is true -- a PPS object isn't quite a "normal" file, and it has
some special semantics.  One of these is that reads must be complete --
you can't retrieve parts of a message in separate read calls.
Re: return value from PPS file read() incorrect  
What release are you referring to?