Skip to content

Commit feb0009

Browse files
atlasteStefan de Bruijn
andauthored
Fix tests (#131)
* Fixed some small compilation bugs. Implemented string::trim for test compatibility. * Fixed project hierarchy * Added unit tests to the project again. * Fixed a bunch of small compilation issues. Linker and library issues remain. * Moved TestSupport. Added documentation. Fixed test framework. Stuff works again! Co-authored-by: Stefan de Bruijn <[email protected]>
1 parent 5b41c37 commit feb0009

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1415
-1117
lines changed

FluidNC.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Global
1818
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Debug|x64.ActiveCfg = Debug|x64
1919
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Debug|x64.Build.0 = Debug|x64
2020
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Debug|x86.ActiveCfg = Debug|Win32
21-
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Debug|x86.Build.0 = Debug|Win32
2221
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Release|x64.ActiveCfg = Release|x64
2322
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Release|x64.Build.0 = Release|x64
2423
{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}.Release|x86.ActiveCfg = Release|Win32

FluidNC/src/Kinematics/Cartesian.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Kinematics {
3131
auto axes = config->_axes;
3232
auto n_axis = config->_axes->_numberAxis;
3333

34-
float cartesian[n_axis];
34+
float cartesian[MAX_N_AXIS];
3535
motors_to_cartesian(cartesian, target, n_axis); // Convert to cartesian then check
3636

3737
bool limit_error = false;

FluidNC/src/Kinematics/CoreXY.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ namespace Kinematics {
216216

217217
auto n_axis = config->_axes->_numberAxis;
218218

219-
float mpos[n_axis] = { 0 };
219+
float mpos[MAX_N_AXIS] = { 0 };
220220

221221
// Set machine positions for homed limit switches. Don't update non-homed axes.
222222
for (int axis = 0; axis < n_axis; axis++) {
@@ -231,7 +231,7 @@ namespace Kinematics {
231231
}
232232
}
233233

234-
float motors_mm[n_axis];
234+
float motors_mm[MAX_N_AXIS];
235235
transform_cartesian_to_motors(motors_mm, mpos);
236236

237237
// the only single axis homing allowed is Z and above
@@ -284,11 +284,11 @@ namespace Kinematics {
284284

285285
auto n_axis = config->_axes->_numberAxis;
286286

287-
float motors[n_axis];
287+
float motors[MAX_N_AXIS];
288288
transform_cartesian_to_motors(motors, target);
289289

290290
if (!pl_data->motion.rapidMotion) {
291-
float last_motors[n_axis];
291+
float last_motors[MAX_N_AXIS];
292292
transform_cartesian_to_motors(last_motors, position);
293293
pl_data->feed_rate *= (three_axis_dist(motors, last_motors) / dist);
294294
}

FluidNC/src/Machine/Homing.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "../Machine/Axes.h"
99
#include "../Machine/MachineConfig.h" // config
1010

11+
#include <cmath>
12+
1113
namespace Machine {
1214
// Calculate the motion for the next homing move.
1315
// Input: axesMask - the axes that should participate in this homing cycle

FluidNC/src/Main.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22
// Copyright (c) 2018 - Bart Dring
33
// Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file.
44

5-
#include "Main.h"
6-
#include "Machine/MachineConfig.h"
7-
8-
#include "Config.h"
9-
#include "Report.h"
10-
#include "Settings.h"
11-
#include "SettingsDefinitions.h"
12-
#include "Limits.h"
13-
#include "Protocol.h"
14-
#include "System.h"
15-
#include "Uart.h"
16-
#include "MotionControl.h"
17-
#include "Platform.h"
18-
19-
#include "WebUI/TelnetServer.h"
20-
#include "WebUI/Serial2Socket.h"
21-
#include "WebUI/InputBuffer.h"
22-
23-
#include "WebUI/WifiConfig.h"
24-
#include <SPIFFS.h>
5+
#ifndef UNIT_TEST
6+
7+
# include "Main.h"
8+
# include "Machine/MachineConfig.h"
9+
10+
# include "Config.h"
11+
# include "Report.h"
12+
# include "Settings.h"
13+
# include "SettingsDefinitions.h"
14+
# include "Limits.h"
15+
# include "Protocol.h"
16+
# include "System.h"
17+
# include "Uart.h"
18+
# include "MotionControl.h"
19+
# include "Platform.h"
20+
21+
# include "WebUI/TelnetServer.h"
22+
# include "WebUI/Serial2Socket.h"
23+
# include "WebUI/InputBuffer.h"
24+
25+
# include "WebUI/WifiConfig.h"
26+
# include <SPIFFS.h>
2527

2628
extern void make_user_commands();
2729

@@ -125,7 +127,7 @@ void setup() {
125127
}
126128

127129
static void reset_variables() {
128-
#ifdef DEBUG_STEPPING
130+
# ifdef DEBUG_STEPPING
129131
rtTestPl = false;
130132
rtTestSt = false;
131133
st_seq = 0;
@@ -134,7 +136,7 @@ static void reset_variables() {
134136
seg_seq0 = 0;
135137
seg_seq1 = 0;
136138
planner_seq = 0;
137-
#endif
139+
# endif
138140
// Reset primary systems.
139141
system_reset();
140142
protocol_reset();
@@ -195,12 +197,14 @@ void loop() {
195197

196198
void WEAK_LINK machine_init() {}
197199

198-
#if 0
200+
# if 0
199201
int main() {
200202
setup(); // setup()
201203
while (1) { // loop()
202204
loop();
203205
}
204206
return 0;
205207
}
208+
# endif
209+
206210
#endif

FluidNC/src/MotionControl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "InputFile.h" // infile
1616
#include "Platform.h" // WEAK_LINK
1717

18+
#include <cmath>
19+
1820
// M_PI is not defined in standard C/C++ but some compilers
1921
// support it anyway. The following suppresses Intellisense
2022
// problem reports.

FluidNC/src/Motors/Dynamixel2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "../Planner.h" // plan_sync_position()
2323

2424
#include <cstdarg>
25+
#include <cmath>
2526

2627
namespace MotorDrivers {
2728
bool MotorDrivers::Dynamixel2::_uart_started = false;

FluidNC/src/Motors/Servo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace MotorDrivers {
3838
xTaskCreatePinnedToCore(updateTask, // task
3939
"servoUpdateTask", // name for task
4040
4096, // size of task stack
41-
(void*)_timer_ms, // parameters
41+
(void*)&_timer_ms, // parameters
4242
1, // priority
4343
NULL, // handle
4444
SUPPORT_TASK_CORE // core
@@ -48,7 +48,7 @@ namespace MotorDrivers {
4848

4949
void Servo::updateTask(void* pvParameters) {
5050
TickType_t xLastWakeTime;
51-
const TickType_t xUpdate = TickType_t(pvParameters) / portTICK_PERIOD_MS; // in ticks (typically ms)
51+
const TickType_t xUpdate = *static_cast<TickType_t*>(pvParameters) / portTICK_PERIOD_MS; // in ticks (typically ms)
5252
auto n_axis = config->_axes->_numberAxis;
5353

5454
xLastWakeTime = xTaskGetTickCount(); // Initialise the xLastWakeTime variable with the current time.

FluidNC/src/NutsBolts.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <cstring>
1212
#include <cstdint>
13+
#include <cmath>
1314

1415
const int MAX_INT_DIGITS = 8; // Maximum number of digits in int32 (and float)
1516

FluidNC/src/Planner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
#include "Machine/MachineConfig.h"
1515

16-
#include <stdlib.h> // PSoc Required for labs
16+
#include <cstdlib> // PSoc Required for labs
17+
#include <cmath>
1718

1819
static plan_block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
1920
static uint8_t block_buffer_tail; // Index of the block to process now

0 commit comments

Comments
 (0)