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

    Sending data from python server to Duet

    Scheduled Pinned Locked Moved
    Duet Web Control
    2
    4
    190
    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.
    • pouryatorabiundefined
      pouryatorabi
      last edited by

      Hi,
      Right now I'm sending some M commands like M1585 with a Macro, and on the server side when I receive M1585 I run a function. That function returns a data that I want to send it back to the macro and do something with it. Can someone tell me the way of doing it?

      1 Reply Last reply Reply Quote 0
      • adambxundefined
        adambx
        last edited by

        Hi,

        you could have a parameter in the macro like "param.R" for example.
        If you call the macro with the parameter, it will act as if it received a result

        M1585           ->  Server
                             ....calculate...
        M1585 R{result} <-  Server
        

        of course that's not synchronous. If you want to wait for the answer, another option would be to use a message box. That would be a little bit more complicated, although much more flexible 😉

        https://docs.duet3d.com/User_manual/Reference/Gcodes#m291-display-message-and-optionally-wait-for-response

        Afaik there is no other way to wait for a message via GCODE...

        pouryatorabiundefined 1 Reply Last reply Reply Quote 0
        • pouryatorabiundefined
          pouryatorabi @adambx
          last edited by pouryatorabi

          @adambx
          Hi,
          Thank you for your reply, that's what I'm doing right now and I thought there might be a better option, but this is how I call a macro with python:

          cc = CommandConnection()
          cc.connect()  
          cc.perform_simple_code('M98 P"/macros/SomeMacro" L{}'.format(val))
          

          Is there any other safer or better way to all a macro with python server?

          adambxundefined 1 Reply Last reply Reply Quote 0
          • adambxundefined
            adambx @pouryatorabi
            last edited by

            @pouryatorabi I can't think of anything, but am looking forward to suggestions, if there are any by others

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