m-labs / artiq

A leading-edge control system for quantum information experiments
https://m-labs.hk/artiq
GNU Lesser General Public License v3.0
435 stars 201 forks source link

thorlabs_tcube_controller multiple devices #140

Closed ghost closed 9 years ago

ghost commented 9 years ago

What's the proper way to handle multiple tcube devices? I have 7 tcubes in the Penning lab. My understanding is the intent is for each device type to share the same port (3255) But this doesn't seem to work. I have 7 tcubes in the Penning lab. Example device_db.pyon.

    "thor_fun": {
        "type": "controller",
        "best_effort": true,
        "host": "68810artiq1.bw.nist.gov",
        "comment": "this is a test of the Thorlabs TCube",
        "port": 3255,
        "target_name": "tdc001",
        "command": "thorlabs_tcube_controller -v -v -p {port} --bind {bind} -P TDC001 -d \"hwgrep://VID:PID=0403:faf0 SNR=83833889\" "
    },
    "wpl": {
        "type": "controller",
        "best_effort": true,
        "host": "68810artiq1.bw.nist.gov",
        "comment": "Thorlabs waveplate lower ODF beam",
        "port": 3255,
        "target_name": "tdc001",
        "command": "thorlabs_tcube_controller -v -v -p {port} --bind {bind} -P TDC001 -d \"hwgrep://VID:PID=0403:faf0 SNR=83822985\" "
    },
(py35)rabi@68810artiq1:~/gitlab/nistpenning/artiq$ artiq_ctlmgr --server 688penninga.bw.nist.gov
DEBUG:controller(novatech_wall):artiq.devices.novatech409b.driver:got response from device: OK
DEBUG:controller(novatech_wall):artiq.devices.novatech409b.driver:got response from device: OK
DEBUG:controller(novatech_wall):asyncio:Using selector: EpollSelector
DEBUG:controller(thor_fun):artiq.devices.thorlabs_tcube.driver:baud rate set to 115200
DEBUG:controller(thor_fun):asyncio:Using selector: EpollSelector
DEBUG:controller(wpl):artiq.devices.thorlabs_tcube.driver:baud rate set to 115200
DEBUG:controller(wpl):asyncio:Using selector: EpollSelector
INFO:controller(wpl):print:Traceback (most recent call last):
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 849, in create_server
INFO:controller(wpl):print:    sock.bind(sa)
INFO:controller(wpl):print:OSError: [Errno 98] Address already in use
INFO:controller(wpl):print:
INFO:controller(wpl):print:During handling of the above exception, another exception occurred:
INFO:controller(wpl):print:
INFO:controller(wpl):print:Traceback (most recent call last):
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/bin/thorlabs_tcube_controller", line 6, in <module>
INFO:controller(wpl):print:    sys.exit(main())
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/frontend/thorlabs_tcube_controller.py", line 48, in main
INFO:controller(wpl):print:    simple_server_loop({args.product.lower(): dev}, args.bind, args.port)
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/protocols/pc_rpc.py", line 497, in simple_server_loop
INFO:controller(wpl):print:    loop.run_until_complete(server.start(host, port))
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 342, in run_until_complete
INFO:controller(wpl):print:    return future.result()
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/futures.py", line 274, in result
INFO:controller(wpl):print:    raise self._exception
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/tasks.py", line 239, in _step
INFO:controller(wpl):print:    result = coro.send(value)
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/protocols/asyncio_server.py", line 29, in start
INFO:controller(wpl):print:    host, port)
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/streams.py", line 102, in start_server
INFO:controller(wpl):print:    return (yield from loop.create_server(factory, host, port, **kwds))
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 853, in create_server
INFO:controller(wpl):print:    % (sa, err.strerror.lower()))
INFO:controller(wpl):print:OSError: [Errno 98] error while attempting to bind on address ('132.163.182.75', 3255): address already in use
WARNING:ctlmgr:artiq.frontend.artiq_ctlmgr:Controller wpl exited
WARNING:ctlmgr:artiq.frontend.artiq_ctlmgr:Restarting in 5.0 seconds
DEBUG:controller(wpl):artiq.devices.thorlabs_tcube.driver:baud rate set to 115200
DEBUG:controller(wpl):asyncio:Using selector: EpollSelector
INFO:controller(wpl):print:Traceback (most recent call last):
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 849, in create_server
INFO:controller(wpl):print:    sock.bind(sa)
INFO:controller(wpl):print:OSError: [Errno 98] Address already in use
INFO:controller(wpl):print:
INFO:controller(wpl):print:During handling of the above exception, another exception occurred:
INFO:controller(wpl):print:
INFO:controller(wpl):print:Traceback (most recent call last):
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/bin/thorlabs_tcube_controller", line 6, in <module>
INFO:controller(wpl):print:    sys.exit(main())
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/frontend/thorlabs_tcube_controller.py", line 48, in main
INFO:controller(wpl):print:    simple_server_loop({args.product.lower(): dev}, args.bind, args.port)
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/protocols/pc_rpc.py", line 497, in simple_server_loop
INFO:controller(wpl):print:    loop.run_until_complete(server.start(host, port))
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 342, in run_until_complete
INFO:controller(wpl):print:    return future.result()
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/futures.py", line 274, in result
INFO:controller(wpl):print:    raise self._exception
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/tasks.py", line 239, in _step
INFO:controller(wpl):print:    result = coro.send(value)
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/protocols/asyncio_server.py", line 29, in start
INFO:controller(wpl):print:    host, port)
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/streams.py", line 102, in start_server
INFO:controller(wpl):print:    return (yield from loop.create_server(factory, host, port, **kwds))
INFO:controller(wpl):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 853, in create_server
INFO:controller(wpl):print:    % (sa, err.strerror.lower()))
INFO:controller(wpl):print:OSError: [Errno 98] error while attempting to bind on address ('132.163.182.75', 3255): address already in use
WARNING:ctlmgr:artiq.frontend.artiq_ctlmgr:Controller wpl exited
WARNING:ctlmgr:artiq.frontend.artiq_ctlmgr:Restarting in 5.5 seconds
^CTraceback (most recent call last):
  File "/home/rabi/anaconda3/envs/py35/bin/artiq_ctlmgr", line 6, in <module>
    sys.exit(main())
  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/frontend/artiq_ctlmgr.py", line 329, in main
    loop.run_until_complete(rpc_server.wait_terminate())
  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 330, in run_until_complete
    self.run_forever()
  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 301, in run_forever
    self._run_once()
  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 1162, in _run_once
    event_list = self._selector.select(timeout)
  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/selectors.py", line 432, in select
    fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt
