Commit Graph

54 Commits

Author SHA1 Message Date
Markus Hitter 77630167e7 Serial: postpone sending "ok" until a slot is free.
Previously acknoledgement was sent as soon as the command was
parsed. Accordingly, the host would send the next command and
this command would wait in the RX buffer without being parsed.

This worked reasonably, unless an incoming line of G-code was
longer than the RX buffer, in which case the line end was dropped
and parsing of the line never completed. With a 64 bytes buffer
on AVR this was rarely the case, with the 16 bytes hardware buffer
on ARM LPC1114 it happens regularly. And there's no recovering
from such a situation.

This should solve issue #52.
2015-08-04 23:03:51 +02:00
Phil Hord 503d2c75a1 Fix typos: "whether" and whitespace. 2015-07-17 16:16:42 +02:00
Markus Hitter 277de42b00 G-code parser: move gcode_source stuff ...
... from gcode_process.c/.h to gcode_parse.c/.h.
2015-07-17 13:31:10 +02:00
Markus Hitter 53dfab3be3 G-code parser: check for end of line in the parser.
This raises abstraction and even makes the binary a bit smaller
(2 bytes without SD, 14 bytes with SD).

A G-code file with 16'384 lines of comments, 64 bytes per line
( = 1 MB file size), is read and parsed from SD card in 2:47
minutes, or at a speed of 5924 bytes/second.
2015-07-10 14:19:48 +02:00
Markus Hitter 5a0f7a0e72 G-code parser: anything but a number ends a field.
This should make the parser a bit more robust and also saves
6 bytes binary size.
2015-07-05 23:32:48 +02:00
Markus Hitter c6916e2a5b G-code parser: an asterisk always ends all fields.
This solves lines like these, with previous answer:

  M23 bla*3
  ok E: Bad M-code 233
  M23 123*92
  ok E: Bad M-code 88

It should also solve lines with ;-comment _and_ a checksum.
2015-07-05 23:32:48 +02:00
Markus Hitter 49345782f6 G-code parser: make space a field delimiter.
This is neccessary to allow file names with leading digits. It's
still possible to send commands like M105 with spaces in between
("M1 05") and also to put space between character and number, like
"X 15.0".
2015-07-05 23:32:48 +02:00
Michael Moon 983bcfdd46 SD card: initial shoehorning of SD code, part 2.
Part 2 is to implement M23: select file. That's more than just a
few lines, as we also have to teach the gcode-parser to collect
strings.

For now the file is simply tested for successful opening, no
actual printing, yet.

About build size: during development there was another
implementation, which didn't abstract SD card functions into
sd.c/.h, but put them into gcode_process.c directly. At the
feature completeness of this commit, the other implementation
used 70 bytes flash less, but also 23 bytes more RAM. So I decided
for the more abstracted/encapsulated version. --Traumflug

Also, this adds 14 bytes binary size even without SD card support.
A lot more #ifdefs around each use of next_target.read_string
would remove this, but after all we do care a bit about
readability of the source code, so let's sacrify these 14 bytes
to it. --Traumflug
2015-07-05 23:32:48 +02:00
David Forrest 6820e2cc0a gcode_parse.c: fix E debugging message.
This should complete issue #87.
2015-06-06 12:04:36 +02:00
konoppo a0125dedfc gcode_parse.c: don't assume G1 on pure M- or T-codes.
Offending code were lines like these from Repetier Host:

  N8965 M117 ETE 29m 10s *86

When firmware received not-G command (M-command or T-command) with X, Y,
Z, E or F coordinate, it will "change" this command to G1.
Now, firmware do change only if received line is not either G- or M-
or T-command.

Examples:
X10 - is changed to G1 X10
E20 F300 - is changed to G1 E20 F300
M117 E1 - is NOT changed to G1 E1

This commit costs 6 bytes binary size.
2015-01-06 16:28:51 +01:00
David Forrest 003697ee0f gcode_parse.c: Debug S with serwrite_int32. 2014-08-31 19:07:30 +02:00
Phil Hord d3f49b3e95 DDA: Convert TARGET axis vars to array.
In preparation for more efficient and scalable code using axis-loops
for common operations, add two new array-types for signed and unsigned
32-bit values per axis. Make the TARGET type use this array instead of
its current X, Y, Z, and E variables.

Traumflug notes:

- Did the usual conversion to spaces for changed lines.

- Added X = 0 to the enum. Just for peace of mind.

- Excellent patch!

