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

    Controlling Duet from python

    Scheduled Pinned Locked Moved
    General Discussion
    2
    2
    282
    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.
    • jonathanundefined
      jonathan
      last edited by

      Re: Duet 3 use for other motion systems?

      A brief update and a question
      Update. I can control several motors well enough either singly or in coupled movement via the console.

      Question: I need to be able to send Gcode from a PC, preferably python. From hints in the documentation and the CodeConsole, it seems like I should be able to use a simple POST to send a command and get the response. This is easy with the python requests library, a single line of code. I have a Duet3 and a raspberry pi on the network configured at the router with a static address. Here is the stupid simple code (due to my ignorance):

      import requests

      class Duet(object):
      """simple command post to duet"""

      def __init__(self, URL = 'http://192.167.1.42/'):
          """stasch the URL
          check validity?
          """
          self.URL = URL
      
      def DuetCmd(self, command):
          response = requests.post(self.URL, data=command)
          return response
      

      DuetCmd times out. The default port is 80. Likely I have misinterpreted the use of the PORT on the Raspberry pi. So how does one send individual lines of Gcode to the pi, thence the Duet? Is there a simpler way to do this?
      Many thanks for any suggestions or pointers to resources.

      T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
      • T3P3Tonyundefined
        T3P3Tony administrators @jonathan
        last edited by

        @jonathan have you seen this documentation:

        https://github.com/Duet3D/DuetSoftwareFramework#rest-api

        www.duet3d.com

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Unless otherwise noted, all forum content is licensed under CC-BY-SA