Cannot get response from Duet for M400



  • I am having trouble reading the "ok" messages from the Duet when I connect over serial port in python.

    When I send a move command, such as "G1 X100", I write to the serial port with a python script. The code I execute needs to know when the movement has physically completed, so I added an M400 command when I was using a different controller board. I would then wait for the appropriate number of "ok" responses, and then my software would move forward.

    When I read the serial port on the Duet, I only occasionally grab the heartbeat "ok" messages when the board automatically sends M105.

    Is there a way to increase the read rate of responses from the Duet? My baud rate is at 115200. Thanks.


  • administrators

    The serial port on Duets is generally used for connecting a PanelDue, so OK responses are not sent to it. If you want to receive OK responses, I suggest you use the USB port instead.



  • Thanks for the quick response.

    I use the built in pySerial class to open the connection, which uses the USB Port as best I understand it:

    ser=serial.Serial("/dev/tty.usbmodem", 115200, timeout=0.1)

    Is there an alternate way to connect over USB?



  • @dc42 Really all I want is a way to get controlled "OK" messages back from the board. I found a work around where I send the following series of commands:

    G1 ; Any command here it doesn't matter
    M400 ; This waits for everything upstream to execute
    M105
    M105

    The M105 command returns "ok T" for my configuration, presumably trying to tell me the bed temp for a bed that doesn't exist. So, it doesn't matter to me if I connect over USB or Serial, just that I can get back expected "ok" messages easily. But, I am concerned that using this M105 command will have unintended consequences.

    What is the best way in your opinion, to get back these "ok" messages at the conclusion of Move-execution?

    Thanks!


  • administrators

    If you have Marlin compatibility selected in M555, you should get an "ok" response for every command sent via USB or Telnet. I've just tested this, and I do get "ok" after M400 sent via USB.



  • Ok, based on your direction I set the compatibility mode to Marlin with the command: "M555 P2" and reset the board. I'm not getting any "ok" messages back that are different from before.


  • administrators

    @sean said in Cannot get response from Duet for M400:

    Ok, based on your direction I set the compatibility mode to Marlin with the command: "M555 P2" and reset the board. I'm not getting any "ok" messages back that are different from before.

    Strange, it works for me, sending the commands from YAT. Please try sending those same commands from a terminal emulator.



  • @dc42 Thanks for sticking with me on this. When I set the firmware compatibility to Marlin previously, I just sent the M555 S2 command from the terminal emulator. After thinking about it some more, I thought to add the command directly to the general config.g settings, and it worked!

    I now get an "ok" back for every command I send. I added two M400 commands to make sure I know when the batch of movement commands are completed executing.

    I should say too that I am using a Mac terminal for most of this development work, and also used Pronterface and Arduino IDE previously, but hadn't set the Marlin compatibility directly in config.g

    I am also using serial.Serial() to open the connection via USB port. Works great!

    tl;dr Receive "ok"s by setting M555 S2 in config.g file, instead of trying to send M555 S2 over terminal. (I think setting it in the config file makes it more permanent)


Log in to reply