コード例 #1
0
 def __init__(self, filename=None):
     if get_simavr_logger() is None:
         init_simavr_logger()
     self.filename = None
     self.backend = elf_firmware_t()
     if filename:
         self.read(filename)
コード例 #2
0
    def __init__(self, firmware=None, mcu=None, f_cpu=None, avcc=5, vcc=5):
        '''

        :param mcu: mcu name
        :param f_cpu: frequency in hertz
        :param avcc: avcc in Volt
        :param vcc: vcc in Volt
        '''
        if get_simavr_logger() is None:
            init_simavr_logger()  # Only init logger when it was not initialized before
        self.callbacks_keepalive = [] # External callback instances are stored here just to avoid GC destroying them too early
        self._irq_helper = IRQHelper(self)
        self.avrsize = None
        self.time_marker = 0.0
        self.mcu = mcu
        self.f_cpu = f_cpu
        self._avcc = avcc
        self._vcc = vcc

        if firmware:
            if not self.mcu:
                self.mcu = str(firmware.mcu)
            if not self.f_cpu:
                self.f_cpu = firmware.frequency

        assert self.mcu
        assert self.f_cpu

        log.debug('mcu=%s f_cpu=%s' % (self.mcu, self.f_cpu))

        self.backend = avr_make_mcu_by_name(self.mcu)
        if not self.backend:
            raise UnkwownAvrError('unknown AVR: ' + self.mcu)

        avr_init(self.backend)
        self.backend.frequency = self.f_cpu  # Propagate the freq to the backend

        self._set_voltages()

        avr_start_thread(self.backend)
        self.pause()
        if firmware:
            self.load_firmware(firmware)
        self.uart = Uart(self)
        self.uart.connect()
コード例 #3
0
ファイル: test_1log.py プロジェクト: ponty/pysimavr
def test_custom_logger():
    loggerMethod = Mock()
    #Register custom callback method for simav logs
    logger.init_simavr_logger(loggerMethod)
    avr = Avr(mcu='atmega48', f_cpu=8000000)
    #Let the simavr run in background until it sadly crashes on ramend
    avr.run() 
    while avr.cycle < 8000 and avr.state == cpu_Running :
        time.sleep(0.1)
        
    # Expected:
    #('Starting atmega48 - flashend 0fff ramend 02ff e2end 00ff\n', 3)
    #('atmega48 init\n', 3)
    #('atmega48 reset\n', 3)
    #('avr_sadly_crashed\n', 1)
    eq_(loggerMethod.call_count, 4, "number of callback invocations")
    loggerMethod.assert_called_with('avr_sadly_crashed\n', 1)    
    avr.terminate()
コード例 #4
0
def test_custom_logger():
    loggerMethod = Mock()
    #Register custom callback method for simav logs
    logger.init_simavr_logger(loggerMethod)
    avr = Avr(mcu='atmega48', f_cpu=8000000)
    #Let the simavr run in background until it sadly crashes on ramend
    avr.run()
    while avr.cycle < 8000 and avr.state == cpu_Running:
        time.sleep(0.1)

    # Expected:
    #('Starting atmega48 - flashend 0fff ramend 02ff e2end 00ff\n', 3)
    #('atmega48 init\n', 3)
    #('atmega48 reset\n', 3)
    #('avr_sadly_crashed\n', 1)
    eq_(loggerMethod.call_count, 4, "number of callback invocations")
    loggerMethod.assert_called_with('avr_sadly_crashed\n', 1)
    avr.terminate()
コード例 #5
0
ファイル: avr.py プロジェクト: ponty/pysimavr
    def __init__(self, firmware=None, mcu=None, f_cpu=None, avcc=5, vcc=5):
        '''

        :param mcu: mcu name
        :param f_cpu: frequency in hertz
        :param avcc: avcc in Volt
        :param vcc: vcc in Volt
        '''
        if get_simavr_logger() is None:
            init_simavr_logger() #Only init logger when it was not initialized before
        self.avrsize = None
        self.time_marker = 0.0
        self.mcu = mcu
        self.f_cpu = f_cpu
        self._avcc = avcc
        self._vcc = vcc

        if firmware:
            if not self.mcu:
                self.mcu = str(firmware.mcu)
            if not self.f_cpu:
                self.f_cpu = firmware.frequency

        assert self.mcu
        assert self.f_cpu

        log.debug('mcu=%s f_cpu=%s' % (self.mcu, self.f_cpu))

        self.backend = avr_make_mcu_by_name(self.mcu)
        if not self.backend:
            raise UnkwownAvrError('unknown AVR: ' + self.mcu)

        avr_init(self.backend)
        self.backend.frequency = self.f_cpu #Propagate the freq to the backend

        self._set_voltages()

        avr_start_thread(self.backend)
        self.pause()
        if firmware:
            self.load_firmware(firmware)
        self.uart = Uart(self)
        self.uart.connect()
コード例 #6
0
ファイル: avr.py プロジェクト: sanakhan22/pysimavr
    def __init__(self, firmware=None, mcu=None, f_cpu=None, avcc=5, vcc=5):
        '''

        :param mcu: mcu name
        :param f_cpu: frequency in hertz
        :param avcc: avcc in Volt
        :param vcc: vcc in Volt
        '''
        init_simavr_logger()
        self.avrsize = None
        self.time_marker = 0.0
        self.mcu = mcu
        self.f_cpu = f_cpu
        self._avcc = avcc
        self._vcc = vcc

        if firmware:
            if not self.mcu:
                self.mcu = str(firmware.mcu)
            if not self.f_cpu:
                self.f_cpu = firmware.frequency

        assert self.mcu
        assert self.f_cpu

        log.debug('mcu=%s f_cpu=%s' % (self.mcu, self.f_cpu))

        self.backend = avr_make_mcu_by_name(self.mcu)
        if not self.backend:
            raise UnkwownAvrError('unknown AVR: ' + self.mcu)

        avr_init(self.backend)

        self._set_voltages()

        avr_start_thread(self.backend)
        self.pause()
        if firmware:
            self.load_firmware(firmware)
        self.uart = Uart(self)
        self.uart.connect()