diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/uoak.h | 8 | ||||
-rw-r--r-- | sys/dev/usb/uoak_subr.c | 61 | ||||
-rw-r--r-- | sys/dev/usb/uoaklux.c | 12 | ||||
-rw-r--r-- | sys/dev/usb/uoakrh.c | 22 | ||||
-rw-r--r-- | sys/dev/usb/uoakv.c | 37 |
5 files changed, 64 insertions, 76 deletions
diff --git a/sys/dev/usb/uoak.h b/sys/dev/usb/uoak.h index 615e11ab72a..0bc2ca9daff 100644 --- a/sys/dev/usb/uoak.h +++ b/sys/dev/usb/uoak.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uoak.h,v 1.1 2012/09/20 13:52:11 yuo Exp $ */ +/* $OpenBSD: uoak.h,v 1.2 2012/10/19 14:52:38 deraadt Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -29,7 +29,7 @@ /* OAK sensor command */ /* 1 byte commands */ #define OAK_CMD_REPORTMODE 0x0000 -#define OAK_REPORTMODE_AFTERSAMPING 0x0 /* default */ +#define OAK_REPORTMODE_AFTERSAMPLING 0x0 /* default */ #define OAK_REPORTMODE_AFTERCHANGE 0x1 #define OAK_REPORTMODE_FIXEDRATE 0x2 #define OAK_CMD_LEDMODE 0x0001 @@ -138,10 +138,10 @@ struct uoak_softc { struct uoak_sensor { - struct ksensor ave; + struct ksensor avg; struct ksensor max; struct ksensor min; - int64_t vave, vmax, vmin; + int64_t vavg, vmax, vmin; unsigned int count; }; diff --git a/sys/dev/usb/uoak_subr.c b/sys/dev/usb/uoak_subr.c index 7e4cc653157..8af2912911f 100644 --- a/sys/dev/usb/uoak_subr.c +++ b/sys/dev/usb/uoak_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoak_subr.c,v 1.1 2012/09/20 13:52:11 yuo Exp $ */ +/* $OpenBSD: uoak_subr.c,v 1.2 2012/10/19 14:52:38 deraadt Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -53,7 +53,7 @@ int uoak_check_device_ready(struct uoak_softc *sc) { if (uhidev_get_report(sc->sc_hdev, UHID_FEATURE_REPORT, - &sc->sc_buf, sc->sc_flen)) + &sc->sc_buf, sc->sc_flen)) return EIO; if (sc->sc_buf[0] != 0xff) @@ -71,7 +71,7 @@ uoak_set_cmd(struct uoak_softc *sc) usbd_delay_ms(sc->sc_udev, UOAK_RETRY_DELAY); if (uhidev_set_report(sc->sc_hdev, UHID_FEATURE_REPORT, - &sc->sc_rcmd, sc->sc_flen)) + &sc->sc_rcmd, sc->sc_flen)) return EIO; return 0; @@ -88,7 +88,7 @@ uoak_get_cmd(struct uoak_softc *sc) /* issue request */ if (uhidev_set_report(sc->sc_hdev, UHID_FEATURE_REPORT, - &sc->sc_rcmd, sc->sc_flen)) + &sc->sc_rcmd, sc->sc_flen)) return EIO; /* wait till the device ready to return the request */ @@ -115,7 +115,7 @@ uoak_get_device_name(struct uoak_softc *sc, enum uoak_target target) return EIO; strlcpy(sc->sc_config[target].devname, sc->sc_buf+1, - sizeof(sc->sc_config[target].devname)); + sizeof(sc->sc_config[target].devname)); return 0; } @@ -233,7 +233,7 @@ uoak_get_devinfo(struct uoak_softc *sc) void uoak_get_setting(struct uoak_softc *sc, enum uoak_target target) { - /* get device lavel */ + /* get device level */ (void)uoak_get_device_name(sc, target); /* get global sensor configuration */ @@ -249,36 +249,33 @@ uoak_get_setting(struct uoak_softc *sc, enum uoak_target target) void uoak_print_devinfo(struct uoak_softc *sc) { - printf(", serial#:%s", sc->sc_udi.udi_serial); - printf("\n"); + printf(": serial %s", sc->sc_udi.udi_serial); } void uoak_print_setting(struct uoak_softc *sc, enum uoak_target target) { - printf(" device label:%s", sc->sc_config[target].devname); - printf(", report mode:"); - switch(sc->sc_config[target].report_mode) { - case OAK_REPORTMODE_AFTERSAMPING: - printf("after sampling (rate:%d ms).", - sc->sc_config[target].sample_rate); + switch (sc->sc_config[target].report_mode) { + case OAK_REPORTMODE_AFTERSAMPLING: + printf(" sampling %dms", + sc->sc_config[target].sample_rate); break; case OAK_REPORTMODE_AFTERCHANGE: - printf("after change."); + printf(" reports changes"); break; case OAK_REPORTMODE_FIXEDRATE: - printf("fixed rate (rate:%d ms).", - sc->sc_config[target].report_rate); + printf(" rate %dms", + sc->sc_config[target].report_rate); break; default: - printf("unknown."); + printf(" unknown sampling"); break; } - printf("\n"); /* print device spcecific information */ if (sc->sc_methods->dev_print != NULL) sc->sc_methods->dev_print(sc->sc_parent, target); + printf("\n"); } void @@ -288,21 +285,21 @@ uoak_sensor_attach(struct uoak_softc *sc, struct uoak_sensor *s, if (s == NULL) return; - s->ave.type = type; + s->avg.type = type; s->max.type = type; s->min.type = type; - s->ave.flags |= SENSOR_FINVALID; + s->avg.flags |= SENSOR_FINVALID; s->max.flags |= SENSOR_FINVALID; s->min.flags |= SENSOR_FINVALID; - (void)snprintf(s->ave.desc, sizeof(s->ave.desc), - "ave(#%s)", sc->sc_udi.udi_serial); + (void)snprintf(s->avg.desc, sizeof(s->avg.desc), + "avg(#%s)", sc->sc_udi.udi_serial); (void)snprintf(s->max.desc, sizeof(s->max.desc), - "max(#%s)", sc->sc_udi.udi_serial); + "max(#%s)", sc->sc_udi.udi_serial); (void)snprintf(s->min.desc, sizeof(s->min.desc), - "min(#%s)", sc->sc_udi.udi_serial); + "min(#%s)", sc->sc_udi.udi_serial); - sensor_attach(sc->sc_sensordev, &s->ave); + sensor_attach(sc->sc_sensordev, &s->avg); sensor_attach(sc->sc_sensordev, &s->max); sensor_attach(sc->sc_sensordev, &s->min); } @@ -313,7 +310,7 @@ uoak_sensor_detach(struct uoak_softc *sc, struct uoak_sensor *s) if (s == NULL) return; - sensor_attach(sc->sc_sensordev, &s->ave); + sensor_attach(sc->sc_sensordev, &s->avg); sensor_attach(sc->sc_sensordev, &s->max); sensor_attach(sc->sc_sensordev, &s->min); } @@ -326,7 +323,7 @@ uoak_sensor_update(struct uoak_sensor *s, int val) /* reset */ if (s->count == 0) { - s->vmax = s->vmin = s->vave = val; + s->vmax = s->vmin = s->vavg = val; s->count++; return; } @@ -337,8 +334,8 @@ uoak_sensor_update(struct uoak_sensor *s, int val) else if (val < s->vmin) s->vmin = val; - /* calc avelage */ - s->vave = (s->vave * s->count + val) / (s->count + 1); + /* calc average */ + s->vavg = (s->vavg * s->count + val) / (s->count + 1); s->count++; } @@ -349,12 +346,12 @@ uoak_sensor_refresh(struct uoak_sensor *s, int mag, int offset) if (s == NULL) return; /* update value */ - s->ave.value = s->vave * mag + offset; + s->avg.value = s->vavg * mag + offset; s->max.value = s->vmax * mag + offset; s->min.value = s->vmin * mag + offset; /* update flag */ - s->ave.flags &= ~SENSOR_FINVALID; + s->avg.flags &= ~SENSOR_FINVALID; s->max.flags &= ~SENSOR_FINVALID; s->min.flags &= ~SENSOR_FINVALID; s->count = 0; diff --git a/sys/dev/usb/uoaklux.c b/sys/dev/usb/uoaklux.c index 58c4a460ff7..af997a9bdf8 100644 --- a/sys/dev/usb/uoaklux.c +++ b/sys/dev/usb/uoaklux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoaklux.c,v 1.1 2012/09/20 13:52:11 yuo Exp $ */ +/* $OpenBSD: uoaklux.c,v 1.2 2012/10/19 14:52:38 deraadt Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -156,7 +156,7 @@ uoaklux_attach(struct device *parent, struct device *self, void *aux) err = uoak_set_sample_rate(scc, OAK_TARGET_RAM, UOAKLUX_SAMPLE_RATE); if (err) { printf("%s: could not set sampling rate. exit\n", - sc->sc_hdev.sc_dev.dv_xname); + sc->sc_hdev.sc_dev.dv_xname); return; } @@ -190,7 +190,7 @@ uoaklux_attach(struct device *parent, struct device *self, void *aux) err = uhidev_open(&sc->sc_hdev); if (err) { printf("%s: could not open interrupt pipe, quit\n", - sc->sc_hdev.sc_dev.dv_xname); + sc->sc_hdev.sc_dev.dv_xname); return; } scc->sc_ibuf = malloc(scc->sc_ilen, M_USBDEV, M_WAITOK); @@ -308,8 +308,8 @@ uoaklux_dev_print(void *parent, enum uoak_target target) { struct uoaklux_softc *sc = (struct uoaklux_softc *)parent; - printf(" sensor gain:%s", (sc->sc_sensor.gain ? "HIGH" : "LOW")); - printf(", integration time:"); + printf(", %s gain", (sc->sc_sensor.gain ? "HIGH" : "LOW")); + printf(", speed "); switch(sc->sc_sensor.inttime) { case OAK_LUX_SENSOR_INTTIME_13_7ms: printf("13.7ms"); @@ -324,6 +324,4 @@ uoaklux_dev_print(void *parent, enum uoak_target target) printf("unknown"); break; } - - printf("\n"); } diff --git a/sys/dev/usb/uoakrh.c b/sys/dev/usb/uoakrh.c index f10d71eb74b..d403381b20a 100644 --- a/sys/dev/usb/uoakrh.c +++ b/sys/dev/usb/uoakrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoakrh.c,v 1.1 2012/09/20 13:52:11 yuo Exp $ */ +/* $OpenBSD: uoakrh.c,v 1.2 2012/10/19 14:52:38 deraadt Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -159,7 +159,7 @@ uoakrh_attach(struct device *parent, struct device *self, void *aux) err = uoak_set_sample_rate(scc, OAK_TARGET_RAM, UOAKRH_SAMPLE_RATE); if (err) { printf("%s: could not set sampling rate. exit\n", - sc->sc_hdev.sc_dev.dv_xname); + sc->sc_hdev.sc_dev.dv_xname); return; } @@ -186,9 +186,9 @@ uoakrh_attach(struct device *parent, struct device *self, void *aux) /* add label with sensor serial# */ (void)snprintf(sc->sc_sensor.temp.desc, sizeof(sc->sc_sensor.temp.desc), - "Temp.(#%s)", scc->sc_udi.udi_serial); + "Temp.(#%s)", scc->sc_udi.udi_serial); (void)snprintf(sc->sc_sensor.humi.desc, sizeof(sc->sc_sensor.humi.desc), - "\%RH(#%s)", scc->sc_udi.udi_serial); + "\%RH(#%s)", scc->sc_udi.udi_serial); sensor_attach(&sc->sc_sensordev, &sc->sc_sensor.temp); sensor_attach(&sc->sc_sensordev, &sc->sc_sensor.humi); @@ -204,7 +204,7 @@ uoakrh_attach(struct device *parent, struct device *self, void *aux) err = uhidev_open(&sc->sc_hdev); if (err) { printf("%s: could not open interrupt pipe, quit\n", - sc->sc_hdev.sc_dev.dv_xname); + sc->sc_hdev.sc_dev.dv_xname); return; } scc->sc_ibuf = malloc(scc->sc_ilen, M_USBDEV, M_WAITOK); @@ -272,7 +272,7 @@ uoakrh_intr(struct uhidev *addr, void *ibuf, u_int len) if (s->count == 0) { s->tempval = temp; s->humival = humi; - }; + } /* calculate average value */ s->tempval = (s->tempval * s->count + temp) / (s->count + 1); @@ -342,11 +342,7 @@ uoakrh_dev_print(void *parent, enum uoak_target target) { struct uoakrh_softc *sc = (struct uoakrh_softc *)parent; - - printf(" Sensor resolution: %s", - (sc->sc_sensor.resolution ? "8bit RH/12 bit" : "12bit RH/14bit")); - printf(", Heater: %s", (sc->sc_rh_heater ? "ON" : "OFF")); - printf("\n"); + printf(", %s", + (sc->sc_sensor.resolution ? "8bit RH/12 bit" : "12bit RH/14bit")); + printf(", heater %s", (sc->sc_rh_heater ? "ON" : "OFF")); } - - diff --git a/sys/dev/usb/uoakv.c b/sys/dev/usb/uoakv.c index 4dccd5e9dec..81a0452de23 100644 --- a/sys/dev/usb/uoakv.c +++ b/sys/dev/usb/uoakv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoakv.c,v 1.1 2012/09/20 13:52:11 yuo Exp $ */ +/* $OpenBSD: uoakv.c,v 1.2 2012/10/19 14:52:38 deraadt Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -56,7 +56,7 @@ int uoakvdebug = 0; struct uoakv_sensor { struct uoak_sensor v; /* ADC setting */ - unsigned int offset[OAK_V_TARGET_MAX]; /* absolute offset (mV) */ + unsigned int offset[OAK_V_TARGET_MAX]; /* absolute offset (mV) */ }; struct uoakv_softc { @@ -72,7 +72,7 @@ struct uoakv_softc { struct sensor_task *sc_sensortask; /* sensor setting */ - int sc_inputmode[OAK_V_TARGET_MAX]; + int sc_inputmode[OAK_V_TARGET_MAX]; }; @@ -159,7 +159,7 @@ uoakv_attach(struct device *parent, struct device *self, void *aux) err = uoak_set_sample_rate(scc, OAK_TARGET_RAM, UOAKV_SAMPLE_RATE); if (err) { printf("%s: could not set sampling rate. exit\n", - sc->sc_hdev.sc_dev.dv_xname); + sc->sc_hdev.sc_dev.dv_xname); return; } @@ -183,7 +183,7 @@ uoakv_attach(struct device *parent, struct device *self, void *aux) uoak_sensor_attach(scc, &sc->sc_sensor[i].v, SENSOR_VOLTS_DC); /* start sensor */ - sc->sc_sensortask = sensor_task_register(sc, uoakv_refresh, + sc->sc_sensortask = sensor_task_register(sc, uoakv_refresh, UOAKV_REFRESH_PERIOD); if (sc->sc_sensortask == NULL) { printf(", unable to register update task\n"); @@ -194,7 +194,7 @@ uoakv_attach(struct device *parent, struct device *self, void *aux) err = uhidev_open(&sc->sc_hdev); if (err) { printf("%s: could not open interrupt pipe, quit\n", - sc->sc_hdev.sc_dev.dv_xname); + sc->sc_hdev.sc_dev.dv_xname); return; } scc->sc_ibuf = malloc(scc->sc_ilen, M_USBDEV, M_WAITOK); @@ -254,7 +254,7 @@ uoakv_intr(struct uhidev *addr, void *ibuf, u_int len) memcpy(scc->sc_ibuf, ibuf, len); frame = (scc->sc_ibuf[1] << 8) + scc->sc_ibuf[0]; - + for (i = 0; i < OAK_V_MAXSENSORS; i++) { idx = (i + 1) * 2; val = (int16_t)((scc->sc_ibuf[idx+1] << 8) | scc->sc_ibuf[idx]); @@ -273,9 +273,9 @@ uoakv_refresh(void *arg) /* blink LED for each cycle */ if (uoak_led_status(scc, OAK_TARGET_RAM, &led) < 0) DPRINTF(("status query error\n")); - if (led == OAK_LED_OFF) + if (led == OAK_LED_OFF) (void)uoak_led_ctrl(scc, OAK_TARGET_RAM, OAK_LED_ON); - else + else (void)uoak_led_ctrl(scc, OAK_TARGET_RAM, OAK_LED_OFF); for (i = 0; i < OAK_V_MAXSENSORS; i++) @@ -335,7 +335,7 @@ uoakv_dev_setting(void *parent, enum uoak_target target) /* get device specific configuration */ (void)uoakv_get_sensor_setting(sc, target); - for (i = 0; i < OAK_V_MAXSENSORS; i++) + for (i = 0; i < OAK_V_MAXSENSORS; i++) (void)uoakv_get_channel_setting(sc, target, i); } @@ -345,16 +345,13 @@ uoakv_dev_print(void *parent, enum uoak_target target) struct uoakv_softc *sc = (struct uoakv_softc *)parent; int i; - printf(" input mode:%s\n", - (sc->sc_inputmode[target] ? "Psuedo-Diffential" : "Single-Ended")); + printf(", %s", + (sc->sc_inputmode[target] ? "Psuedo-Diffential" : "Single-Ended")); - printf(" ADC offset(mV): "); + printf(", ADC channel offsets:\n"); + printf("%s: ", sc->sc_hdev.sc_dev.dv_xname); for (i = 0; i < OAK_V_MAXSENSORS; i++) - printf("ch%02d ",i); - printf("\n "); - for (i = 0; i < OAK_V_MAXSENSORS; i++) - printf("%2d.%02d ", - sc->sc_sensor[i].offset[target] / 100, - sc->sc_sensor[i].offset[target] % 100); - printf("\n"); + printf("ch%02d %2d.%02d, ", i, + sc->sc_sensor[i].offset[target] / 100, + sc->sc_sensor[i].offset[target] % 100); } |