void AtasmartSensorDriver::read_temps() const { SkBool disk_sleeping = false; if (unlikely(dnd_disk && (sk_disk_check_sleep_mode(disk_, &disk_sleeping) < 0))) { string msg = strerror(errno); throw SystemError("sk_disk_check_sleep_mode(" + path_ + "): " + msg); } if (unlikely(disk_sleeping)) { temp_state.add_temp(0); } else { uint64_t mKelvin; double tmp; if (unlikely(sk_disk_smart_read_data(disk_) < 0)) { string msg = strerror(errno); throw SystemError("sk_disk_smart_read_data(" + path_ + "): " + msg); } if (unlikely(sk_disk_smart_get_temperature(disk_, &mKelvin)) < 0) { string msg = strerror(errno); throw SystemError("sk_disk_smart_get_temperature(" + path_ + "): " + msg); } tmp = mKelvin / 1000.0f; tmp -= 273.15f; if (unlikely(tmp > std::numeric_limits<int>::max() || tmp < std::numeric_limits<int>::min())) { throw SystemError(MSG_T_GET(path_) + std::to_string(tmp) + " isn't a valid temperature."); } temp_state.add_temp(tmp); } }
void NvmlSensorDriver::read_temps() const { nvmlReturn_t ret; unsigned int tmp; if ((ret = dl_nvmlDeviceGetTemperature(device_, NVML_TEMPERATURE_GPU, &tmp))) throw SystemError(MSG_T_GET(path_) + "Error code (cf. nvml.h): " + std::to_string(ret)); temp_state.add_temp(tmp); }
void NvmlSensorDriver::read_temps() const { nvmlReturn_t ret; unsigned int tmp; if ((ret = dl_nvmlDeviceGetTemperature(device_, NVML_TEMPERATURE_GPU, &tmp))) fail(TF_ERR) << SystemError(MSG_T_GET(path_) + "Error code (cf. nvml.h): " + std::to_string(ret)) << flush; *temp_state.temp_idx = tmp; update_tempstate(correction_[0]); }
void HwmonSensorDriver::read_temps() const { std::ifstream f(path_); try { f.exceptions(f.failbit | f.badbit); int tmp; f >> tmp; temp_state.add_temp(tmp/1000 + correction_[0]); } catch (std::ios_base::failure &e) { string msg = std::strerror(errno); throw SystemError(MSG_T_GET(path_) + msg); } }
void HwmonSensorDriver::read_temps() const { try { std::ifstream f(path_); f.exceptions(f.failbit | f.badbit); int tmp; f >> tmp; *temp_state.temp_idx = tmp / 1000; update_tempstate(correction_[0]); } catch (std::exception &e) { string msg = std::strerror(errno); fail(TF_ERR) << MSG_T_GET(path_) + ": " << SystemError(string(e.what()) + ": " + msg) << flush; } }
void TpSensorDriver::read_temps() const { try { std::ifstream f(path_); f.exceptions(f.failbit | f.badbit); unsigned int tidx = 0; while (!f.eof()) { f >> *temp_state.temp_idx; update_tempstate(correction_[tidx++]); } } catch (std::exception &e) { string msg = std::strerror(errno); fail(TF_ERR) << MSG_T_GET(path_) << SystemError(string(e.what()) + ": " + msg) << flush; } }
void TpSensorDriver::read_temps() const { std::ifstream f(path_); try { f.exceptions(f.failbit | f.badbit); f.seekg(skip_bytes_); f.exceptions(f.badbit); unsigned int tidx = 0; int tmp; while (!f.eof()) { f >> tmp; if (!f.fail()) temp_state.add_temp(tmp + correction_[tidx++]); } } catch (std::ios_base::failure &e) { string msg = std::strerror(errno); throw SystemError(MSG_T_GET(path_) + msg); } }
void AtasmartSensorDriver::read_temps() const { SkBool disk_sleeping = false; if (unlikely(dnd_disk && (sk_disk_check_sleep_mode(disk_, &disk_sleeping) < 0))) { string msg = strerror(errno); fail(TF_ERR) << SystemError("sk_disk_check_sleep_mode(" + path_ + "): " + msg) << flush; } if (unlikely(disk_sleeping)) { *temp_state.temp_idx = 0; update_tempstate(correction_[0]); } else { uint64_t mKelvin; double tmp; if (unlikely(sk_disk_smart_read_data(disk_) < 0)) { string msg = strerror(errno); fail(TF_ERR) << SystemError("sk_disk_smart_read_data(" + path_ + "): " + msg) << flush; } if (unlikely(sk_disk_smart_get_temperature(disk_, &mKelvin)) < 0) { string msg = strerror(errno); fail(TF_ERR) << SystemError("sk_disk_smart_get_temperature(" + path_ + "): " + msg) << flush; } tmp = mKelvin / 1000.0f; tmp -= 273.15f; if (unlikely(tmp > std::numeric_limits<int>::max() || tmp < std::numeric_limits<int>::min())) { fail(TF_ERR) << MSG_T_GET(path_) << SystemError(std::to_string(tmp) + " isn't a valid temperature.") << flush; } *temp_state.temp_idx = tmp; update_tempstate(correction_[0]); } }