Commit Graph

1181 Commits

Author SHA1 Message Date
Markus Hitter a07e5a7d1e Configtool: don't try to parse help text in the loaded file.
This shouldn't change functionality and is for more robustness.
2015-07-17 13:37:48 +02:00
Markus Hitter a48d9edf67 Configtool: let the parsing method decide about values.
Shouldn't cause functional change.

So far, values commented out are still ignored, which is why the
used regexp changed. This will hopefully change in the future,
so a configuration can remember disabled values, too.
2015-07-17 13:37:42 +02:00
Markus Hitter d9e4cd1086 Configtool: let the parsing method decide what a name is.
This is mostly for code robustness.
2015-07-17 13:37:34 +02:00
Markus Hitter e7395c8dd8 Configtool: there are no simple comments in printer.metadata.
Accordingly, don't try to parse them. If they ever appear, they
need handling.
2015-07-17 13:37:26 +02:00
Markus Hitter eeee384ed6 Configtool: let the parsing method decide what a candidate is.
This is mostly for code robustness.
2015-07-17 13:37:18 +02:00
Markus Hitter 7acbf30e22 Configtool: ignore value options in board.metadata.
This solves the problem of choice menus being populated with too
many entries. Before, such menus would pick up values from
board.metadata as well as from the actually loaded file.

