forked from M-Labs/artiq
1
0
Fork 0

examples/coredev_test: RPC demo

This commit is contained in:
Sebastien Bourdeauducq 2014-07-07 19:14:39 +02:00
parent 4f0e40ca3c
commit b9b9cc46e2
1 changed files with 9 additions and 2 deletions

View File

@ -4,11 +4,18 @@ from artiq.devices import corecom_serial, runtime, core, gpio_core
class CompilerTest(Experiment): class CompilerTest(Experiment):
channels = "core led" channels = "core led"
def output(self, n):
print("Received: "+str(n))
def get_max(self):
return int(input("Maximum: "))
@kernel @kernel
def run(self): def run(self):
self.led.set(1) self.led.set(1)
x = 1 x = 1
while x < 100: m = self.get_max()
while x < m:
d = 2 d = 2
prime = 1 prime = 1
while d*d <= x: while d*d <= x:
@ -16,7 +23,7 @@ class CompilerTest(Experiment):
prime = 0 prime = 0
d = d + 1 d = d + 1
if prime == 1: if prime == 1:
syscall("rpc", 42, x) self.output(x)
x = x + 1 x = x + 1
self.led.set(0) self.led.set(0)