From: Jean T. <jt...@bo...> - 2004-11-08 20:19:56
|
Lone Star wrote : > > I"m writing a user-space program, and want to get notified when > device in range and out. After searching the archive, You read the archive ! I'm impressed ! > I wrote a small > test program, doing select+read on /dev/irnet: > > fd = open("/dev/irnet", O_RDONLY); > while(1) { > FD_ZERO(&rfds); > FD_SET(fd, &rfds); > retval = select(fd+1, &rfds, NULL, NULL, NULL); > > if(retval>0 && FD_ISSET(fd, &rfds)){ > len = read(fd, buf, 64); > if(len>=0) > printf("%d %s\n", len, buf); > } > } > > But it doesn"t work as expected. GDB told me that the select returned > immediately, with fd ready, but the following read never return. Yeah, I can see that. This bug only happens when you open the file descriptor and the discovery log is empty. I will have to think about how I could fix that, unfortunately this is not trivial. The reason I never saw it is because my /dev/irnet socket is non-blocking. That's a nice workaround for you ;-) > I put > my Palm in range, then both irdadump and /proc/net/irda/discovery told > me it has been discovered, but my test program didn"t read anything. IrNET filter discovery on the IrLAN bit, so your Palm won't show up. One workaround would be to replace the S_LAN in the code... Too bad... Jean |