File printer.metadata contains no options, so no adjustment
needed there.
2015-07-17 13:37:11 +02:00
Markus Hitter 25c502d68b Configtool: save target candidate pins, not the metadata ones.
Previously, all the cancicates were replaced with the ones from
board.metadata, messing things up. Appears to work fine now,
candidates are preserved.
2015-07-17 13:37:04 +02:00
Markus Hitter 6b866e8c85 Configtool: get values back into config/*.metadata.
This has to work, else we can't provide default values for new
items.

Now loading a RAMPS board and just saving it results in an
identical file. Very well. Not so for other boards, because
disabled values still get lost.
2015-07-17 13:36:56 +02:00
jbernardis fb922735fd Configtool: process a metadata file before reading header files.
This should allow for easier addition of defines as Teacup evolves.
2015-07-17 13:36:48 +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 017e17801c SD card: move parsing closer to the metal.
This means a custom function in pff_diskio.c, disk_parsep(),
which replaces disk_readp(). Now it no longer reads a whole
sector for every single byte, but only once per line of G-code.

Performance is now much better than with buffered reading, the
1 MB file with 16'468 lines of comments, 64 bytes per line,
read and parses now in just 46 seconds, which means 358 lines
or 22'795 bytes per second.

Unfortunately all the binary size loss is gone compared to the
previous version, we're 68 bytes bigger than before buffer-less
parsing. Reason is the new function disk_parsep() in
pff_diskio.h. RAM usage is still low.

               ATmega...     '168   '328(P)   '644(P)     '1280
   FLASH:   22276 bytes   155.39%    72.51%    35.09%    17.27%
     RAM:    1331 bytes   129.98%    64.99%    32.50%    16.25%
  EEPROM:      32 bytes     3.12%     1.56%     1.56%     0.78%
2015-07-17 13:31:03 +02:00
Markus Hitter 75df5e3a0a SD card: don't read into a buffer, parse directly instead.
Formerly we took efforts to read only small chunks into a
(small) buffer, just to read this buffer byte by byte yet
again for parsing. It's more efficient and requires less
code to parse the character at read time directly. This
way we can read in chunks of exactly one line, making the
buffer obsolete.

First step is to implement this in mendel.c and in sd.c/.h.
This gets rid of the buffer already.

Very inefficient in pff.c and pff_diskio.c so far, more
than 40 minutes / less than 500 bytes/s for reading this
1 MB comments file. Reason is, for every single byte a
whole sector is read. Nevertheless, this attempt appears
to be on the right track.

Binary is 156 bytes smaller, 16 bytes less RAM:
               ATmega...     '168   '328(P)   '644(P)     '1280
   FLASH:   22052 bytes   153.82%    71.78%    34.73%    17.09%
     RAM:    1331 bytes   129.98%    64.99%    32.50%    16.25%
  EEPROM:      32 bytes     3.12%     1.56%     1.56%     0.78%
2015-07-17 13:30:55 +02:00
Phil Hord 3520f54db7 Makefile-example: add shortcut targets.
Add shortcuts to Makefile-example for regressiontests and program
so it can more easily be used as-is.

Remove the comment suggesting to use Makefile-AVR directly instead
since it is no longer more convenient, at least for the original
reason.
2015-07-17 13:29:22 +02:00
Phil Hord a3e956e70b Regressiontests: give SIM a "standard" config.
We should not fail the regression test if the user's config is
missing or misconfigured.

Also turn on -Werror for simulator validation, too. This might be
a bit presumptuous since we are dependent on the user's installed
gcc instance; but we already depending on him to be able to build
the simulator at all, so this doesn't seem to be too much of a
stretch.
2015-07-17 13:27:25 +02:00
Markus Hitter 6c7133792e Configtool: be helpful when trying to overwrite protected files. 2015-07-14 17:00:46 +02:00
Markus Hitter a8ab755f31 simulator.h: provide a minimalistic SPI fake.
This mostly means: there is no SPI simulator, so don't build
support for it. This was found by running the new regression tests.
2015-07-13 14:02:39 +02:00
Markus Hitter c42ccfff38 mendel.c: when to include simulator.h matters.
This partially fixes building the simulator. It was found by
running the new regression tests.
2015-07-13 14:02:39 +02:00
Markus Hitter 5489ddccab heater.c: set up timer 2 only when present.
This was found by running the new regression tests. ...and seeing
that this is pretty old code, I wonder how Teacup could ever
compile for the Teensy2 guys.
2015-07-13 14:02:24 +02:00
Markus Hitter df451d72fd mendel.c: set SIMINFO serial port only when BAUD is available.
This was found by running the new regression tests.
2015-07-13 14:01:27 +02:00
Markus Hitter 1eb7e73273 Introduce regression tests.
For now this is just a number of different configurations and a
makefile target, "make regressiontests", to build with them.
Further tests, e.g. using SimulAVR or the hostside simulator
to check actual behaviour of the firmware are welcome.
2015-07-13 14:00:33 +02:00
Markus Hitter bf3dd74f54 Configtool: also try toolpaths in more recent OS Xs.
This should address one part of issue #165.
2015-07-13 10:59:01 +02:00
Markus Hitter a57ce1f046 Configtool: add nanoheart configuration to protected files list.
This was forgotten when adding this configuration.
2015-07-10 14:25:10 +02:00
Ruslan Popov aa401650a7 Configtool: add SD card select pin support.
For now on the general pinout page, may be moved to a separate tab
together with display stuff later. --Traumflug
2015-07-10 14:25: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 cb1b9b3feb SD card: measures sizes and additionally enable FAT32 support.
FAT12 was not choosen, because it's virtually no longer in use
(allows volume sizes up to 32 MB, only) and would increase
binary size by another 248 bytes.

Measured sizes are in a comment in pff_conf.h, where one can also
enable or disable support for these variants.
2015-07-07 19:07:37 +02:00
Markus Hitter 23be2d1449 SD card: finally(!) implement printing from SD card.
Turned out to be pretty easy with all the more complex bits
already in place.

Strategy is to always parse a full line from one of the sources.
Accordingly, simply sending a character on the serial line stops
reading from SD until the line coming in over serial is completed.
2015-07-07 19:07:35 +02:00
Markus Hitter c7b134bc65 SD card: change demo code for performance measurement.
As we're around here, lets see how fast this implementation is.
All measurements are raw reading performance, without actual
parsing of the G-code.

With SPI_2X disabled (see line 8 in spi.h), performance is
195 seconds per megabyte, equivalent to about 50'000 baud.

With SPI_2X enabled, performance is 159 seconds per megabyte,
or 60'000 baud.

Still, SPI_2X is left disabled to increase reliability. Reading
from SD is faster by design, because there is no checksumming and
also no waiting for the "ok" to be sent back. In case reading
G-code from SD ever becomes a bottleneck, there are even more
opportunities in addition to enabling SPI_2X, like making sdbuffer
bigger, like micro-optimizing spi_rw() and similar stuff.
2015-07-07 14:36:46 +02:00
Markus Hitter d3f548a895 SD card: actually read the characters from the file.
Next to the implementation of sd_read_byte() as well as M24 and
M25, yet another demo: read the file and write it to the serial
line, to show correctness of the implementation.
2015-07-07 14:36:44 +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
Markus Hitter bf6fd141c0 G-code parser: add a number of test strings.
We're about to change substantial parts of the parser, so we need
to verify it doesn't become messed up.
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
Michael Moon 8f2e1e59ac SD card: initial shoehorning of SD code, part 1.
Part 1 is, implement

 - M20: List SD card.
 - M21: Initialize SD card (has to be done before listing).
 - M22: Release SD card.

Do all this in one chunk, splitting this up wouldn't allow to test
the result.
2015-07-05 23:32:48 +02:00
Markus Hitter 03e720d2ac pff.c/.h: add pf_unmount().
It's not mandatory to unmount cards, just make sure subsequent
card operations fail.
2015-07-05 23:32:48 +02:00
Markus Hitter bf1fa5f269 SD card: add a note about a possible performance optimisation. 2015-07-05 23:32:48 +02:00
Markus Hitter 30ce8eb1b4 SD card: remove the demonstration code.
We're about to do some real stuff ...
2015-07-05 23:32:48 +02:00
Markus Hitter 7762408d5c SD card, pff.c: silence a warning.
Let the preprocessor decide wether this piece of code is compiled
at all. Previous behaviour was to compile it unconditionally and
rely on the optimizer to remove it after that. Trusting the
optimizer is fine, but only if the code is warning-free in all cases.
2015-07-05 23:32:48 +02:00
Markus Hitter 9de0c65460 SD card: add the layer between hardware and Petit FatFs.
This is all the commands to read from and write to SPI,
initializing the card, read in blocks and so on. This should
make Petit FatFs actually usable.

So far read-only and no M-codes to let end users play with
this stuff.

The demonstration code was changed to list the SD card's
top level directory over and over again.
2015-07-05 23:32:48 +02:00
Markus Hitter fe9ef63225 SD card: store sample code for the hardware layer.
Fetched from http://elm-chan.org/fsw/ff/00index_p.html.

There is also sample code for the bigger brother, FatFs, here:
http://elm-chan.org/fsw/ff/00index_e.html. These FatFs examples
are bigger (600 lines of code vs. 260 lines), but are also
for a lot more platforms available.
2015-07-05 23:32:48 +02:00
Markus Hitter 0a013d6e5e SD card: wrap Petit FatFs code in #ifdef SD.
No need to compile this when not needed and also make sure it's
nowhere used with SD card support disabled.
2015-07-05 23:32:48 +02:00
Markus Hitter 846d575aee SD card: add Petit FatFs to Teacup Firmware.
Some modifications to avoid file name conflicts with other parts and
make it compile. As the glue code to the hardware (spi.c/.h) is
still missing, there are a few warnings, of course.

Changes to this library are tracked in pff.c.
2015-07-05 23:32:48 +02:00
Markus Hitter a9aa690cb3 SD card: store Petit FatFs original sources.
Fetched from http://elm-chan.org/fsw/ff/00index_p.html, version R0.03.

Storing original code separately shall ease diff'ing them when a
new release comes out.
2015-07-05 23:32:48 +02:00
Markus Hitter 63c4dbaea9 mendel.c: do module enabling differently.
Same result, but 8 bytes less binary size. With SD card disabled,
binary size is now the same as before getting SPI running.
2015-07-05 23:32:48 +02:00
Markus Hitter 1fb3ece31e SD card: establish spi.c/.h and sd.c/.h and get SPI running.
For now this is just a nice demonstration on how to send bytes
over SPI. Add SD_CARD_SELECT_PIN to your configuration board
file manually to see data signals on MOSI dancing on the scope.

The TODO's about SS in arduino*.h were wrong, SS does have a
chip-specific special meaning (used in SPI multi-master or SPI
slave mode). Still, a #define MAX6675_SELECT_PIN is missing.

Squashed in this commit from the SPI development topic branch to
get this first step working:

Author: jbernardis <jeff.bernardis@gmail.com>
2015-02-04 22:35:07
mendel.c: disable SPI in power management only when not needed.

If we want to talk to a SD card connected to SPI, we need SPI
powered, of course.

From Traumflug: nice catch, Jeff!
2015-07-05 23:32:46 +02:00
Markus Hitter b4145e683a Configtool: work around a URL-open bug on some Linuxes.
Not exactly ideal, but the best I could find so far.

This is work related to issue #159.
2015-07-01 16:42:38 +02:00
Markus Hitter 80626eb528 Configtool: Add "Report problem" function.
The idea is to open the user's email client automatically, so
(s)he has not much more to do than to write a sentence about what
went wrong. As easy as possible!

This is work related to issue #159.
2015-07-01 16:42:36 +02:00
Ruslan Popov a13e00893d Add support for the NanoHeart board.
See http://blog.securelayer.ru/doku.php/reprap/electronics/nanoheart
2015-07-01 11:39:36 +02:00
Markus Hitter 113b23ca2c Configtool: add "About Teacup" function.
It's a nice thank you and listing of the top 10 contributors.

This is work related to issue #159.
2015-06-10 13:56:39 +02:00
Markus Hitter 652b129b20 Configtool: add help menu.
This is "Help", "Report problem" and "About Teacup". Functionality
behind the latter two forthcoming.

This is work related to issue #159.
2015-06-10 13:56:39 +02:00