|  |  | @ -32,27 +32,29 @@ class TestAmplifier(unittest.TestCase): | 
			
		
	
		
		
			
				
					
					|  |  |  |     dmesg = subprocess.check_output("dmesg", shell=True, encoding='utf8') |  |  |  |     dmesg = subprocess.check_output("dmesg", shell=True, encoding='utf8') | 
			
		
	
		
		
			
				
					
					|  |  |  |     i2c_lines = [l for l in dmesg.strip().splitlines() if 'i2c_geni a88000.i2c' in l] |  |  |  |     i2c_lines = [l for l in dmesg.strip().splitlines() if 'i2c_geni a88000.i2c' in l] | 
			
		
	
		
		
			
				
					
					|  |  |  |     i2c_str = '\n'.join(i2c_lines) |  |  |  |     i2c_str = '\n'.join(i2c_lines) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if not expected: |  |  |  |     if not expected: | 
			
		
	
		
		
			
				
					
					|  |  |  |       assert len(i2c_lines) == 0 |  |  |  |       return len(i2c_lines) == 0 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     else: |  |  |  |     else: | 
			
		
	
		
		
			
				
					
					|  |  |  |       assert "i2c error :-107" in i2c_str or "Bus arbitration lost" in i2c_str |  |  |  |       return "i2c error :-107" in i2c_str or "Bus arbitration lost" in i2c_str | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_init(self): |  |  |  |   def test_init(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |     amp = Amplifier(debug=True) |  |  |  |     amp = Amplifier(debug=True) | 
			
		
	
		
		
			
				
					
					|  |  |  |     r = amp.initialize_configuration(Tici().get_device_type()) |  |  |  |     r = amp.initialize_configuration(Tici().get_device_type()) | 
			
		
	
		
		
			
				
					
					|  |  |  |     assert r |  |  |  |     assert r | 
			
		
	
		
		
			
				
					
					|  |  |  |     self._check_for_i2c_errors(False) |  |  |  |     assert self._check_for_i2c_errors(False) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_shutdown(self): |  |  |  |   def test_shutdown(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |     amp = Amplifier(debug=True) |  |  |  |     amp = Amplifier(debug=True) | 
			
		
	
		
		
			
				
					
					|  |  |  |     for _ in range(10): |  |  |  |     for _ in range(10): | 
			
		
	
		
		
			
				
					
					|  |  |  |       r = amp.set_global_shutdown(True) |  |  |  |       r = amp.set_global_shutdown(True) | 
			
		
	
		
		
			
				
					
					|  |  |  |       r = amp.set_global_shutdown(False) |  |  |  |       r = amp.set_global_shutdown(False) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       # amp config should be successful, with no i2c errors | 
			
		
	
		
		
			
				
					
					|  |  |  |       assert r |  |  |  |       assert r | 
			
		
	
		
		
			
				
					
					|  |  |  |       self._check_for_i2c_errors(False) |  |  |  |       assert self._check_for_i2c_errors(False) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   def test_init_while_siren_play(self): |  |  |  |   def test_init_while_siren_play(self): | 
			
		
	
		
		
			
				
					
					|  |  |  |     for _ in range(5): |  |  |  |     for _ in range(10): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       self.panda.set_siren(False) |  |  |  |       self.panda.set_siren(False) | 
			
		
	
		
		
			
				
					
					|  |  |  |       time.sleep(0.1) |  |  |  |       time.sleep(0.1) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -63,8 +65,10 @@ class TestAmplifier(unittest.TestCase): | 
			
		
	
		
		
			
				
					
					|  |  |  |       r = amp.initialize_configuration(Tici().get_device_type()) |  |  |  |       r = amp.initialize_configuration(Tici().get_device_type()) | 
			
		
	
		
		
			
				
					
					|  |  |  |       assert r |  |  |  |       assert r | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     # make sure we're a good test |  |  |  |       if self._check_for_i2c_errors(True): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     self._check_for_i2c_errors(True) |  |  |  |         break | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     else: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       self.fail("didn't hit any i2c errors") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | if __name__ == "__main__": |  |  |  | if __name__ == "__main__": | 
			
		
	
	
		
		
			
				
					|  |  | 
 |