Software icon indicating copy to clipboard operation
Software copied to clipboard

Thunderloop Send Error when Battery is Unstable

Open Mr-Anyone opened this issue 1 year ago • 1 comments

Description

resolve #3181. This essentially sends a message when the battery isn't stable.

Testing Done

ran the following code to make sure I can actually read the file!

#include <fstream>
#include <iostream>

static bool isPowerStable()
{
    std::ifstream dmesg_log_file("/var/log/dmesg");
    // if the log file cannot be open, we would return false. Chances are, the battery
    // power supply is indeed stable
    if (!dmesg_log_file.is_open())
    {
        //LOG(WARNING) << "Cannot dmesg log file. Do you have permission?";
        std::cout << "Cannot dmesg log file. Do you have permission?" << std::endl;
        return true;
    }

    std::string line;
    while (getline(dmesg_log_file, line))
    {
        if (line.find("kernel") != std::string::npos)
        {
            return false;
        }
    }

    return true;
}

int main(){
    if(isPowerStable()){
        std::cout << "Yay" << std::endl; 
    }else{
        std::cout << "this is expected as the log message is likely to contain the word 'kernel' " << std::endl; 
    }
}

Resolved Issues

resolves #3181

Review Checklist

  • [X] Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • [X] Remove all commented out code
  • [X] Remove extra print statements: for example, those just used for testing
  • [X] Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Mr-Anyone avatar May 10 '24 03:05 Mr-Anyone

maybe pull from a buffer?

Mr-Anyone avatar May 10 '24 03:05 Mr-Anyone