mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
- Fixed initialization bug in trinamic drivers
- Added better error handling for validation of pin changes
This commit is contained in:
@@ -202,6 +202,14 @@ namespace Motors {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void TrinamicDriver::read_settings() {
|
void TrinamicDriver::read_settings() {
|
||||||
|
// When 'test' is called and no actual trinamic is there, _has_errors will evaluate to 'true'. The
|
||||||
|
// result of that is that the check below will fail. And the result of that is that the step/dir pin
|
||||||
|
// is not initialized if we don't do it here. Unstep actually uses that pin -- and then you will get
|
||||||
|
// an assertion for using a pin that's not initialized.
|
||||||
|
//
|
||||||
|
// So... I moved init_step_dir_pins here, which basically solves that.
|
||||||
|
init_step_dir_pins();
|
||||||
|
|
||||||
if (_has_errors) {
|
if (_has_errors) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -218,8 +226,6 @@ namespace Motors {
|
|||||||
}
|
}
|
||||||
tmcstepper->microsteps(axis_settings[_axis_index]->microsteps->get());
|
tmcstepper->microsteps(axis_settings[_axis_index]->microsteps->get());
|
||||||
tmcstepper->rms_current(run_i_ma, hold_i_percent);
|
tmcstepper->rms_current(run_i_ma, hold_i_percent);
|
||||||
|
|
||||||
init_step_dir_pins();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrinamicDriver::set_homing_mode(bool isHoming) {
|
bool TrinamicDriver::set_homing_mode(bool isHoming) {
|
||||||
|
@@ -165,7 +165,17 @@ Pin Pin::create(const String& str) {
|
|||||||
bool Pin::validate(const String& str) {
|
bool Pin::validate(const String& str) {
|
||||||
Pins::PinDetail* pinImplementation;
|
Pins::PinDetail* pinImplementation;
|
||||||
|
|
||||||
auto valid = parse(str, pinImplementation);
|
bool valid = false;
|
||||||
|
try {
|
||||||
|
valid = parse(str, pinImplementation);
|
||||||
|
} catch (const AssertionFailed& e) {
|
||||||
|
// If an assertion happens, it's definitely invalid.
|
||||||
|
#ifdef ESP32
|
||||||
|
grbl_msg_sendf(CLIENT_ALL, MsgLevel::Warning, "Validation for pin spec %s failed: %s", str.c_str(), e.error.c_str());
|
||||||
|
#endif
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (pinImplementation) {
|
if (pinImplementation) {
|
||||||
delete pinImplementation;
|
delete pinImplementation;
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ AssertionFailed AssertionFailed::create(const char* condition, const char* msg,
|
|||||||
st += " at: ";
|
st += " at: ";
|
||||||
st += esp_backtrace_print(10);
|
st += esp_backtrace_print(10);
|
||||||
|
|
||||||
return AssertionFailed(st);
|
return AssertionFailed(st, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@@ -6,11 +6,12 @@
|
|||||||
class AssertionFailed {
|
class AssertionFailed {
|
||||||
public:
|
public:
|
||||||
String stackTrace;
|
String stackTrace;
|
||||||
|
String error;
|
||||||
|
|
||||||
AssertionFailed(String st) : stackTrace(st) {}
|
AssertionFailed(String st, String err) : stackTrace(st), error(err) {}
|
||||||
|
|
||||||
static AssertionFailed create(const char* condition) {
|
static AssertionFailed create(const char* condition) {
|
||||||
return create(condition, "Assertion failed");
|
return create(condition, "Unknown error (assertion failed).");
|
||||||
}
|
}
|
||||||
static AssertionFailed create(const char* condition, const char* msg, ...);
|
static AssertionFailed create(const char* condition, const char* msg, ...);
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ public:
|
|||||||
String stackTrace;
|
String stackTrace;
|
||||||
|
|
||||||
static std::exception create(const char* condition) {
|
static std::exception create(const char* condition) {
|
||||||
return create(condition, "Assertion failed");
|
return create(condition, "Unknown error (assertion failed).");
|
||||||
}
|
}
|
||||||
static std::exception create(const char* condition, const char* msg, ...);
|
static std::exception create(const char* condition, const char* msg, ...);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user