def getPiThrottled(): vcgm = Vcgencmd() thrott_state = vcgm.get_throttled() # print("Get Throttled = ", thrott_state) return thrott_state
try: interval = float(sys.argv[1]) print("running at an interval of " + str(interval) + " seconds.") except Exception as e: print(str(e)) print("note: you can pass the loop interval as a value in seconds, e.g. voltage_check.py 0.5") interval = 1 num_errors = 0 last_error = "" while True: status = [] row = [get_date(),0,0,0,0,0,0,0,0] sum_bits = 0 output = vcgm.get_throttled() if "breakdown" in output: result = output["breakdown"] # testing # result = {'0': False, '1': False, '2': True, '3': False, '16': True, '17': False, '18': False, '19': False} if result['0'] == True: row[1]=1 sum_bits += 1 status.append(fields[1]) last_error = "(last err since boot under VDC: " + get_datetime() + ")" if result['1'] == True: row[2]=1 sum_bits += 1 status.append(fields[2]) last_error = "(last err since boot arm freq cap: " + get_datetime() + ")" if result['2'] == True:
def __init__(self, node): """Init selftest with node.""" self.node = node self.lcd_driver = self.node.create_publisher(Lcd, "lcd", 1) # Wait for subscribers while self.lcd_driver.get_subscription_count() < 1: sleep(1) self.__write__(0) # Report selftest init if "aarch64" not in machine(): return self.__write__(0x10) # Started Hardware tests # Testing for CPU Throttling vcgm = Vcgencmd() self.__write__(0x11) if int(vcgm.get_throttled().get("raw_data"), 16) != 0: return # Testing devices on sensors I2C Bus addrs_vlx = [] if node.name == "obelix": addrs_vlx = [0x30, 0x31, 0x32, 0x35, 0x36, 0x37] try: bus = SMBus(4) for addr in addrs_vlx: self.__write__(addr) bus.read_byte(addr) except BaseException: return # Testing devices on actuators I2C Bus code = 0x40 self.__write__(code) try: bus = SMBus(3) for addr in self.node.actuators.pump_addr: code += 1 self.__write__(code) bus.read_byte(addr) """ if node.name == "obelix": addr_slider = 0x12 self.__write__(addr_slider) bus.read_byte(addr_slider) """ except BaseException: return # NOTE : Testing devices on accessories bus (I2C6 is not relevant) # due to the LCD being present # Testing dynamixels connection code = 0x50 if node.name == "obelix": self.__write__(code) for dyna in self.node.actuators.DYNAMIXELS: code += 1 self.__write__(code) if self.node.actuators.arbotix.getPosition(dyna) == -1: return for servo in self.node.actuators.SERVOS: servo = self.node.actuators.SERVOS.get(servo) code += 1 self.__write__(code) if self.node.actuators.arbotix.getPosition(servo.get("addr")) == -1: return self.__write__(0xFF)