Пример #1
0
def check_hardware(skip_keyboard_input = False):    
    # first the GPIO pins        
    sound_check_passed = 'skip-gpio-test' in sys.argv;
    while not sound_check_passed:
        print 'Checking device control - you should hear both devices turn on/off or off/on...'
        time.sleep(1)
        try:
            chestfreezer_gpio.output_pin_for_time(configuration.heater_pin(), False, 1)            
            time.sleep(1)                        
            chestfreezer_gpio.output_pin_for_time(configuration.freezer_pin(), False, 1)
        except ValueError as e:            
            sys.exit('Pins could not be activated, reason:\n' + str(e) + '\nTerminating.')
        try:
            if skip_keyboard_input: raise termios.error
            # eclipse cannot handle this!
            sound_check_passed = do_sound_check()
        except termios.error:
            print 'You are using eclipse or some other IDE or are running tests, check passed.'
            sound_check_passed = True  
    print 'GPIO pins #' + configuration.heater_pin() + ' and #' + configuration.freezer_pin() + ' connected correctly.'            
    
    # then the temperature sensor(s)
    temperature_probes.initialize_probes()
    probes = temperature_probes.probe_ids        
    if probes is None:    
        sys.exit('No temperature probes were detected, check your wiring. Terminating.')
    else:
        print 'Found ' + str(len(probes)) + ' functional temperature sensor(s).'
        temperature_probes.determine_master_probe()
        if 'insert-test-data' in sys.argv:                        
            data_for_testing.insert_dummy_temperatures()                
 def test_output_pin_for_time(self):
     chestfreezer_gpio.GPIO.setup = Mock()
     chestfreezer_gpio.GPIO.output = Mock()        
     chestfreezer_gpio.output_pin_for_time(1, False, 1)
             
     chestfreezer_gpio.GPIO.setup.assert_called_once_with(1, chestfreezer_gpio.GPIO.OUT) # @UndefinedVariable
     chestfreezer_gpio.GPIO.output.assert_any_call(1, False) # @UndefinedVariable
     chestfreezer_gpio.GPIO.output.assert_any_call(1, True) # @UndefinedVariable
Пример #3
0
def checkHardware():
    # first the GPIO pins
    import hardware.chestfreezer_gpio as gpio    
    sound_check_passed = True;
    while not sound_check_passed:
        print 'Checking device control - you should hear four clicking noises...'
        time.sleep(1)
        try:  
            gpio.output_pin_for_time(configuration.heater_pin(), False, 1)
            time.sleep(1)
            gpio.output_pin_for_time(configuration.freezer_pin(), False, 1)
        except ValueError as e:            
            sys.exit('Pins could not be activated, reason:\n' + str(e) + '\nTerminating.')
        sound_check_passed = do_sound_check(gpio)            
    print 'GPIO pins #' + configuration.heater_pin() + ' and #' + configuration.freezer_pin() + ' connected correctly.'            
    
    # then the temperature sensor(s)
    temperature.initialize_probes()
    probes = temperature.probe_ids        
    if probes is None:    
        sys.exit('No temperature probes were detected, check your wiring. Terminating.')
    else:
        print 'Found ' + str(len(probes)) + ' functional temperature sensor(s).'
        temperature.determine_master_probe()