]> mj.ucw.cz Git - home-hw.git/commitdiff
Clock host: Do not report zero pressure before the 1st sensor reading
authorMartin Mares <mj@ucw.cz>
Thu, 16 Aug 2018 10:13:05 +0000 (12:13 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 16 Aug 2018 10:13:05 +0000 (12:13 +0200)
usb/host/burrow-clock.c

index 62a1e8cf1a4c0cc10e8664358e904dd6fed01d76..6ef3415a3df7d462290c96513636969086ef39f0 100644 (file)
@@ -38,7 +38,7 @@ static libusb_device *find_device(void)
                libusb_device *dev = devlist[i];
                if (!libusb_get_device_descriptor(dev, &desc)) {
                        if (desc.idVendor == 0x4242 && desc.idProduct == 0x0001) {
-                               msg(L_INFO, "Found device at usb%d.%d\n", libusb_get_bus_number(dev), libusb_get_device_address(dev));
+                               msg(L_INFO, "Found device at usb%d.%d", libusb_get_bus_number(dev), libusb_get_device_address(dev));
                                // FIXME: Free device list
                                return dev;
                        }
@@ -145,14 +145,14 @@ int main(int argc UNUSED, char **argv)
                unsigned char resp[64];
                int received;
                if (err = libusb_bulk_transfer(devh, 0x82, resp, 64, &received, 2000))
-                       die("Receive failed: error %d\n", err);
+                       die("Receive failed: error %d", err);
                // printf("Received %d bytes\n", received);
                if (received >= 12) {
                        int temp = get_u32_be(resp);
                        int press = get_u32_be(resp + 4);
                        uint cycle = get_u32_be(resp + 8);
                        msg(L_DEBUG, "Temperature %d ddegC, pressure %d Pa, cycle %u", temp, press, cycle);
-                       if (!(cnt % 10)) {
+                       if (!(cnt % 10) && press) {
                                mqtt_publish("burrow/temp/clock", "%.1f %llu", temp / 10., (long long) t);
                                mqtt_publish("burrow/pressure/clock", "%d %llu", press, (long long) t);
                        }