void sht_measure(void) { uint16_t res; printf("sht measure humd\n"); printf(" start\n"); sht_start(); printf(" command\n"); sht_sendb(SHT_CMD_HUMD); printf(" data\n"); res = sht_readw(); printf(" result: %d\n", res); printf("sht measure temp\n"); printf(" start\n"); sht_start(); printf(" command\n"); sht_sendb(SHT_CMD_TEMP); printf(" data\n"); res = sht_readw(); printf(" result: %d\n", res); }
void watchdog_check(void) { watchdog_t *wd; ht_pos_t pos; time_t diff; time_t now = time(NULL); if (pthread_mutex_lock(&watchdog_mutex)) { log_sys_error("watchdog: pthread_mutex_lock"); return; } watchdog_init(); // Check all records sht_start(&watchdog_table, &pos); while ((wd = sht_next(&watchdog_table, &pos))) { diff = now - wd->wd_received; if (diff <= cf_watchdog_stage_timeout) { continue; } log_error("%s: %s: slow connection: age=%d %s=%d", wd->wd_id, wd->wd_stage, diff, wd->wd_stage, now - wd->wd_instage); } if (pthread_mutex_unlock(&watchdog_mutex)) { log_sys_error("watchdog: pthread_mutex_unlock"); } return; }