mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-06 00:36:29 +08:00
setup: add serial to request headers (#27237)
* setup: add dongle ID to request headers * rename openpilot * fix str * hardware: get_serial * set serial instead * fix typo * static * fixes old-commit-hash: 6fb5661abba34971e547941e0f6a6625bef3b75a
This commit is contained in:
@@ -16,6 +16,8 @@ public:
|
||||
static int get_voltage() { return 0; };
|
||||
static int get_current() { return 0; };
|
||||
|
||||
static std::string get_serial() { return "cccccc"; }
|
||||
|
||||
static void reboot() {}
|
||||
static void poweroff() {}
|
||||
static void set_brightness(int percent) {}
|
||||
|
||||
@@ -21,6 +21,23 @@ public:
|
||||
static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); };
|
||||
static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); };
|
||||
|
||||
static std::string get_serial() {
|
||||
static std::string serial("");
|
||||
if (serial.empty()) {
|
||||
std::ifstream stream("/proc/cmdline");
|
||||
std::string cmdline;
|
||||
std::getline(stream, cmdline);
|
||||
|
||||
auto start = cmdline.find("serialno=");
|
||||
if (start == std::string::npos) {
|
||||
serial = "cccccc";
|
||||
} else {
|
||||
auto end = cmdline.find(" ", start + 9);
|
||||
serial = cmdline.substr(start + 9, end - start - 9);
|
||||
}
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
static void reboot() { std::system("sudo reboot"); };
|
||||
static void poweroff() { std::system("sudo poweroff"); };
|
||||
|
||||
Reference in New Issue
Block a user