Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

PanelDue M408, M20, M36

Open thinkyhead opened this issue 6 years ago • 37 comments

As requested in #10609

Add support for the PanelDue touch controller by Escher3D and the M408 command it requires.

  • M20 still needs work to add the P parameter for selecting a folder and for printing long filenames. The existing implementation just prints the whole directory with full DOS 8.3 paths.
  • M36 still needs to be implemented. The M27 C command is similar, so part of that code can be re-used.

A test unit is on the way!

thinkyhead avatar May 03 '18 04:05 thinkyhead

Did you receive the test panel?

bwgeez02 avatar May 09 '18 01:05 bwgeez02

It arrived yesterday, along with the 4-pin connector, thanks! I'll hook it up to something and get into testing this weekend. I haven't read the online docs yet, but I'll do that tomorrow to see what it can do and how it connects to the board.

thinkyhead avatar May 09 '18 20:05 thinkyhead

I will shortly do a new release of the PanelDue firmware, so I propose to add customisation for Marlin. The customisation will be triggered by seeing "firmwareName":"Marlin" in the M408 S1 response. You may put other characters after 'Marlin' e.g. a version number because PanelDue only matches the leading substring of the firmware name. The customisations I propose are the same as for Repetier:

  • GCode files live in the SD card root, not in folder /gcodes
  • Standby temperatures are not supported
  • Temperatures are set by M104 not G10

Anything else? For Smoothieware we also omit the drive identifier (e.g. "0:") at the start of files paths.

dc42 avatar May 24 '18 08:05 dc42

Sounds good! There's a bit of extra work to do before M20 can provide JSON output, but I will get to that pretty soon.

I presume I can flash the new firmware via the USB socket…? Naturally, I'll Google for the documentation once the panel's new firmware is ready.

With bug-fixing foremost on the docket, I haven't hooked up the panel to a board yet, though I have several loose boards hanging around. The one DUE I have on hand has no shield, so I'm looking for a way to hook the panel up to one of my generic boards — preferably RAMPS, Megatronics 3, or ReARM. Is there a specific recommendation as to a set of adjacent pins that are best to use for the 4-pin connector? I presume for serial that the standard Serial1 pins will work best, the idea being that the panel will be able to co-exist with a USB-connected host. I'll look more closely at the boards I have and see if any provide those pins in an ideal configuration.

I'm sure I'll have more questions as I get further in development.

thinkyhead avatar May 24 '18 14:05 thinkyhead

hello i search for this commits but can't find it on latest build why? I want to use the M408 function

Elenedeath avatar Jun 28 '18 17:06 Elenedeath

can't find it on latest build why?

image

thinkyhead avatar Jun 30 '18 20:06 thinkyhead

@thinkyhead Would it help if you had a RADDS shield for your Due?

bwgeez02 avatar Jul 15 '18 18:07 bwgeez02

I just got around to rebasing this, and I'll see about completing this feature soon.

Would it help if you had a RADDS shield for your Due?

@bwgeez02 — It probably would. The Due is pretty useless without it, except for very basic testing.

thinkyhead avatar Sep 06 '18 12:09 thinkyhead

@thinkyhead On it's way. Shipping from Denmark. Sept 14-27 eta. Thanks!

bwgeez02 avatar Sep 09 '18 14:09 bwgeez02

@thinkyhead Hey! Did you receive the Radds? I didn't get any tracking info.

bwgeez02 avatar Sep 30 '18 13:09 bwgeez02

Yes, thanks! And I've attached it to my DUE and flashed Marlin 2.0.x onto it. I'm going to see about installing it into my old i3 too when I get a little more time to rebuild it. Meanwhile, I'll hook up the PanelDue and carry on with this PR.

thinkyhead avatar Oct 01 '18 02:10 thinkyhead

Let me know if you need another PanelDue controller board to test with.

