simonsobs / socs

Simons Observatory specific OCS agents.
BSD 2-Clause "Simplified" License
12 stars 12 forks source link

Error connecting to DWL tilt sensor #716

Open BrianJKoopman opened 2 months ago

BrianJKoopman commented 2 months ago

When starting up the WireGridTiltSensor agent with the following example options we get a connection error due to a type mismatch:

{'agent-class': 'WiregridTiltSensorAgent',
 'instance-id': 'wg-tilt-sensor',
 'manage': 'docker',
 'arguments': [['--ip-address', '10.10.10.10'],
               ['--port', '32'],
               ['--sensor-type', 'DWL']]},

Note, changing the port from '32' to 32 does not solve the problem either. Some type checking/casting should be added.

Args: ['--instance-id', 'wg-tilt-sensor', '--site-hub', 'ws://127.0.0.1:8003/ws', '--site-http', 'http://127.0.0.1:8003/call']
Installed OCS Plugins: ['socs', 'ocs']
Renaming this process to: "ocs-agent:wg-tilt-sensor"
Traceback (most recent call last):
  File "/usr/local/bin/ocs-agent-cli", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/ocs/agent_cli.py", line 208, in main
    start(args=post_args)
  File "/usr/local/lib/python3.8/dist-packages/socs/agents/wiregrid_tiltsensor/agent.py", line 203, in main
    tiltsensor_agent = WiregridTiltSensorAgent(agent,
  File "/usr/local/lib/python3.8/dist-packages/socs/agents/wiregrid_tiltsensor/agent.py", line 36, in __init__
    self.tiltsensor = connect(self.ip, self.port, self.sensor_type)
  File "/usr/local/lib/python3.8/dist-packages/socs/agents/wiregrid_tiltsensor/drivers/__init__.py", line 9, in connect
    tiltsensor = DWL(tcp_ip=ip, tcp_port=port, timeout=0.5, isSingle=False, verbose=0)
  File "/usr/local/lib/python3.8/dist-packages/socs/agents/wiregrid_tiltsensor/drivers/dwl.py", line 25, in __init__
    msg = self.__conn(tcp_ip, tcp_port, timeout)
  File "/usr/local/lib/python3.8/dist-packages/socs/agents/wiregrid_tiltsensor/drivers/dwl.py", line 129, in __conn
    self.ser = mx.Serial_TCPServer((tcp_ip, tcp_port), timeout)
  File "/usr/local/lib/python3.8/dist-packages/socs/common/moxa_serial.py", line 64, in __init__
    self.sock.connect(self.port)
TypeError: an integer is required (got type str)
Disconnecting from TCP IP 10.10.10.10 at port 32
Exception ignored in: <function DWL.__del__ at 0x7f7068afd280>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/socs/agents/wiregrid_tiltsensor/drivers/dwl.py", line 30, in __del__
    self.ser.close()
AttributeError: 'DWL' object has no attribute 'ser'
d-hoshino2626 commented 1 week ago

Hi Brian! I created the PR https://github.com/simonsobs/socs/pull/764 to fix this problem. Sorry for late respose.