Initially I wanted to make the new array an anonymous union with the
old variables to allow accessing values both ways. This way it would
have been possible to do the transition in smaller pieces. But as
the patch worked so flawlessly and binary size is precisely the
same, I abandoned this idea. Maybe it's a good idea in other areas.
2014-08-31 19:03:17 +02:00
Phil Hord c7150445af Zungmann's fixes to compile simulator on Mac OS X, part 2.
Here: .bss section syntax is different.
2014-03-04 19:57:48 +01:00
Markus Hitter ec9e84a068 gcode_parse.c: assume G1 only for stuff which might actually move.
Previously, even comments were run through dda_create(), quite a waste
of time.
2013-12-06 19:24:58 +01:00
Phil Hord cfa4857550 simulator: cmdline switches for output options
Teach simulator several command line options to control console output
of info messages, gcode traces, data_recorder output, etc.

Also move gcode output to sim_gcode instead of sending directly to
datarecorder.
2013-12-06 19:24:58 +01:00
Phil Hord 2b8a5d3b5a simulator: record g-codes in datalog
Add comment stream to datalog output so we can store g-codes and
other events that occur during simulation.
2013-12-06 19:24:58 +01:00
Markus Hitter 63d3f012a8 gcode_parse.c: process incoming digits earlier.
Idea and patch from ItsDrone, see
http://forums.reprap.org/read.php?146,174364,174550#msg-174550

Thanks, ItsDrone.
2013-03-24 16:17:02 +01:00
Markus Hitter 931d81af58 gcode_parse.c: checksum the characters actually received.
Wow! It took something like two years to expose (and get
developer attention of) such a bug: the checksum was calculated
based on the uppercased characters parsed, not the ones actually
received over the line.
2012-08-16 23:43:21 +02:00
Markus Hitter 50adc11392 gcode_parse.c: drop an obsolete comment. 2012-05-11 13:51:06 +02:00
Markus Hitter 4c84b31536 gcode_parse.c, decfloat_to_int(): use a smaller variable.
This saves 78 bytes and likely some processing time.
2012-05-11 13:51:01 +02:00
Markus Hitter 5a9a134ae4 gcode_parse.c: review decfloat_to_int() yet again.
This time, raise range at the cost of some precision for the
newly explored areas.
2012-05-11 13:50:57 +02:00
Markus Hitter eaf6c453be Introduce gcode_init() and honor E_ABSOLUTE as the default. 2012-05-11 13:50:51 +02:00
Markus Hitter 9dda3349be Revert the new relative handling for X, Y and Z.
These were commits 9dbfa7217e0de8b140846ab480d6b4a7fc9b6791 and
2b596cb05e621ed822071486f812eb334328267a.

There are several reasons why this new approach didn't work out well:

- The machine coordinate system is lost on relative movements.
  OK, we could keep tracking it, but this would mean even more
  code, so even more chances for bugs.

- With the lost coordinate system, no software endstops are possible.

- Neither of X, Y, Z will ever overflow.

- If a movement planner would appear one day, he'd have to handle
  relative movements as well. Even more code duplication.
2012-05-11 13:50:47 +02:00
Markus Hitter 5f9ae5b087 Implement M82/M83 and handle relative movements entirely different.
Instead of converting them to absolute first, then back to
relative and having all the fuzz with working on the queue's
start vs. working at the queue's end, mark a movement as relative
and use this directly.
2012-05-11 13:50:33 +02:00
Markus Hitter 34ab76fe6e gcode_parse.c: review decfloat_to_int() again.
Finally, significant simplifications worked out while
keeping micrometer accuracy for up to 4290 mm.
2012-05-11 13:50:26 +02:00
Markus Hitter 4e5f51f01e Store distances in the TARGET strucure in micrometers for all axes.
This extends the previous commit from X to Y, Z and E.
2011-11-17 13:48:36 +01:00
Markus Hitter c96ea0c773 Store distances in the TARGET structure always in micrometers.
This is a intrusive patch and for now, it's done for the X axis only.
To make comparison with the former approach easier ...

The advantages of this change:

- Converting from mm to steps in gcode_parse.c and back in dda.c
  wastes cycles and accuracy.

- In dda.c, UM_PER_STEP simply goes away, so distance calculations
  work now with STEPS_PER_MM > 500 just fine. 1/16 microstepping
  on threaded rods (Z axis) becomes possible.

- Distance calculations (feedrate, acceleration, ...) become much
  simpler.

- A wide range of STEPS_PER_M can now be handled at reasonable
  (4 decimal digit) accuracy with a simple macro. Formerly,
  we were limited to 500 steps/mm, now we can do 4'096 steps/mm
  and could easily raise this another digit.

Disadvantages:

- STEPS_PER_MM is gone in config.h, using STEPS_PER_M is required,
  because the preprocessor refuses to compare numbers with decimal
  points in them.