David Crocker, Escher Technologies Ltd. http://www.eschertech.com Tel. +44 (0)20 8144 3265 or +44 (0)7977 211486

On 01/10/2018 03:13, Scott Lahteine wrote:

Yes, thanks! And I've attached it to my DUE and flashed Marlin 2.0.x onto it. I'm going to see about installing it into my old i3 when I get a little more time to rebuild it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MarlinFirmware/Marlin/pull/10610#issuecomment-425772649, or mute the thread https://github.com/notifications/unsubscribe-auth/ACmEbP4K5xglCinvWDi83vmSjk-nNfedks5ugXpDgaJpZM4TwfVA.

dc42 avatar Oct 02 '18 08:10 dc42

Thanks, David. I've just got to sequester myself in a room with various boards and the 7" PanelDue and hammer out the rest of this, including some deep changes to the cardreader code. At the moment most of my time is taken up in vetting PRs and following up on issues, but in a couple of weeks I'll have an assistant to take on some of that load, allowing me to dive into this and into the long-overdue refactor of the LCD / controller code.

thinkyhead avatar Oct 06 '18 05:10 thinkyhead

Any update on this ?

guestisp avatar Jun 15 '19 16:06 guestisp

Any update on this?

Rebased. It needs more changes to the ls and lsdive methods for the extended M20 command. And it will be getting reworked as an ExtUI-based display. Hopefully I'll have this done by the end of the week.

thinkyhead avatar Jul 01 '19 05:07 thinkyhead

So, to be clear, now i can order a PanelDue and use that to control the Marlin like with a duet and reprapfirmware?

guestisp avatar Jul 01 '19 06:07 guestisp

Is the Marlin 2.0 ready yet ? I want to use PanelDue with my SKR v1.3 with Marlin 2.0. Thanks Adrian

Adik22 avatar Jul 12 '19 12:07 Adik22

Any update or ETA on this? I'm waiting for this merge before buying a PanelDue

guestisp avatar Aug 02 '19 21:08 guestisp

I managed to get M408 to work and added a paneldue to my SKR v1.3 via pins 0.15 and 0.16 (on EXP2) it works but there is no possibility to use external SD cards. The other UART pins are used for step, dir and enable on some of the stepper drivers. And I was not able to get it to work on TX0 and RX0(TFT and AUX-1 connectors).

The changes to these was imported from this branch: cardreader.cpp cardreader.h gcode.cpp gcode.h M408.cpp

I then corrected the things that made M408.cpp unable to compile.

I'm very new to C++ and GIT so if anyone would help me get this ready for import to the main branch we can get M408 working soon. My branch is avaliable here: https://github.com/Swesen/Marlin/tree/BLV_MGN_Cube_SKR_1.3

Using both serial ports seems to interfere with each other, marlin asks for resends (Recv: Resend: 43 Recv: ok) this makes the prints loop while printing over USB, and I don't have the knowledge of where to start. The paneldue also seems to stop updating when this happens.

Swesen avatar Aug 22 '19 16:08 Swesen

I got myself a logic analyzer and checked why the connection is not stable with the panel due and the reason seems to be that marlin checks if the line number is correct, if it is not marlin responds with "Line Number is not Last Line Number+1". This feature would need to be disabled or re synced on the port used for the panel due.

Also port 0 on the SKR 1.3 works for paneldue, it just sends this error which also seems to mess up the sync on the USB also.

Is this part(from line 619) in queue.cpp able to be modified with no severe impact on the rest of the firmware?

char *npos = (*command == 'N') ? command : nullptr;  // Require the N parameter to start the line

