use the new macro
This commit is contained in:
13
src/sys.cpp
13
src/sys.cpp
@@ -1,6 +1,7 @@
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cwchar>
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <sys.hpp>
|
||||
@@ -37,12 +38,13 @@ void sys::getNetwork(Network* net, std::string device) {
|
||||
uint64_t tx = 0;
|
||||
};
|
||||
|
||||
static char buf[24];
|
||||
static _net prev;
|
||||
_net current;
|
||||
|
||||
current.ts = std::chrono::steady_clock::now();
|
||||
current.rx = std::stoull(readFile("/sys/class/net/" + device + "/statistics/rx_bytes", 32));
|
||||
current.tx = std::stoull(readFile("/sys/class/net/" + device + "/statistics/tx_bytes", 32));
|
||||
fastReadNum("/sys/class/net/" + device + "/statistics/rx_bytes", current.rx);
|
||||
fastReadNum("/sys/class/net/" + device + "/statistics/tx_bytes", current.tx);
|
||||
float ts_diff = std::chrono::duration_cast<std::chrono::microseconds>(current.ts - prev.ts).count() / 1000000.0f;
|
||||
net->download = (current.rx - prev.rx) / ts_diff;
|
||||
net->upload = (current.tx - prev.tx) / ts_diff;
|
||||
@@ -54,7 +56,8 @@ void sys::detectHwmon(sysSensors* s, std::string platform) {
|
||||
}
|
||||
|
||||
void sys::updateSensors(sysSensors* s) {
|
||||
s->fan_speed[0] = std::stol(readFile(s->hwmon + "/fan2_input", 4));
|
||||
s->fan_speed[1] = std::stol(readFile(s->hwmon + "/fan7_input", 4));
|
||||
s->t_sensor = std::stol(readFile(s->hwmon + "/temp5_input", 2));
|
||||
static char buf[8];
|
||||
fastReadNum(s->hwmon + "/fan2_input", s->fan_speed[0]);
|
||||
fastReadNum(s->hwmon + "/fan7_input", s->fan_speed[1]);
|
||||
fastReadNum(s->hwmon + "/temp5_input", s->t_sensor) / 1000;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user