mirror of https://github.com/Desuuuu/klipper.git
klippy: Log the type of cpu the host is running on
Report in the log the host CPU type and count. This helps distinguish between different rpi versions when debugging the log from a problem report. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
29131c873a
commit
3434ea540c
|
@ -284,6 +284,7 @@ def main():
|
||||||
software_version = util.get_git_version()
|
software_version = util.get_git_version()
|
||||||
if debugoutput is None:
|
if debugoutput is None:
|
||||||
logging.info("Git version: %s" % (repr(software_version),))
|
logging.info("Git version: %s" % (repr(software_version),))
|
||||||
|
logging.info("CPU: %s" % (util.get_cpu_info(),))
|
||||||
|
|
||||||
# Start firmware
|
# Start firmware
|
||||||
while 1:
|
while 1:
|
||||||
|
|
|
@ -37,6 +37,21 @@ def create_pty(ptyname):
|
||||||
termios.tcsetattr(mfd, termios.TCSADRAIN, old)
|
termios.tcsetattr(mfd, termios.TCSADRAIN, old)
|
||||||
return mfd
|
return mfd
|
||||||
|
|
||||||
|
def get_cpu_info():
|
||||||
|
try:
|
||||||
|
f = open('/proc/cpuinfo', 'rb')
|
||||||
|
data = f.read()
|
||||||
|
f.close()
|
||||||
|
except OSError:
|
||||||
|
logging.debug("Exception on read /proc/cpuinfo: %s" % (
|
||||||
|
traceback.format_exc(),))
|
||||||
|
return "?"
|
||||||
|
lines = [l.split(':', 1) for l in data.split('\n')]
|
||||||
|
lines = [(l[0].strip(), l[1].strip()) for l in lines if len(l) == 2]
|
||||||
|
core_count = [k for k, v in lines].count("processor")
|
||||||
|
model_name = dict(lines).get("model name", "?")
|
||||||
|
return "%d core %s" % (core_count, model_name)
|
||||||
|
|
||||||
def get_git_version():
|
def get_git_version():
|
||||||
# Obtain version info from "git" program
|
# Obtain version info from "git" program
|
||||||
gitdir = os.path.join(sys.path[0], '..', '.git')
|
gitdir = os.path.join(sys.path[0], '..', '.git')
|
||||||
|
|
Loading…
Reference in New Issue