daid/Cura — pull request #698 by hg42 (2014-01-13 02:10:35+00:00)
Title: fix main communication problems

I had a hard time debugging my communication problems.
Lines were sporadically mixed together and I also get errors from time to time, sometimes even crashing(?) Marlin.
I found that it's probably not caused by a hardware problem, but by Cura.

This fixes most of these:

- M105 was sent immediately, mixing with the gcode commands
=> add it to queue (use sendCommand instead of _sendCommand)

- Marlin connects immediately now (waiting also for the "start" sent by Marlin directly after serial connect)

While this fixes nearly all resends and errors, I still get 3 or 4 resends for my current test with > 40000 lines of gcode.

I don't see what is causing this:

Error:No Checksum with line number, Last Line: 8
-> 'N9M205 S0.00 T0.00 B200 XM105 T0'

I added the "->" line to Marlin's output in case of an error, so I can see, what happened with the line.
As we see M105 is truncating line 9 of the gcode after the "X".
But as it is queued, it shouldn't do that.

these are the other lines:
-> 'N7314G1 X-6.10 Y6.29 E3.73389*88'
-> 'N11947G1 X20N11948G1 X20.69 Y-6.53 E1176.09305*105'
-> 'N27638G1 X1.85 Y-6.68 E1982.59409*98'
-> 'N40066G1 X2N40067G1 X21.25 Y-6.66 E2855.36024*97'

They all come without an error message and I currently don't see where they are created in Marlin, because each "->" is preceded by an error message (because I added them to error messages).
I the error message may be swallowed by Cura, or Marlin didn't send it because of another problem.

I have to add, that all my tests run at 5000 mm/s (which is really fast, with real Marlin communication [programmer was chosen] but without power and not waiting for temperatures).
So the remaining resends may be caused by that.
But I think the communication should be robust enough to allow this.

I still wonder why Printrun doesn't show any error when printing the same gcode (saved by Cura).
Either it doesn't get errors or it doesn't show resends?

I also included some other minor improvements from my sources, mainly to see what's going on.