-
Notifications
You must be signed in to change notification settings - Fork 296
Developer Notes
This page contains topics relevant to development - exclusive of the toolchains. See the dedicated pages for setting up projects on different platforms for that information
###Main Loop and Continuations - Adding New Tasks This topic discusses how to add tasks to the main loop.
The controller_run() / _controller_HSM loop in controller.cpp is the main "throttle" that regulates how fast the system can operate - i.e. how fast does the code run through the loop, and therefore at what rate the system can ingest new Gcode blocks. So you don't want to inject any latency that can be avoided.
Read the header notes for controller_run() in controller.cpp first.
New tasks can be added as callbacks inserted into the main loop. Any task that is added to the main loop must behave properly. That is:
- Return as fast as you can (preferably STAT_NOOP) if you have nothing to do
- Return STAT_OK if that task's end state would not block subsequent tasks from executing
- Return STAT_EAGAIN if that task's end state should prevent lower priority tasks from executing. Eagain will force the main loop to start over from the top.
- A callback should generally not take more than +/- 2 milliseconds to execute (ideally less), and must not block internally. If it encounters a blocking condition if you return control to the main loop, possibly with STAT_EAGAIN if lower-priority tasks are dependent on its completion.
Write tasks as co-routines with an entry point to initiate the task, and a continuation installed as a callback to continue the task. A singleton structure can be used to keep state between initiation and repeated calls to the continuation. See plan_arc.cpp, cm_arc_feed() and cm_arc_callback() for a good example of an entry function and a continuation.
Getting Started Pages
- Home
- What is g2core?
- Who uses g2core?
- Jerk-Controlled Motion
- Getting Started with g2core
- Connecting to g2core
- Configuring g2core
- Flashing g2core
- Troubleshooting
Reference Pages
- Gcodes
- Mcodes
- Text Mode
- JSON Communications
- GPIO Digital IO
- Alarms & Exceptions
- Power Management
- Coordinate Systems
- Status Reports
- Status Codes
- G2 Communications
- Tool Offsets and Selection
- Probing
- Feedhold, Resume, Job Kill
- Marlin Compatibility
- 9 Axis UVW Operation
- gQuintic Specs
Discussion Topics
- Roadmap
- GPIO for 1.X Releases
- Toolheads
- Raster Streaming Prototol
- g2core REST Interface
- Gcode Parsing
- G2 3DP Dialect
- Consensus Gcode
- Digital DRO
- Overview of Motion Processing
Developer Pages
- Development & Contribution
- Branching and Release - DRAFT
- Getting Started with g2core Development
- Project Structure & Motate
- Compiling G2
- OSX w/Xcode
- OSX/Linux Command Line
- Windows10 w/AtmelStudio7
- Debugging G2 on OSX
- Board and Machine Profiles
- Arduino Due Pinout
- Arduino DUE External Interfaces
- Diagnostics
- Debugging w/Motate Pins
- Development Troubleshooting
- g2core Communications
- Git Procedures
- Windows 10 / VMware 8 Issues
- Dual Endpoint USB Internals
- G2core License
- VSCode Setup
- Compatibility Axioms
- Wiki History