Hi,
I was trying to run two instances of an NDSP (in order to control two identical function generators) and got an error, so I have built a minimum example reproducing it, based on the hello controller in the manual. My aqctl_hello.py
looks like this
import argparse
from sipyco.pc_rpc import simple_server_loop
from sipyco.common_args import simple_network_args , bind_address_from_args
def get_argparser():
parser = argparse.ArgumentParser(description="Hello world controller")
simple_network_args(parser, 3249) # 3249 is the default TCP port
return parser
class Hello:
def message(self, msg): # -> None: doesn't help either
print("message: " + msg)
def ping(self): # used by the controller manager
return True
def main():
args = get_argparser().parse_args()
simple_server_loop({"hello": Hello()}, bind_address_from_args(args), args.port)
if __name__ == "__main__":
main()
my device_db.py
ends with
device_db.update({
"hello": {
"type": "controller",
"host": "::1",
"port": 3210,
"command": "python aqctl_hello.py -p {port}"
},
})
device_db.update({
"hello2": {
"type": "controller",
"host": "::1",
"port": 3209,
"command": "python aqctl_hello.py -p {port}"
},
})
and the experiment test_hello2.py
goes like
from artiq.experiment import *
class hello_test(EnvExperiment):
"""Test script for 2 hello controllers
"""
def build(self):
# self.setattr_device("core" )
self.setattr_device("hello" )
self.setattr_device("hello2")
#@kernel
def run(self):
self.hello.message ("Hello, World!")
self.hello2.message("Hello, World! 2nd")
Then I run in 3 separate windows artiq_master
, artiq_ctlmgr
and artiq_run test_hello2.py
.
Without @kernel decorator nor "core" I get the 2 msgs on both windows (ctlmgr and master).
With @kernel (which requires "core" device) the 2nd message causes this error:
(artiq5) D:\Javier\work\local>artiq_run test_hello2.py
<synthesized>:1:1-1:54: error: host object has an attribute 'message' of type [rpc3#](...)->NoneType, which is different from previously inferred type [rpc2 #](...)->NoneType for the same attribute
`<sipyco.pc_rpc.Client object at 0x00000000047DD668>`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test_hello2.py:14:1: note: expanded from here
def run(self):
^
I don't think it's related to missing type annotations, but just in case I annotated like this
class Hello:
def message(self, msg) -> None:
and it didn't help either. Anyways, annotations shouldn't be required, according to the manual:
RPC functions must always return a value of the same type. When they return a value that is not None, the compiler should be informed in advance of the type of the value, which is what the -> TBool annotation is for.
def input_led_state() -> TBool:
return input("Enter desired LED state: ") == "1"
I am doing something wrong, but don't know what. Please help.
Thanks in advance