<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rurandom.org/justintime/index.php?action=history&amp;feed=atom&amp;title=Sxsim_test_python_script</id>
	<title>Sxsim test python script - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rurandom.org/justintime/index.php?action=history&amp;feed=atom&amp;title=Sxsim_test_python_script"/>
	<link rel="alternate" type="text/html" href="https://rurandom.org/justintime/index.php?title=Sxsim_test_python_script&amp;action=history"/>
	<updated>2026-11-26T15:53:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.4</generator>
	<entry>
		<id>https://rurandom.org/justintime/index.php?title=Sxsim_test_python_script&amp;diff=361&amp;oldid=prev</id>
		<title>Danny: 1 revision:&amp;#32;copying content from old site</title>
		<link rel="alternate" type="text/html" href="https://rurandom.org/justintime/index.php?title=Sxsim_test_python_script&amp;diff=361&amp;oldid=prev"/>
		<updated>2010-07-12T22:07:41Z</updated>

		<summary type="html">&lt;p&gt;1 revision: copying content from old site&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:07, 12 July 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Danny</name></author>
	</entry>
	<entry>
		<id>https://rurandom.org/justintime/index.php?title=Sxsim_test_python_script&amp;diff=360&amp;oldid=prev</id>
		<title>Danny: New page: &lt;pre&gt; # simple test script that runs the thermostat firmware, simulates some input and # writes the program output to screen.  import sys import pysix  # load a listing file listing = pysi...</title>
		<link rel="alternate" type="text/html" href="https://rurandom.org/justintime/index.php?title=Sxsim_test_python_script&amp;diff=360&amp;oldid=prev"/>
		<updated>2009-06-29T12:28:14Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;lt;pre&amp;gt; # simple test script that runs the thermostat firmware, simulates some input and # writes the program output to screen.  import sys import pysix  # load a listing file listing = pysi...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
# simple test script that runs the thermostat firmware, simulates some input and&lt;br /&gt;
# writes the program output to screen.&lt;br /&gt;
&lt;br /&gt;
import sys&lt;br /&gt;
import pysix&lt;br /&gt;
&lt;br /&gt;
# load a listing file&lt;br /&gt;
listing = pysix.ParseListingFile(&amp;quot;../../test/thermostat.lst&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# create an emulator&lt;br /&gt;
sx = pysix.Simulator()&lt;br /&gt;
&lt;br /&gt;
# load the listings program bytes into the sx rom&lt;br /&gt;
sx.load_rom( listing)&lt;br /&gt;
&lt;br /&gt;
# some code labels&lt;br /&gt;
send_byte = 0x0405&lt;br /&gt;
after_spi_read = 0x0141&lt;br /&gt;
&lt;br /&gt;
#some data labels&lt;br /&gt;
spi_value = 0x08&lt;br /&gt;
&lt;br /&gt;
# the entry point to the send_byte function. At this&lt;br /&gt;
# point w will contain a character to be sent to output (LCD/rs-232)&lt;br /&gt;
sx.set_breakpoint( send_byte) &lt;br /&gt;
&lt;br /&gt;
# right after a temperature has been read from the spi device&lt;br /&gt;
# ram location spi_value will contain the temperature reading.&lt;br /&gt;
sx.set_breakpoint( after_spi_read)&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
	sx.run(10000) # do 10 000 instructions, or stop if we hit a breakpoint&lt;br /&gt;
	&lt;br /&gt;
	if		send_byte		== sx.state.pc:&lt;br /&gt;
		sys.stdout.write( chr(sx.state.w))&lt;br /&gt;
		&lt;br /&gt;
	elif	after_spi_read	== sx.state.pc:&lt;br /&gt;
		# Todo: simplify this. state can only be copied as a whole, not changed&lt;br /&gt;
		state = sx.state&lt;br /&gt;
		state.ram.set_absolute( spi_value, 100)&lt;br /&gt;
		state.ram.set_absolute( spi_value + 1, 0)&lt;br /&gt;
		sx.state = state&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danny</name></author>
	</entry>
</feed>