Commit Graph

272 Commits (aaee8cab300311d624a9dc3032f77c89cfaaffc8)

Author SHA1 Message Date
D.R.racer 4fa352b4fa Change minimum unit tests to reflect new version nr 2023-07-20 10:28:58 +02:00
Guðni Már Gilbert edec4708b5 MMU-239 Add unit test for FINDA flickering when ejecting filament
The test case test the error recovery on all MMU slots.
2023-06-12 07:39:25 +02:00
Guðni Már Gilbert 4d3067213f MMU-239 Add unit test for ejecting slots 0-4
This test ejects slots 0 to 4 and goes through the state machine
without creating any errors like FINDA_FLICKERS.

It also verifies the selector parking position is correct for each
ejected filament slot.
2023-06-12 07:39:25 +02:00
Guðni Már Gilbert 9842375450 Improve homing behavior more
Split the wait for HomingValid and the event where we wait
for the Selector/Idler status to go 'Ready' into separate functions
2023-06-12 07:04:51 +02:00
Guðni Már Gilbert bfc953f52d Add more strings to error output in unit tests 2023-06-12 07:04:51 +02:00
Guðni Már Gilbert eb52475819 Improve selector homing behavior in unit tests
Waiting for the selector to return to the parked position after homing
is not enforced by the firmware and should therefore not be enforced by
the unit tests. There are some few exceptions to this, and for those
situations I added a parameter to SimulateSelectorHoming() called
waitForParkedPosition to explicitly wait for the selector to return to
the parked position if set to true. This is very useful when setting up
test cases in general and also allows us to control the behavior in each
test.
2023-06-12 07:04:51 +02:00
Guðni Már Gilbert 372045c38c Update cut filament unit test 2023-06-12 07:04:51 +02:00
Guðni Már Gilbert 8c873c8a53 cleanup: unit tests: Remove unused Catch namespace 2023-06-04 14:06:03 +00:00
D.R.racer f07e206398 Hold/Resume Idler+Selector even after their homing errors
MMU-222
2023-03-14 18:14:02 +01:00
D.R.racer c4e23b687d Clean-up TMC SG trs setting in COOLCONF register 2023-03-14 17:58:11 +01:00
D.R.racer f0a633b4b6 Ignore Idler's SG signal from TMC when rolling over filaments 2023-03-14 17:58:11 +01:00
D.R.racer 95915cb080 Prototype adaptive Idler homing sg_thrs
Needs to be tweaked further to make it a production code.
But my primary concern now is the fact that it doesn't seem to help too much while homing over the too-tightened Idler cover.
2023-03-14 17:58:11 +01:00
D.R.racer 314233b37f Add runtime VCC measurement as register
- extract logic of undervoltage handling into main.cpp
- fix unit tests
- bump version to 2.1.9 (new register)
2023-03-08 15:14:36 +01:00
D.R.racer 8b55b25028 Allow cutting current >31
Needs reinitialization of the axis (Selector) because the TMC driver needs to set another register to double the current level.
2023-03-07 21:07:52 +01:00
D.R.racer ea41fd6b83 Update unit tests 2023-03-02 12:20:06 +01:00
D.R.racer 009c692138 Remove related unit tests 2023-02-10 14:39:45 +01:00
D.R.racer 75a0ebaf0e Remove handling of left+right buttons in error states
Based on long-term test experience - saves some code + prevents the user from entering hard-to-understand states.
Only Retry remains as the one and only way of recovering from errors.
2023-02-10 14:39:45 +01:00
D.R.racer ada4ed3dda Workaround INVALID_TOOL error codes
May meed some more work to recover gracefully, not sure if it is just a unit test "issue" or a deeper problem in the state machines.
2022-12-28 12:15:47 +01:00
D.R.racer a52f833223 Fix and tune CutFilament + unit tests
Several issues addressed in this PR:
- CutFilament tuning + error recovery
- introduce register 0x1d (cut filament selector iRun current level)
- optimize setting iRun and iHold currents in the FW
- CutFilament unit test fixed
2022-12-28 12:15:47 +01:00
D.R.racer 98daf765af Separate NoCommand and StartUp (new state machine)
The reasons for this change are:
- NoCommand is used during the lifetime of the firmware as a fallback in case an unknown command is received (simplifies command handling code). It must remain not doing anything.
- StartUp became a complex infrastructure which needs to "live" until an error is fixed (if any). That requires a "standard" StateInner() function which waits for the user to resolve the error.

Unit tests renamed as well.
2022-12-27 12:41:29 +01:00
Guðni Már Gilbert 8f212a5cb3 Add unit tests 2022-12-27 12:41:29 +01:00
D.R.racer 3988a9aff0 Improve logging in unit tests' helpers.ipp
Based on work from @gudnimg: https://github.com/gudnimg/Prusa-Firmware-MMU-Private/tree/MMU-206
2022-12-20 10:35:59 +01:00
D.R.racer 3e9410c4f9 Fix: make sure VerifyEnvironmentState checks filamentLoaded reliably
... and improve unit tests
2022-12-20 06:32:51 +01:00
D.R.racer c0189d81af Distinguish among different error states when recovering ToolChange
Some errors need specific recovery, it seems it is no longer possible to "just" retry.
2022-11-18 22:42:05 +01:00
D.R.racer c8c39f7b69 Make sure ToolChange moves Selector to desired slot
and verify correct behaviour in unit tests - especially when Selector's start position is at a different slot.
2022-11-18 22:29:01 +01:00
D.R.racer 08f777b5cb Introduce FINDA_FLICKERS error code
Intended for scenarios when FINDA used to be OFF but accidentally became ON without a reason.
The user is obliged to inspect FINDA and tune its switching.
2022-11-17 07:32:38 +01:00
D.R.racer 3f09ba0c16 Unit tests: selector refused to move in ToolChange
Revealed all kinds of subtle issues (which is great). All have been fixed in this commit.
2022-11-17 07:32:38 +01:00
D.R.racer c74d418016 Invalidate Idler+Selector homing flags when Retry from ToolChange Error
If FSENSOR_DIDNT_SWITCH_ON was caused by misaligned Idler, rehoming it may fix the issue when auto retrying -> no user intervention.
So first invalidate homing flags as the user may have moved the Idler or Selector accidentally.

Beware: we may run into issues when FINDA or FSensor do not work correctly. Selector may rely on the presumed filament position and actually cut it accidentally when trying to rehome.
It is yet to be seen if something like this can actually happen.

MMU-191
2022-11-15 17:42:12 +01:00
D.R.racer 299a31b765 Generate exactly 1 userInput event when button pressed (and held)
This PR is a different solution to what @gudnimg found in PR#233 / PFW-1404.

The benefit of this approach is the fact, that the button press event is generated when the button is pressed and not after it has been released.

The downside is obvious:
CPUFLASH: +28B
RAM: +1B
2022-11-15 07:19:20 +01:00
Guðni Már Gilbert 0e625dc551 circular_buffer: implement reset()
reset() discards any data in the buffer (head == tail)

Change in memory:
Flash: -116 bytes
SRAM: 0 bytes
2022-10-25 07:21:33 +02:00
Yuri D'Elia 3567a3dcd5 motion: Also test for the simplest case of a single+unplanned move 2022-10-22 17:40:28 +02:00
Yuri D'Elia 7053755b0e motion: Add tests for unscheduled moves in AbortPlannedMoves
This catches the previously untested #228
2022-10-22 17:21:08 +02:00
Guðni Már Gilbert 353affb9f3 Optimise Catch2 V3 includes + fix a few cases of missing includes 2022-10-22 15:41:44 +02:00
Guðni Már Gilbert 45f70e004c Update CMake integration for Catch v3.1.0 2022-10-22 15:41:44 +02:00
Alex Voinea e2924c3506 Fix tests 2022-10-20 12:09:42 +02:00
Guðni Már Gilbert bf89030423 user input test: Register enum with Catch
Now when REQUIRE ( a == b ) fails we see the values of a and b.
2022-10-17 17:27:47 +02:00
Guðni Már Gilbert 63404f7970 Format 2022-10-12 06:41:59 +02:00
Guðni Már Gilbert 01ef1191b0 Fix test_motion_ramp on Windows
* 'python3' is not valid on Windows

* call the .py file with 'python' command to prevent BAD_COMMAND error
2022-10-12 06:41:59 +02:00
Alex Voinea 2ab3b96542 tests... 2022-10-11 07:13:42 +02:00
D.R.racer 4f1a301e0e Force fix formatting 2022-09-22 12:16:41 +02:00
D.R.racer 0fa8a3c278 Refactor original solution from @leptun
- rename stall*guard to StallGuard (match name with the vendor)
- separate TMC2130 module from EEPROM (they do not need to know about each other at all)
- separate SGTHRS settings from motion - moved to globals like all other "global" parameters
- improved EEPROM storage for SGTHRS
2022-09-22 12:16:41 +02:00
D.R.racer 48d5bbc19e Fix computation of CRC for Write requests (non-zero value2) 2022-09-08 11:39:10 +02:00
D.R.racer 9a5a6d9498 Fix computation of CRC
came out of unit tests of read/write registers functionality.
2022-09-07 15:44:08 +02:00
D.R.racer 89fc176955 Add basic unit test infrastructure for application + registers 2022-08-11 10:26:42 +02:00
vintagepc fdb2058d2b Fix test build 2022-08-11 10:26:42 +02:00
D.R.racer 39caece714 Add CRC to the protocol + unit tests 2022-08-11 10:26:42 +02:00
D.R.racer bf5c0f3f23 Allow result codes on a Finished Command state
Helpful for the printer to show, that a command has been cancelled (or anything else we can think of in the future).
MMU-146
2022-08-11 10:26:42 +02:00
D.R.racer ad0b26c5ec Fix unit tests 2022-08-11 10:26:42 +02:00
D.R.racer 53f87c8755 Introduce generic Read/Write register operations 2022-08-11 10:26:42 +02:00
D.R.racer 5dffd32025 Introduce Idler::PartiallyDisengage
This is to solve a potential problem while feeding to printer's drive gears - while disengaging the Idler, the Pulley was still rotating to avoid grinding the filament (printer is pulling it).
Other filaments could have moved a bit when the Idler's bearings ran over them while the Pulley was still rotating slowly -> the filament could have been moved into the Selector's path causing trouble (especially when not used in the print).
Therefore, the Idler disengages partially now - moves into an intermediate position between the slots.
Then, the Pulley is completely stopped and after that the Idler does a full disengage like before.
2022-08-02 07:28:10 +02:00