Commit Graph

7 Commits

Author SHA1 Message Date
Markus Hitter 7441f6b6ba Simulator: be more clear about files opened.
Before, a seemingly valid command like ...

  ./sim -o sim-log.log -t 0 testcases/triangle-odd.gcode

... would not act as expected (treat both files as G-code source)
and not give meaningful hints on what's going on either. It just
reported 'Could not stat file'. No hint that it tries to open the
intended log file as G-code source.

Now the message reporting opening of a G-code file names it as
'G-code source' and opening of the recorder file gets reported,
too. Which should give a good idea about what's going on.
2018-01-07 12:54:26 +01:00
Markus Hitter 81cffde4e9 dda_queue.c/.h: eliminate queue_empty().
This is no longer needed, because mb_tail_dda gives the same
information, just faster. Wanted side effect: better encapsulation.

No stepping performance improvement, but binary size 36 bytes
smaller:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19398 bytes      136%       64%       31%       16%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%
2016-12-06 14:16:54 +01:00
Phil Hord e5715e433b simulator: Wait for DDA to complete before exiting
When the simulator finishes processing the last gcode, it exits.  This
leaves causes us to exit without completing the last commanded move.

Rework how we handle end-of-file parsing and wait for the dda queue to
empty before exiting at the end of file processing.
2016-05-31 15:21:49 -04:00
Phil Hord 573dbfe576 Simulator: record serial data as comments, not as G-code.
We cheated before and sent the serial data in the simulator into
the G-code reporter so it could be line-buffered and then recorded
as comments in the trace-log. But this confuses the simulator
console output and is harder to manage. Revert to sending serial-out
data directly to the comment engine.

Also be less chatty about startup when connecting to a UART.
2015-07-17 16:34:20 +02: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 36747e5703 Teach simulator to process gcode files directly
The simulator runs as a device simulator complete with serial port
so it can communicate with printer software like pronterface. But
often we just want to stream it a file of gcode commands and get
some output.  Teach the simulator to take a regular file as input
and process it as a file of gcode commands if it is not a device.
2013-12-06 19:24:58 +01:00
Phil Hord 452e2e5cd9 Restore simulation build target.
This code was accidentally removed long ago in a botched merge. This
patch recovers it and makes it build again. I've done minimal testing
and some necessary cleanup. It compiles and runs, but it probably still
has a few dust bunnies here and there.

I added registers and pin definitions to simulator.h and
simulator/simulator.c which I needed to match my Gen7-based config.
Other configs or non-AVR ports will need to define more or different
registers. Some registers are 16-bits, some are 8-bit, and some are just
constant values (enums). A more clever solution would read in the
chip-specific header and produce saner definitions which covered all
GPIOs. But this commit just takes the quick and easy path to support my
own hardware.

Most of this code originated in these commits:

	commit cbf41dd4ad
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:28:08 2010 +0200

	    document simulation

	commit 3028b297f3
	Author: Stephan Walter <stephan@walter.name>
	Date:   Mon Oct 18 20:15:59 2010 +0200

	    Add simulation code: use "make sim"

Additional tweaks:

Revert va_args processing for AVR, but keep 'int' generalization
for simulation. gcc wasn't lying. The sim really aborts without this.

Remove delay(us) from simulator (obsolete).

Improve the README.sim to demonstrate working pronterface connection
to sim. Also fix the build instructions.

Appease all stock configs.

Stub out intercom and shush usb_serial when building simulator.

Pretend to be all chip-types for config appeasement.

Replace sim_timer with AVR-simulator timer:

The original sim_timer and sim_clock provided direct replacements
for timer/clock.c in the main code. But when the main code changed,
simcode did not. The main clock.c was dropped and merged into timer.c.
Also, the timer.c now has movement calculation code in it in some
cases (ACCELERATION_TEMPORAL) and it would be wrong to teach the
simulator to do the same thing. Instead, teach the simulator to
emulate the AVR Timer1 functionality, reacting to values written to
OCR1A and OCR1B timer comparison registers.

Whenever OCR1A/B are changed, the sim_setTimer function needs to be
called. It is called automatically after a timer event, so changes
within the timer ISRs do not need to bother with this.

A C++ class could make this requirement go away by noticing the
assignment. On the other hand, a chip-agnostic timer.c would help
make the main code more portable. The latter cleanup is probably
better for us in the long run.
2013-12-06 19:24:58 +01:00