1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | int main(void) { while(1) { int module = 0xa0; for(module = 0xcb; module < 0xe0; module ++) { Write(module); } usleep(10000); } return 0; } void Write(int channel) { char s[300]; int num, fd; char path[50]; snprintf(path, sizeof path, "var/write/%x.rbx", channel & 0xff); fd = open(path, O_RDONLY | O_NDELAY); if ((num = read(fd, s, 300)) == -1) { perror("read"); remove(path); mknod(path, S_IFIFO | 0666, 0); } else { s[num] = '\0'; printf("%s", s); } if(num > 0) { printf("\n"); } } |