- // timout has expired...
- write(pipefd, "sample temp0", 12);
- char c = '\n';
- write(pipefd, &c, 1);
+ int i;
+ for(i = 0; i < device_num; i++) {
+ devices[i].cnt_++;
+ if(devices[i].cnt_ >= devices[i].delay_) {
+ if(sample_enabled) {
+ log_printf(DEBUG, "autosample send sample command for '%s'", devices[i].device_name_);
+ send_sample_cmd(writefd, devices[i].device_name_);
+ }
+ devices[i].cnt_ = 0;
+ }
+ }
+ }
+
+ if(FD_ISSET(readfd, &tmpfds)) {
+ int ret;
+ do {
+ ret = read(readfd, &sample_enabled, 1);
+ } while(!ret || (ret == -1 && errno == EINTR));
+ log_printf(NOTICE, "autosample %s", sample_enabled == 0 ? "disabled" : "enabled");