1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 19:02:35 +02:00

Message format cleanups

This commit is contained in:
Mitch Bradley
2021-05-21 14:30:52 -10:00
parent 6f48057687
commit baf74070e5
3 changed files with 22 additions and 22 deletions

View File

@@ -27,7 +27,7 @@ public:
// Note: these '{'..'}' scopes are here for a reason: the destructor should flush. // Note: these '{'..'}' scopes are here for a reason: the destructor should flush.
#define log_debug(x) \ #define log_debug(x) \
{ \ { \
DebugStream ss("DBG "); \ DebugStream ss("DBG"); \
ss << x; \ ss << x; \
} }
@@ -45,13 +45,13 @@ public:
#define log_error(x) \ #define log_error(x) \
{ \ { \
DebugStream ss("ERR "); \ DebugStream ss("ERR"); \
ss << x; \ ss << x; \
} }
#define log_fatal(x) \ #define log_fatal(x) \
{ \ { \
DebugStream ss("FATAL "); \ DebugStream ss("FATAL"); \
ss << x; \ ss << x; \
Assert(false, "A fatal error occurred."); \ Assert(false, "A fatal error occurred."); \
} }

View File

@@ -314,9 +314,9 @@ Axes::~Axes() {
void I2SOBus::validate() const { void I2SOBus::validate() const {
if (_bck.defined() || _data.defined() || _ws.defined()) { if (_bck.defined() || _data.defined() || _ws.defined()) {
Assert(_bck.defined(), "I2SO BCK pin should be configured once."); Assert(_bck.defined(), "I2SO BCK pin should be configured once");
Assert(_data.defined(), "I2SO Data pin should be configured once."); Assert(_data.defined(), "I2SO Data pin should be configured once");
Assert(_ws.defined(), "I2SO WS pin should be configured once."); Assert(_ws.defined(), "I2SO WS pin should be configured once");
} }
} }
@@ -328,10 +328,10 @@ void I2SOBus::handle(Configuration::HandlerBase& handler) {
void SPIBus::validate() const { void SPIBus::validate() const {
if (_ss.defined() || _miso.defined() || _mosi.defined() || _sck.defined()) { if (_ss.defined() || _miso.defined() || _mosi.defined() || _sck.defined()) {
Assert(_ss.defined(), "SPI SS pin should be configured once."); Assert(_ss.defined(), "SPI SS pin should be configured once");
Assert(_miso.defined(), "SPI MISO pin should be configured once."); Assert(_miso.defined(), "SPI MISO pin should be configured once");
Assert(_mosi.defined(), "SPI MOSI pin should be configured once."); Assert(_mosi.defined(), "SPI MOSI pin should be configured once");
Assert(_sck.defined(), "SPI SCK pin should be configured once."); Assert(_sck.defined(), "SPI SCK pin should be configured once");
} }
} }
@@ -358,30 +358,30 @@ void MachineConfig::handle(Configuration::HandlerBase& handler) {
void MachineConfig::afterParse() { void MachineConfig::afterParse() {
if (_axes == nullptr) { if (_axes == nullptr) {
log_info("Axes config missing; building default axes."); log_info("Axes config missing; building default axes");
_axes = new Axes(); _axes = new Axes();
} }
if (_coolant == nullptr) { if (_coolant == nullptr) {
log_info("Coolant control config missing; building default coolant."); log_info("Coolant control config missing; building default coolant");
_coolant = new CoolantControl(); _coolant = new CoolantControl();
} }
if (_probe == nullptr) { if (_probe == nullptr) {
log_info("Probe config missing; building default probe."); log_info("Probe config missing; building default probe");
_probe = new Probe(); _probe = new Probe();
} }
} }
size_t MachineConfig::readFile(const char* filename, char*& buffer) { size_t MachineConfig::readFile(const char* filename, char*& buffer) {
if (!SPIFFS.begin(true)) { if (!SPIFFS.begin(true)) {
log_info("An error has occurred while mounting SPIFFS"); log_info("Cannot mount the local filesystem");
return 0; return 0;
} }
FILE* file = fopen(filename, "rb"); FILE* file = fopen(filename, "rb");
if (!file) { if (!file) {
log_info("There was an error opening the config file for reading"); log_info("Cannot open the config file " << filename);
return 0; return 0;
} }
@@ -389,7 +389,7 @@ size_t MachineConfig::readFile(const char* filename, char*& buffer) {
// in trouble with this, we can cut it in pieces and read it per chunk. // in trouble with this, we can cut it in pieces and read it per chunk.
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
auto filesize = ftell(file); auto filesize = ftell(file);
log_debug("Configuration file is " << int(filesize) << " bytes."); log_debug("Configuration file is " << int(filesize) << " bytes");
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
buffer = new char[filesize + 1]; buffer = new char[filesize + 1];
@@ -411,7 +411,7 @@ size_t MachineConfig::readFile(const char* filename, char*& buffer) {
if (pos != filesize) { if (pos != filesize) {
delete[] buffer; delete[] buffer;
log_error("There was an error reading the config file"); log_error("Cannot read the config file");
return 0; return 0;
} }
return filesize; return filesize;
@@ -454,7 +454,7 @@ bool MachineConfig::load(const char* filename) {
config->handle(handler); config->handle(handler);
} }
log_info("Done parsing machine config. Running after-parse tasks"); log_info("Parsed configuration. Running after-parse tasks");
try { try {
Configuration::AfterParse afterParse; Configuration::AfterParse afterParse;
@@ -462,7 +462,7 @@ bool MachineConfig::load(const char* filename) {
config->handle(afterParse); config->handle(afterParse);
} catch (std::exception& ex) { log_info("Validation error: " << ex.what()); } } catch (std::exception& ex) { log_info("Validation error: " << ex.what()); }
log_info("Validating machine config"); log_info("Validating configuration");
try { try {
Configuration::Validator validator; Configuration::Validator validator;
@@ -470,7 +470,7 @@ bool MachineConfig::load(const char* filename) {
config->handle(validator); config->handle(validator);
} catch (std::exception& ex) { log_info("Validation error: " << ex.what()); } } catch (std::exception& ex) { log_info("Validation error: " << ex.what()); }
log_info("Done validating machine config."); log_info("Validated configuration");
successful = true; successful = true;
@@ -492,7 +492,7 @@ bool MachineConfig::load(const char* filename) {
log_error("Configuration validation error: " << ex.what()); log_error("Configuration validation error: " << ex.what());
} catch (...) { } catch (...) {
// Get rid of buffer and return // Get rid of buffer and return
log_error("Unknown error occurred while processing configuration file."); log_error("Unknown error while processing config file");
} }
// Get rid of buffer and return // Get rid of buffer and return

View File

@@ -77,7 +77,7 @@ namespace Spindles {
_pwm_period = (1 << _pwm_precision); _pwm_period = (1 << _pwm_precision);
if (_pwm_min_value > _pwm_max_value) { if (_pwm_min_value > _pwm_max_value) {
log_warn("Spindle min pwm is greater than max."); log_warn("Spindle min PWM is greater than max.");
} }
// pre-calculate some PWM count values // pre-calculate some PWM count values