if (npos) {

          bool M110 = strstr_P(command, PSTR("M110")) != nullptr;

          if (M110) {
            char* n2pos = strchr(command + 4, 'N');
            if (n2pos) npos = n2pos;
          }

          gcode_N = strtol(npos + 1, nullptr, 10);

          if (gcode_N != last_N + 1 && !M110)
            return gcode_line_error(PSTR(MSG_ERR_LINE_NO), i);

          char *apos = strrchr(command, '*');
          if (apos) {
            uint8_t checksum = 0, count = uint8_t(apos - command);
            while (count) checksum ^= command[--count];
            if (strtol(apos + 1, nullptr, 10) != checksum)
              return gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH), i);
          }
          else
            return gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM), i);

          last_N = gcode_N;
        }

Commenting out this part makes it work but then the check for matching line number is disabled.

          if (gcode_N != last_N + 1 && !M110)
            return gcode_line_error(PSTR(MSG_ERR_LINE_NO), i);

Is it possible to separate this check for the two serial ports or how does this work now?

Swesen avatar Sep 03 '19 16:09 Swesen

Unless you are using PanelDueFirmware that is several years old, PanelDue does increment the line number on each request.

Does Marlin maintain separate line numbers for the USB input channel and the extra serial port input channel? This is obviously necessary.

dc42 avatar Sep 03 '19 17:09 dc42

It does send a line number that increments, but it continues to increment with every line even if it gets no response so it never synchronises with marlin again once out of sync. And the fact that it causes problems for the USB connection(octoprint) seems to indicate that the two serial ports are treated as one

Recv: Resend: 2
Recv: ok
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv: Resend: 2
Recv: ok
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.00 /0.00 @:0 B@:0
Recv:  T:25.44 /0.00 B:25.00 /0.00 @:0 B@:0
Recv: Resend: 2
Recv: ok

Removing the line number checking in marlin solves the current problem but might cause future errors. The best solution would be to set up separate line number checking for each port.

Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0
Recv:  T:25.50 /0.00 B:25.91 /0.00 @:0 B@:0

Swesen avatar Sep 03 '19 18:09 Swesen

any news? a lot of people have asked

boelle avatar Oct 12 '19 15:10 boelle

Ive got hardware here as well now and this was discussed face to face at errf. Things are happening behind the scenes...

InsanityAutomation avatar Oct 15 '19 15:10 InsanityAutomation

@InsanityAutomation — I've rebased this onto the latest code. It's close, but the card listing needs more work because M20 is currently only supporting a full listing of the root folder, and PanelDue wants just the contents of the folder specified by the P parameter. The printListing method is simple enough that it could just be duplicated and specialized rather than taking a json boolean.

thinkyhead avatar Oct 24 '19 22:10 thinkyhead

@InsanityAutomation — I've rebased this onto the latest code. It's close, but the card listing needs more work because M20 is currently only supporting a full listing of the root folder, and PanelDue wants just the contents of the folder specified by the P parameter. The printListing method is simple enough that it could just be duplicated and specialized rather than taking a json boolean.

If Marlin only supports storing GCode files in the root, you can ignore the P parameter. Except that if PanelDue asks for the contents of /macros then I suggest you return an empty list, unless/until Marlin supports M98 and macros, so that PanelDue will display an empty macros list.

dc42 avatar Oct 25 '19 14:10 dc42

If Marlin only supports storing GCode files in the root, you can ignore the P parameter.

Thanks for the notes! Marlin supports a configurable number of directory levels. The default is 10.

thinkyhead avatar Oct 25 '19 18:10 thinkyhead

I actually implemented a general M408 functionality myself for consumption by an ESP32-CAM monitor via serial interface. Would this pull request mean that I should rather wait before submitting a pull? One issue I found is that during pause, M408 would actually not respond, but rather with the more general pause response.

eben80 avatar Dec 21 '19 08:12 eben80

@eben80 — A general M408 would be ok as a start, and we can look at what information that needs to include. The main hold-up with this PR is the M20 coding.

thinkyhead avatar Jan 03 '20 01:01 thinkyhead

Hi, what is the current status of this integration? Is there anything I can assist with?

JRHeaton avatar Jul 29 '20 06:07 JRHeaton