vfdboard/scripts/cpuload.py

21 lines
399 B
Python
Executable File

#!/usr/bin/env python
import subprocess
import serial
ser = serial.Serial("/dev/ttyACM0")
ser.write(b'\nxx\n')
last = 0
while 1:
p = subprocess.Popen("./getload.sh", shell=True);
r = p.wait()
r = round(r / 100 * 60)
#if (r < last - 2):
# r = last - 4
last=r
ser.write(b'X')
ser.write(r.to_bytes(1, byteorder='big'))
ser.write(r.to_bytes(1, byteorder='big'))
ser.write(b'\n')
ser.close()