Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'H180Motor' object has no attribute 'serial' #21

Open
AlexKurek opened this issue Feb 25, 2024 · 1 comment
Open

AttributeError: 'H180Motor' object has no attribute 'serial' #21

AlexKurek opened this issue Feb 25, 2024 · 1 comment

Comments

@AlexKurek
Copy link

AlexKurek commented Feb 25, 2024

We have H180 and whether it is connected or not we are getting:

Traceback (most recent call last):
  File "/home/kurek/miniconda3/envs/srtpy/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/home/kurek/miniconda3/envs/srtpy/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/kurek/./miniconda3/envs/srtpy/bin/srt_runner.py", line 19, in run_srt_daemon
    daemon = srt_d.SmallRadioTelescopeDaemon(configuration_dir, configuration_dict)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kurek/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/daemon.py", line 115, in __init__
    self.rotor = Rotor(
                 ^^^^^^
  File "/home/kurek/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/rotor_control/rotors.py", line 58, in __init__
    self.motor = H180Motor(port, baudrate, az_limits, el_limits)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kurek/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/rotor_control/motors.py", line 352, in __init__
    Motor.__init__(self, port, az_limits, el_limits)
TypeError: Motor.__init__() missing 1 required positional argument: 'el_limits'
Exception ignored in: <function Motor.__del__ at 0x7f68a291dee0>
Traceback (most recent call last):
  File "/home/kurek/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/rotor_control/motors.py", line 88, in __del__
    if self.serial is not None and self.serial.is_open:
       ^^^^^^^^^^^
AttributeError: 'H180Motor' object has no attribute 'serial'

I modified https://github.com/MITHaystack/srt-py/blob/master/srt/daemon/rotor_control/motors.py#L352 to:
Motor.__init__(self, port, az_limits=(-0.7,359), el_limits=(8.4,80), baudrate=2400),
and the error is gone. Also (89df766):
Motor.__init__(self, port, az_limits=az_limits, el_limits=el_limits, baudrate=baudrate),
is working. I got :

Traceback (most recent call last):
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/site-packages/serial/serialposix.py", line 322, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/dev/ttyUSB0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/alex/miniconda3/envs/srtpy/bin/srt_runner.py", line 19, in run_srt_daemon
    daemon = srt_d.SmallRadioTelescopeDaemon(configuration_dir, configuration_dict)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/daemon.py", line 115, in __init__
    self.rotor = Rotor(
                 ^^^^^^
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/rotor_control/rotors.py", line 58, in __init__
    self.motor = H180Motor(port, baudrate, az_limits, el_limits)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/site-packages/srt/daemon/rotor_control/motors.py", line 353, in __init__
    self.serial = serial.Serial(
                  ^^^^^^^^^^^^^^
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/site-packages/serial/serialutil.py", line 244, in __init__
    self.open()
  File "/home/alex/miniconda3/envs/srtpy/lib/python3.11/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'

Doing (esp8266/source-code-examples#26 (comment)):
sudo usermod -a -G tty,dialout $USER
fixed it and now its working.

@AlexKurek
Copy link
Author

AlexKurek commented Feb 26, 2024

FYI: I also get these warnings in a loop. This starts to show up when I launch the browser and SRT's Dash.

WARNING:waitress.queue:Task queue depth is 2
WARNING:waitress.queue:Task queue depth is 1
WARNING:waitress.queue:Task queue depth is 1
WARNING:waitress.queue:Task queue depth is 1
WARNING:waitress.queue:Task queue depth is 2
WARNING:waitress.queue:Task queue depth is 1
WARNING:waitress.queue:Task queue depth is 1
WARNING:waitress.queue:Task queue depth is 1

To fix this, maybe one more parameter should be added to the config file: DASHBOARD_THREADS by default set to at least 6 (I set 8 and the warning is gone in Firefox 123):
https://stackoverflow.com/questions/55857058/how-to-find-the-cause-of-task-queue-depth-warnings-from-waitress/55861495#55861495
https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser/30064610#30064610
and passed to here:
https://github.com/MITHaystack/srt-py/blob/master/bin/srt_runner.py#L27

I also got during env activation:

$ conda activate srtpy
WARNING: No ICDs were found. Either,
- Install a conda package providing a OpenCL implementation (pocl, oclgrind, intel-compute-runtime, beignet) or 
- Make your system-wide implementation visible by installing ocl-icd-system conda package.

From activated env I did:
conda install -c conda-forge ocl-icd-system
and the latter warning is gone.
EDIT: fixed in AlexKurek@3bbc50a

AlexKurek added a commit to AlexKurek/srt-py that referenced this issue Feb 29, 2024
AlexKurek added a commit to AlexKurek/srt-py that referenced this issue Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant