Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build and test

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Unit tests (model layer, no hardware)
run: test/run_host_tests.sh
- name: Desktop simulator builds (UI and model layers stay portable)
run: |
sudo apt-get update -q
sudo apt-get install -y -q libsdl2-dev
make -C sim deps
make -C sim -j"$(nproc)"

firmware:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # FW_TAG is the short hash of HEAD
- uses: actions/cache@v4
with:
path: ~/.platformio
key: pio-${{ hashFiles('platformio.ini') }}
- name: Install PlatformIO
run: pip install platformio
- name: Panel firmware builds
run: pio run -e crowadv
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ sim/cncsim

# Vendor STEP (40 MB), mockup only - see cad/lean_to.py
cad/ref/

# Host test deps and binaries (test/run_host_tests.sh)
test/.deps/
test/.build/
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ lib_deps =
platform = native
; PlatformIO does not build src/ into test binaries unless told to.
test_build_src = yes
build_src_filter = +<model/gcode_stats.cpp> +<model/offsets.cpp> +<model/console_log.cpp> +<model/fnc_codes.cpp> +<transport/xmodem_rx.cpp> +<model/vibration.cpp> +<model/screensaver.cpp> +<model/calibration.cpp> +<model/sendq.cpp> +<model/caps.cpp> +<model/fnc_settings.cpp> +<model/filelist.cpp> +<model/homed.cpp> +<model/motors.cpp> +<model/toolchange.cpp>
build_src_filter = +<model/gcode_stats.cpp> +<model/offsets.cpp> +<model/console_log.cpp> +<model/fnc_codes.cpp> +<transport/xmodem_rx.cpp> +<model/vibration.cpp> +<model/screensaver.cpp> +<model/calibration.cpp> +<model/sendq.cpp> +<model/caps.cpp> +<model/fnc_settings.cpp> +<model/filelist.cpp> +<model/homed.cpp> +<model/motors.cpp> +<model/toolchange.cpp> +<model/linkwatch.cpp>
build_flags =
-std=gnu++17
-DUNIT_TEST
Expand Down
15 changes: 1 addition & 14 deletions sim/src/sim_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ static const char* PAGE_NAMES[PAGE_COUNT] = {
static void ui_tick_cb(lv_timer_t*) { shell_tick(); }
static void touch_tick_cb(lv_timer_t*) { touch_poll(); }

static bool s_primed = false;

static void prime_link_if_up() {
if (s_primed) return;
if (state == Disconnected) return;
s_primed = true;
caps_request_config();
send_line("$#");
filelist_request();
fncset_request_all();
Serial.println("link up: primed config, offsets, file list and settings");
}

static void link_watchdog() {
static uint32_t next_log = 0;
uint32_t now = millis();
Expand Down Expand Up @@ -162,7 +149,7 @@ int main(int argc, char** argv) {
}
send_pump();
imu_poll();
prime_link_if_up();
link_service();
link_watchdog();
service_action();
lv_timer_handler();
Expand Down
4 changes: 4 additions & 0 deletions sim/src/sim_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ void sd_set_root(const char* root) {
if (root && *root) { strncpy(s_root, root, sizeof(s_root) - 1); s_root[sizeof(s_root) - 1] = 0; }
}

// Built like the firmware: without HAS_SD_CARD, hw/sdcard.h supplies inline
// no-card stubs and these would redefine them.
#ifdef HAS_SD_CARD
bool sd_begin() {
struct stat st;
return stat(s_root, &st) == 0 && S_ISDIR(st.st_mode);
Expand All @@ -47,3 +50,4 @@ size_t sd_read(uint8_t* dst, size_t max) {
void sd_close() {
if (s_fp) { fclose(s_fp); s_fp = nullptr; }
}
#endif
39 changes: 2 additions & 37 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ void setup() {
lv_timer_handler();
}

// The work offsets and file list are primed once, the first time the link is
// actually alive. Doing it at boot would either block (see above) or be sent
// into the void and never retried.
static bool s_primed = false;

// Act on the vibration analyser according to the Setup mode. Deliberately
// conservative:
// monitor - never touches the machine
Expand Down Expand Up @@ -187,7 +182,7 @@ static void vib_guard() {
rearm_ms = now + 3000;

if (lvl == VIB_ESTOP && mode == 2) {
fnc_realtime(Reset);
send_reset();
clog_add("[MSG:VIBRATION: impact - soft reset sent]");
} else {
fnc_realtime(FeedHold);
Expand Down Expand Up @@ -267,36 +262,6 @@ static void link_watchdog() {
touch_int_level(), touch_last_status());
}

static void prime_link_if_up() {
// A controller reset wipes everything primed below, plus the $RI auto-report
// and the parser modes, and the link may never drop to Disconnected if the
// reboot is quick. Left alone the jog page falls back to its 500 mm/min
// creep rate because the axis max rates are gone.
bool reset = model_take_board_reset();
if (reset) { homed_forget(); motors_resync(); }
if (state == Disconnected) { s_primed = false; return; }
if (reset && s_primed) {
s_primed = false;
send_line("$G");
send_line("$RI=200");
Serial.println("controller reset seen: re-priming");
}
if (s_primed) return;
s_primed = true;
motors_resync(); // a drop may have been the controller rebooting
motors_on_link();
// Config dump first: it decides which controls are even offered, and every
// second it is late is a second the panel shows homing and probing to a
// machine that has neither.
caps_request_config();
send_line("$#");
filelist_request();
// The full settings dump also feeds the Diag limit lamps: which lamps
// exist is read from the controller's configured limit/probe pins.
fncset_request_all();
Serial.println("link up: primed config, offsets, file list and settings");
}

// [MSG:PANEL:UPDATE] from the controller runs the same network update as the
// Setup button. Never mid-job: the update blanks the screen and reboots. The
// update's own tap-to-cancel countdown still gives whoever is at the panel the
Expand Down Expand Up @@ -351,7 +316,7 @@ void loop() {
imulog_poll();
console_cmd();
vib_guard();
prime_link_if_up();
link_service(); // liveness, controller restarts, priming
caps_poll();
link_watchdog();
service_action();
Expand Down
Loading
Loading