Brian Edmond(deleted)
|
PPS notification group problem
|
Brian Edmond(deleted)
02/26/2016 2:48 PM
post115874
|
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
|
|
|