[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Simulavr-devel] Run a devices twice
From: |
Thomas K |
Subject: |
Re: [Simulavr-devel] Run a devices twice |
Date: |
Sun, 11 Jun 2017 17:22:07 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 |
Hi Sebastian,
your code has some misunderstandings, I believe.
At first: ResetClock() does just reset the time control system, this
isn't a real core reset! If you want to rerun a program a second time
then it's better to reset the device and load the possibly different
code again and start again.
In your code (if this is, what you want to do) it would be better to
delete the entire simulation and set it up again. Background for the
exception in your code is, that if you create a device, it registers
itself on a trace system (for debugging output, vcd-Output and such) and
on 4th code line you've declared the simulation as single device
application - just one core in simulation. And on the 12th line you
create again a core without deleting the old core before! This ends in a
exception.
So, (best solution!) delete sim (means "del sim"! The garbage collector
could do this to late) for the second run and repeat 3th and 4th line
(create sim and set into single core mode) before loadDevice()
or:
Delete dev (e.g. "del dev") for the second run before loadDevice() call.
But ... maybe it's the best to describe, what you want to get. Your
example is a little bit to minimalistic. :-)
Best regards, Thomas
Am 09.06.2017 um 10:12 schrieb zug:
Hi everyone,
thanks for providing simulavr with a Python interface, I would like to
use the simulator to evaluate automatically AVR code of my students.
Hence, I have a number of elf files and it was my intention to run a
script loading one by one
and execute some tests. But I failed to reset the simulator and the
virtual controller ...
To condense my problem I prepared the following code snippet that
should run and
rerun an elf file. For reseting the simulation I added a method
def ResetSystem(self):
self.__sc.ResetClock()
in ex_utils.py. When I excute the script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
import ex_utils
mcu = "atmega32"
sim = ex_utils.SimulavrAdapter()
sim.dmanSingleDeviceApplication()
# Test 1
print "First Run"
dev = sim.loadDevice(mcu, "blinking_LED.elf")
sim.doRun(10000) # Execute an exemplary simulation
sim.ResetSystem() # Reset the simulation system
# Test 2
print "Second Run"
dev = sim.loadDevice(mcu, "blinking_LED.elf")
sim.doRun(10000) # Execute an examplary simulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I got
▶ python evaluationFailure.py
First Run
Second Run
FATAL: file traceval.cpp: line 567: Can't create device name twice,
because it's a single device application
What's happened? The syncMembers vector should be empty? Why do we have a
conflict here?
Thanks for your help
Sebastian