- The DDA has to store the position in steps anyways to avoid
  rounding errors.
2011-11-17 13:48:26 +01:00
Jim McGee 85a9f63dfb Pretest DEBUG_X constants for non-zero and && the test with all existing
& tests of the debug_flags. Currently the compiler is able to eliminate
the block and the & operation when the constant is zero, but since
the debug_flags variable is a volatile the compiler does not eliminate
the load of the variable. By pretesting and shortcutting the load is
eliminated. Saves a small number of bytes when the debug build is
disabled and costs nothing when it is enabled.
2011-05-15 09:56:33 +10:00
Ben Jackson f8d8b2a471 gcode_parse.c: Send newline as char rather than PSTR 2011-05-08 00:37:03 +10:00
Markus Hitter ee481864fa gcode_parse.c: get rid of the denominator variable in decfloat_to_int().
This allows for better optimisation and saves 100 bytes binary size
accordingly. For denominator = 1, the algorithm is also significantly
simpler.
2011-04-15 02:12:13 +02:00
Markus Hitter 6896aa5236 gcode_parse.c: join the upper and the lower formula in decfloat_to_int().
This also makes rounding more accurate with exponent > 0.
Saves another 40 bytes binary size.
2011-04-15 02:12:10 +02:00
Markus Hitter 8cf8a8a44a gcode_parse.c: get rid of rounding[].
This saves 8 bytes of flash and, more important, 16 bytes of RAM.
2011-04-15 02:12:07 +02:00
Markus Hitter f41dd9c098 gcode_parse.c: make all usages of decfloat_to_int()...
... to divide either by 1 or 1000. Accordingly, a flag
can be used instead of the actual value, shrinking code
size by 70 bytes.
2011-04-15 02:12:02 +02:00
Michael Moon ae33cb7fa2 start implementing absolute E support 2011-04-09 09:16:05 +10:00
Michael Moon 0dc7d77885 Massive Doxygen documentation addition
'make doc' then point your browser at doc/html/

Needs plenty of cleanup and polishing, but the main bulk is here

even documents your configuration! ;)
2011-03-22 01:34:36 +11:00
Markus Hitter 03b52e0340 gcode_parse.c: don't double-initialize last_field or read_digit.
Saves 64 bytes binary size.
2011-03-06 23:30:15 +01:00
Michael Moon c177756913 don't mess up return data stream if numbers have too much precision 2011-03-05 15:54:36 +11:00
Markus Hitter 5c0dde4e14 Changed M110 to match the description in the RepRap Wiki. 2011-03-03 09:40:55 +01:00
Markus Hitter bdeb4827fc gcode_parse.c: replace some ints by uints to double the range.
This is without accuracy or other losses and should finally make
decfloat_to_int() free of variable overflow within the decribed
ranges. Surprisingly, this costs 14 bytes program size.
2011-02-27 11:51:19 +01:00
Markus Hitter f985de8a54 gcode_parse.c: make decfloat_to_int handle all uints.
This saves 10 bytes of binary size and possible headaches (negative factors).
2011-02-25 11:54:22 +01:00
Markus Hitter 758893c275 gcode_parse.c: ditch ASTERISK_IN_CHECKSUM_INCLUDED. 2011-02-25 11:49:51 +01:00
Markus Hitter 2c53dbe2a8 gcode_parse: limit decimal ranges by decfloat_to_int()'s demands.
Formerly, it was limited by variable bit ranges, which allowed
more than decfloat_to_int() can swallow.
2011-02-23 02:52:51 +01:00
Markus Hitter 0dc623d4eb gcode_parse.c: added comments, which show possible variable overflows.
Stay tuned, the fix is just around the corner.
2011-02-23 02:52:27 +01:00
Michael Moon 72adba5a58 apparently repg expects N preceding line numbers in resend requests 2011-02-19 13:09:21 +11:00
Michael Moon d06a365f54 G4 uses millisecond units now apparently, instead of seconds 2011-02-17 14:05:13 +11:00
Markus Amsler 3aa7fc83e4 M140: S value is a temperature 2011-02-15 13:21:45 +11:00
Michael Moon 79674da51b try to make E behave 2011-02-12 22:20:18 +11:00
Stephan Walter 4febbea2f8 fix decfloat_to_int, Less divisions in decfloat_to_int.
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-01-11 19:20:17 +11:00
Michael Moon 1fa0036008 fix arithmetic error 2011-01-10 10:15:42 +11:00
Markus Hitter 719a9d32b5 gcode_parse.c: Limit the digits right of the decimal.
Previously, variables in decfloat_to_int() could overflow due to
excess precision, like Z2.0000000.
2011-01-08 12:15:13 +11:00