INFO:controller(thor_fun):print:Traceback (most recent call last):
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/bin/thorlabs_tcube_controller", line 6, in <module>
INFO:controller(thor_fun):print:    sys.exit(main())
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/frontend/thorlabs_tcube_controller.py", line 48, in main
INFO:controller(thor_fun):print:    simple_server_loop({args.product.lower(): dev}, args.bind, args.port)
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/site-packages/artiq/protocols/pc_rpc.py", line 499, in simple_server_loop
INFO:controller(thor_fun):print:    loop.run_until_complete(server.wait_terminate())
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 330, in run_until_complete
INFO:controller(thor_fun):print:    self.run_forever()
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 301, in run_forever
INFO:controller(thor_fun):print:    self._run_once()
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/asyncio/base_events.py", line 1162, in _run_once
INFO:controller(thor_fun):print:    event_list = self._selector.select(timeout)
INFO:controller(thor_fun):print:  File "/home/rabi/anaconda3/envs/py35/lib/python3.5/selectors.py", line 432, in select
INFO:controller(thor_fun):print:    fd_event_list = self._epoll.poll(timeout, max_ev)
INFO:controller(thor_fun):print:KeyboardInterrupt
WARNING:ctlmgr:artiq.frontend.artiq_ctlmgr:Controller thor_fun did not respond to terminate command, killing
WARNING:ctlmgr:artiq.frontend.artiq_ctlmgr:Controller novatech_wall did not respond to terminate command, killing
sbourdeauducq commented 9 years ago

One controller per tcube device (as you did) and if they are on the same machine, you need to use a different port for each. The default ports of controllers are just for demonstration purposes or simple setups, and the port allocation should be adapted to particular laboratory configurations.