USBのinterruptのread,writeに失敗すると、USBと通信をしなくなる問題を修正。
/var/idsをベースPATHにする。
DEVICE_TIMEOUTを調整
@@ -113,8 +113,8 @@ | ||
113 | 113 | (char *)wdata, |
114 | 114 | sizeof(wdata), |
115 | 115 | DEVICE_TIMEOUT) < 0) { |
116 | - fprintf(stderr, "failed in intterupt write. (%s)\n", usb_strerror()); | |
117 | - return; | |
116 | + fprintf(stderr, "failed in intterupt write. (%d: %s)\n", errno, usb_strerror()); | |
117 | + goto next; | |
118 | 118 | } |
119 | 119 | if (usb_interrupt_read( |
120 | 120 | sensor->dh, |
@@ -122,8 +122,8 @@ | ||
122 | 122 | (char *)rdata, |
123 | 123 | sizeof(rdata), |
124 | 124 | DEVICE_TIMEOUT) < 0) { |
125 | - fprintf(stderr, "failed in intterupt read. (%s)\n", usb_strerror()); | |
126 | - return; | |
125 | + fprintf(stderr, "failed in intterupt read. (%d: %s)\n", errno, usb_strerror()); | |
126 | + goto next; | |
127 | 127 | } |
128 | 128 | /* 取得した情報をチェック */ |
129 | 129 | if (rdata[4] == 0xff) { |
@@ -141,6 +141,7 @@ | ||
141 | 141 | sensor->detect_count = 0; |
142 | 142 | } |
143 | 143 | /* 次のポーリングイベントを登録 */ |
144 | +next: | |
144 | 145 | timer.tv_sec = 0; |
145 | 146 | timer.tv_usec = sensor->poll_interval; |
146 | 147 | evtimer_set(&sensor->poll_event, sensor_polling, sensor); |
@@ -21,8 +21,8 @@ | ||
21 | 21 | #ifndef ALERT_H |
22 | 22 | #define ALERT_H |
23 | 23 | |
24 | -#define DEFAULT_FIRST_ALERT_SCRIPT "./first_alert_script.sh" | |
25 | -#define DEFAULT_SECOND_ALERT_SCRIPT "./second_alert_script.sh" | |
24 | +#define DEFAULT_FIRST_ALERT_SCRIPT "/var/ids/first_alert_script.sh" | |
25 | +#define DEFAULT_SECOND_ALERT_SCRIPT "/var/ids/second_alert_script.sh" | |
26 | 26 | #define DEFAULT_CANCEL_WAIT_TIME 60 |
27 | 27 | |
28 | 28 | #define ALERT_STATUS_NO_ALERT 0 |
@@ -23,9 +23,9 @@ | ||
23 | 23 | |
24 | 24 | #define USB_VENDOR 0x04bb /* IODATA */ |
25 | 25 | #define USB_PRODUCT 0x0f04 /* SENSOR-HM/ECO */ |
26 | -#define DEVICE_TIMEOUT (5 * 1000) | |
26 | +#define DEVICE_TIMEOUT (10 * 1000) | |
27 | 27 | #define DEFAULT_POLL_INTERVAL 5000 |
28 | -#define DEFAULT_ALERT_THRESHOLD 12 | |
28 | +#define DEFAULT_ALERT_THRESHOLD 12 | |
29 | 29 | |
30 | 30 | struct sensor { |
31 | 31 | struct event poll_event; |
@@ -21,7 +21,7 @@ | ||
21 | 21 | #ifndef IDS_H |
22 | 22 | #define IDS_H |
23 | 23 | |
24 | -#define DEFAULT_CONFIG_FILE_PATH "./ids.conf" | |
24 | +#define DEFAULT_CONFIG_FILE_PATH "/var/ids/ids.conf" | |
25 | 25 | #define DEFAULT_PID_FILE_PATH "/var/run/ids.pid" |
26 | 26 | |
27 | 27 | struct ids { |