python wrapper for simavr which is AVR and arduino simulator.
Project description
pysimavr is a python wrapper for simavr which is AVR and arduino simulator
- Links:
documentation: http://pysimavr.readthedocs.org
- Features:
Basic usage
>>> from pysimavr.avr import Avr >>> avr=Avr(mcu='atmega48',f_cpu=8000000) >>> firmware = Firmware('lcd.elf') >>> avr.load_firmware(firmware)>>> from pysimavr.sim import ArduinoSim >>> print ArduinoSim(snippet='Serial.print("hello!");').get_serial() hello!
Installation
check simavr documentation
General
Ubuntu 14.04
sudo apt-get install python-pip sudo apt-get install python-dev gcc libelf-dev arduino sudo pip install pysimavr # optional for some tests: sudo apt-get install freeglut3-dev scons swig
Uninstall
# as root pip uninstall pysimavr
Usage
pysimavr.examples.simple:
#-- include('examples/simple.py')--# from pysimavr.avr import Avr if __name__ == "__main__": avr = Avr(mcu='atmega48', f_cpu=8000000) print( avr.pc ) avr.step(1) print( avr.pc ) avr.step(1) print( avr.pc ) avr.terminate() #-#
Output:
#-- sh('python -m pysimavr.examples.simple ')--# 0 2 4 #-#
pysimavr.examples.hello:
#-- include('examples/hello.py')--# from pysimavr.sim import ArduinoSim if __name__ == "__main__": s= ArduinoSim(snippet='Serial.println("hello!");').get_serial() print(s) #-#
Output:
#-- sh('python -m pysimavr.examples.hello ')--# hello! #-#
pysimavr.examples.delay:
#-- include('examples/delay.py')--# from pysimavr.sim import ArduinoSim import time snippet = ''' int i=0; while (1) { Serial.println(i++); _delay_ms(1000); } ''' t0 = None def logger(x): global t0 t = time.time() if not t0: t0 = t print t - t0, x f_cpu=16000000 fps=20 speed=1 timespan=5 if __name__ == "__main__": ArduinoSim(snippet=snippet, timespan=timespan, serial_line_logger=logger, f_cpu=f_cpu, fps=fps, speed=speed, ).run() #-#
Output:
#-- sh('python -m pysimavr.examples.delay ')--# 0.0 0 1.00977802277 1 2.01976013184 2 3.02968215942 3 4.03792500496 4 #-#
vcd export example
pysimavr.examples.vcd:
#-- include('examples/vcd.py')--# from pysimavr.sim import ArduinoSim vcdfile='delay.vcd' snippet = ''' Serial.println("start"); pinMode(0, OUTPUT); digitalWrite(0, HIGH); delay(100); digitalWrite(0, LOW); delay(100); digitalWrite(0, HIGH); delay(100); digitalWrite(0, LOW); delay(100); Serial.println("end"); ''' if __name__ == "__main__": sim = ArduinoSim(snippet=snippet, vcd=vcdfile, timespan=0.5) sim.run() #-#
File hierarchy
|-docs sphinx documentation |---.build generated documentation |-pysimavr main python package, high level classes |---examples examples |---swig all swig files (simavr and parts) |-----include copy of simavr generated *.h files |-------avr copy from avr-libc |-----parts some electronic parts in c |-----simavr simavr as git submodule |-tests unit tests
How to update external sources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pysimavr-0.2.2.tar.gz
(1.1 MB
view details)
File details
Details for the file pysimavr-0.2.2.tar.gz
.
File metadata
- Download URL: pysimavr-0.2.2.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70d49d3500d0381e6695f492e97eb86164ddc403ca03780ca2787f4641b20926 |
|
MD5 | 92b53e1d991647824f1a655bd973c311 |
|
BLAKE2b-256 | 2fe4ac33181c5c9acd2f9ae41b76ce5b7fcb9bb81004b5f1d2ad9cde409cae8c |