Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    File2 is not a valid CodeChannel - Part Deux

    Scheduled Pinned Locked Moved Solved
    DSF Development
    2
    3
    196
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • davidjryanundefined
      davidjryan
      last edited by

      I did not want to hijack Ant1's previous thread so I have created a new one with a similar problem. All I am trying to do is run the examples in GitHub https://github.com/Duet3D/dsf-python/tree/main/examples, specifically the subscribe to object model example, and I receive the same error "File2 is not a valid CodeChannel".

      My setup:
      Duet 6HC 3.5.1 in SBC mode with a Raspberry Pi 5 running the latest Duet Bookworm image

      I have performed the following (per the "pip won't install dsf-python-3.5.1rc1 thread"):

      pi@A1000-1:~/.local/lib/python3.11/site-packages $  sudo pip3 install --break-system-packages --pre dsf-python
      Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
      Requirement already satisfied: dsf-python in /usr/local/lib/python3.11/dist-packages (3.5.1rc1)
      Requirement already satisfied: python-dateutil in /usr/local/lib/python3.11/dist-packages (from dsf-python) (2.9.0.post0)
      Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil->dsf-python) (1.16.0)
      WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
      pi@A1000-1:~/.local/lib/python3.11/site-packages $
      

      From the examples folder, I have been able to run, without issue:
      custom_http_endpoint.py
      custom_m_codes.py
      send_simple_code.py

      When I try to run:
      subscribe_object_model.py

      I get:

       /bin/python /home/pi/Alphamated/controller/sub.py
      Traceback (most recent call last):
        File "/home/pi/Alphamated/controller/sub.py", line 31, in <module>
          subscribe()
        File "/home/pi/Alphamated/controller/sub.py", line 18, in subscribe
          object_model = subscribe_connection.get_object_model()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/connections/subscribe_connection.py", line 43, in get_object_model
          object_model = self.receive(ObjectModel)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/connections/base_connection.py", line 83, in receive
          return cls.from_json(json.loads(json_string))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 87, in from_json
          return cls()._update_from_json(**preserve_builtin(data))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/object_model.py", line 165, in _update_from_json
          super(ObjectModel, self)._update_from_json(**kwargs)
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 76, in _update_from_json
          setattr(self, attr_name, attr.update_from_json(json_value))
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_collection.py", line 57, in update_from_json
          self.append(self._item_constructor().update_from_json(item_to_add))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 93, in update_from_json
          return self._update_from_json(**preserve_builtin(data))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 69, in _update_from_json
          setattr(self, json_key_snake, json_value)
        File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/inputs/input_channel.py", line 132, in name
          self._name = CodeChannel(value)
                       ^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/enum.py", line 717, in __call__
          return cls.__new__(cls, value)
                 ^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.11/enum.py", line 1133, in __new__
          raise ve_exc
      ValueError: 'File2' is not a valid CodeChannel
      

      What simple thing am I missing or what typo did I perform?

      The Pi is dedicated to the Duet and only has a single user. I'd like to have all packages system-wide and not have to use a venv (hence, I used the --break-system-packages option for pip install).

      I am nowhere near the level of you folks on here so please type slowly so I can understand... 😉

      Falcounetundefined 1 Reply Last reply Reply Quote 0
      • Falcounetundefined
        Falcounet @davidjryan
        last edited by Falcounet

        @davidjryan By looking at the traceback, it seems you have an older version of dsf-python installed for the pi user (in /home/pi/.local/lib/python3.11/site-packages/dsf/) so python uses this one instead of the system-wide one installed in /usr/local/lib/python3.11/dist-packages.

        Try running pip3 uninstall dsf-python without sudo to remove it.

        Also, please note that an APT package has been released to install dsf-python on Debian Bookworm.
        This can be installed using sudo apt install python3-dsf-python
        However, there is no change since the 3.5.1rc1 version that you have currently installed using pip3 --break-system-packages so you should be fine.

        davidjryanundefined 1 Reply Last reply Reply Quote 1
        • davidjryanundefined
          davidjryan @Falcounet
          last edited by

          @Falcounet That did it, thanks!
          I had performed:
          sudo apt install python3-dsf-python
          but didn't include the snippet of that in my post. I guess it didn't matter since I had the older version of dsf-python installed. I do install that version via a script when setting up the Pi/Duet "out of the box". I'll update my script to use python3-dsf-python instead.

          Thanks again!

          1 Reply Last reply Reply Quote 1
          • davidjryanundefined davidjryan marked this topic as a question
          • davidjryanundefined davidjryan has marked this topic as solved
          • First post
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA