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

    Python script send Gcode to duet 3 failed

    Scheduled Pinned Locked Moved
    General Discussion
    2
    3
    254
    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.
    • Kaguyaundefined
      Kaguya
      last edited by

      Hi,

      I am trying to use python to send Gcode to the board through USB serial port with the code (we use Visual Studio Code + python 3.7)

      import serial
      #Serial takes these two parameters: serial device and baudrate
      
      ser = serial.Serial('COM6', 9600, timeout=0)
      command = 'M106 S128'
      ser.write(command.encode())
      

      The board didn't response to the command. The connection is build successfully however the Gcode seems not recognized by the Duet 3. We tried to use YAT software to send this command and it works (the fan is then rotate).

      We are wondering if this is because the python script lacks some function to transform string to the signal Duet 3 can read. Could you help with this? Thanks.

      Otsoundefined 1 Reply Last reply Reply Quote 0
      • Otsoundefined
        Otso @Kaguya
        last edited by

        @kaguya Hi, you must add a newline character before the command will be processed. Try command = "M106 S128\n".

        Kaguyaundefined 1 Reply Last reply Reply Quote 1
        • Kaguyaundefined
          Kaguya @Otso
          last edited by

          @otso Thank you very much. It works.

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