Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - PPS notification group problem: (2 Items)
   
PPS notification group problem  
I have tried using a PPS notification group and they do not seem to work as expected.  I created the following file:

/pps/crank/test

Then use this code:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/pps.h>

int main()
{
    char noid[16], buf[256];
    int notify_fd, fd1;
    int nread;

    notify_fd = open("/pps/.notify", O_RDONLY);
    read(notify_fd, &noid[0], sizeof(noid));
    noid[strlen(noid)-1] = 0;
    printf("Open Notify fd: <%s>\n", noid);

    sprintf(buf, "/pps/crank/test?notify=%s:id", noid);
    fd1 = open(buf, O_RDONLY);
    printf("Open: %s\n", buf);

    memset(buf, 0, sizeof(buf));
    while((nread=read(notify_fd, &buf, sizeof(buf))) >= 0) {
        if (nread) {
            printf("Notify (%d): %s\n", nread, buf);
        }       
        memset(buf, 0, sizeof(buf));
    }   
    printf("Done: %d\n", nread);
    return 0;
}

So a notification group is used to monitor the "id" attribute of the test object.  Then I write to the object:
    echo "id::1" >> /pps/crank/test
Now I see the above "Notify" message as I expect.
Now write to the object again but with a different attribute:
  echo "abc::1" >> /pps/crank/test
Now I still see the above "Notify" message.  However I did not change the "id" value so why does read return like I did?


Thanks,
Brian
Re: PPS notification group problem  
..notify is not for selecting attributes to be notified about, it is as an
alternative for ionotify/poll/select, i.e. as a means of discovering which
of several fds have data available. When you open a pps object using
notify=nnn:mmm  the nnn part is for pps to determine which fd it should
notify and mmm is for the client to know which fd it is being notified
about.  I don¹t know that there is any reason to use .notify any longer, I
think it is there for purely historical reasons.

If you only want to get the Œid' attribute from a pps object, you¹d open:

   /pps/crank/test?f=id

f = filter.  I don¹t recall if you can filter more than one attribute.


On 2016-02-26, 2:48 PM, "Brian Edmond" <community-noreply@qnx.com> wrote:

>I have tried using a PPS notification group and they do not seem to work
>as expected.  I created the following file:
>
>/pps/crank/test
>
>Then use this code:
>
>#include <stdlib.h>
>#include <stdio.h>
>#include <string.h>
>#include <fcntl.h>
>#include <sys/pps.h>
>
>int main()
>{
>    char noid[16], buf[256];
>    int notify_fd, fd1;
>    int nread;
>
>    notify_fd = open("/pps/.notify", O_RDONLY);
>    read(notify_fd, &noid[0], sizeof(noid));
>    noid[strlen(noid)-1] = 0;
>    printf("Open Notify fd: <%s>\n", noid);
>
>    sprintf(buf, "/pps/crank/test?notify=%s:id", noid);
>    fd1 = open(buf, O_RDONLY);
>    printf("Open: %s\n", buf);
>
>    memset(buf, 0, sizeof(buf));
>    while((nread=read(notify_fd, &buf, sizeof(buf))) >= 0) {
>        if (nread) {
>            printf("Notify (%d): %s\n", nread, buf);
>        }       
>        memset(buf, 0, sizeof(buf));
>    }   
>    printf("Done: %d\n", nread);
>    return 0;
>}
>
>So a notification group is used to monitor the "id" attribute of the test
>object.  Then I write to the object:
>    echo "id::1" >> /pps/crank/test
>Now I see the above "Notify" message as I expect.
>Now write to the object again but with a different attribute:
>  echo "abc::1" >> /pps/crank/test
>Now I still see the above "Notify" message.  However I did not change the
>"id" value so why does read return like I did?
>
>Thanks,
>Brian
>
>
>
>_______________________________________________
>
>QNX Momentics Community Support
>http://community.qnx.com/sf/go/post115874
>To cancel your subscription to this discussion, please e-mail
>momentics-community-unsubscribe@community.qnx.com