Skip to content

Commit

Permalink
Merge pull request #960 from bdring/Devt
Browse files Browse the repository at this point in the history
Devt
  • Loading branch information
bdring authored Jul 12, 2023
2 parents 98c776c + 4704b8c commit eba3f81
Show file tree
Hide file tree
Showing 57 changed files with 1,057 additions and 819 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: FluidNC Continuous Integration
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
pio_env:
- noradio
- wifi
- bt
# - wifibt
# - debug
pio_env_variant:
- ""
# - "_s2"
# - "_s3"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: platformio-${{ runner.os }}
- name: Build target ${{ matrix.pio_env }}${{ matrix.pio_env_variant }}
run: pio run -e ${{ matrix.pio_env }}${{ matrix.pio_env_variant }}

tests:
strategy:
matrix:
include:
- os: ubuntu-latest
pio_env: tests
- os: macos-latest
pio_env: tests
- os: windows-latest
pio_env: tests_nosan
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# Windows has issues running gtest code with the included gcc, so install
# MSYS2 and use that instead (remember to add it to the path)
- if: matrix.os == 'windows-latest'
name: Install MSYS2 (Windows)
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
location: D:\
install: mingw-w64-ucrt-x86_64-gcc
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: platformio-${{ runner.os }}

# Separate run task for Windows, since it has issues with the included gcc
- if: matrix.os == 'windows-latest'
name: Run tests (Windows)
run: |
$env:PATH = "D:\msys64\mingw64\bin;D:\msys64\usr\bin;D:\msys64\ucrt64\bin;" + $env:PATH
pio test -e ${{ matrix.pio_env }} -vv
- if: matrix.os != 'windows-latest'
name: Run tests
run: pio test -e ${{ matrix.pio_env }} -vv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ build/
dist/
*.cppx
*.hx
/compile_commands.json
Binary file modified FluidNC/data/index.html.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions FluidNC/include/Driver/delay_usecs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <cstdint>

extern uint32_t ticks_per_us;

void timing_init();
void spinUntil(int32_t endTicks);
void delay_us(int32_t us);
Expand Down
20 changes: 15 additions & 5 deletions FluidNC/src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,30 @@ uint32_t Channel::setReportInterval(uint32_t ms) {
_lastTool = 255; // Force GCodeState report
return actual;
}
static bool motionState() {
return sys.state == State::Cycle || sys.state == State::Homing || sys.state == State::Jog;
}

void Channel::autoReportGCodeState() {
// When moving, we suppress $G reports in which the only change is the motion mode
// (e.g. G0/G1/G2/G3 changes) because rapid-fire motion mode changes are fairly common.
// We would rather not issue a $G report after every GCode line.
// Similarly, F and S values can change rapidly, especially in laser programs.
// F and S values are also reported in ? status reports, so they will show up
// at the chosen periodic rate there.
if (motionState()) {
// Force the compare to succeed if the only change is the motion mode
_lastModal.motion = gc_state.modal.motion;
}
if (memcmp(&_lastModal, &gc_state.modal, sizeof(_lastModal)) || _lastTool != gc_state.tool ||
_lastSpindleSpeed != gc_state.spindle_speed || _lastFeedRate != gc_state.feed_rate) {
(!motionState() && (_lastSpindleSpeed != gc_state.spindle_speed || _lastFeedRate != gc_state.feed_rate))) {
report_gcode_modes(*this);
memcpy(&_lastModal, &gc_state.modal, sizeof(_lastModal));
_lastTool = gc_state.tool;
_lastSpindleSpeed = gc_state.spindle_speed;
_lastFeedRate = gc_state.feed_rate;
}
}
static bool motionState() {
return sys.state == State::Cycle || sys.state == State::Homing || sys.state == State::Jog;
}

void Channel::autoReport() {
if (_reportInterval) {
auto limitState = limits_get_state();
Expand Down
14 changes: 8 additions & 6 deletions FluidNC/src/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class Channel : public Stream {
// a reception buffer, even if the system is busy. Channels that can handle external
// input via an interrupt or other background mechanism should override it to return
// the remaining space that mechanism has available.
virtual int rx_buffer_available() { return 0; };
// The queue can handle more than 256 characters but we don't want it to get too
// large, so we report a limited size.
virtual int rx_buffer_available() { return std::max(0, 256 - int(_queue.size())); }

// flushRx() discards any characters that have already been received. It is used
// after a reset, so that anything already sent will not be processed.
Expand Down Expand Up @@ -100,10 +102,10 @@ class Channel : public Stream {

int peek() override { return -1; }
int read() override { return -1; }
int available() override { return 0; }
int available() override { return _queue.size(); }

uint32_t setReportInterval(uint32_t ms);
uint32_t getReportInterval() { return _reportInterval; }
void autoReport();
void autoReportGCodeState();
uint32_t setReportInterval(uint32_t ms);
uint32_t getReportInterval() { return _reportInterval; }
virtual void autoReport();
void autoReportGCodeState();
};
2 changes: 1 addition & 1 deletion FluidNC/src/Configuration/Completer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int num_initial_matches(char* key, int keylen, int matchnum, char* matchname) {
nfound = completer._numMatches;
} else {
// Match NVS settings
for (Setting* s = Setting::List; s; s = s->next()) {
for (Setting* s : Setting::List) {
if (isInitialSubstringCI(key, s->getName())) {
if (matchname && nfound == matchnum) {
strcpy(matchname, s->getName());
Expand Down
10 changes: 5 additions & 5 deletions FluidNC/src/Configuration/ParseException.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

namespace Configuration {
class ParseException {
int line_;
std::string description_;
int _linenum;
std::string _description;

public:
ParseException() = default;
ParseException(const ParseException&) = default;

ParseException(int line, const char* description) : line_(line), description_(description) {}
ParseException(int linenum, const char* description) : _linenum(linenum), _description(description) {}

inline int LineNumber() const { return line_; }
inline const std::string& What() const { return description_; }
inline int LineNumber() const { return _linenum; }
inline const std::string& What() const { return _description; }
};
}
Loading

0 comments on commit eba3f81

Please sign in to comment.