Skip to content

Commit

Permalink
Added all_messages config item to suppress chitchat on a channel
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchBradley committed Dec 11, 2023
1 parent 3e94650 commit 6db0190
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions FluidNC/src/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class Channel : public Stream {
bool _reportWco = true;
CoordIndex _reportNgc = CoordIndex::End;

// Set this to false to suppress messages sent to AllChannels
// It is useful for IO Expanders that do not want to be spammed
// with chitchat
bool _all_messages = true;

public:
Channel(const char* name, bool addCR = false) : _name(name), _linelen(0), _addCR(addCR) {}
virtual ~Channel() = default;
Expand Down Expand Up @@ -104,6 +109,8 @@ class Channel : public Stream {
int read() override { return -1; }
int available() override { return _queue.size(); }

bool all_messages() { return _all_messages; }

uint32_t setReportInterval(uint32_t ms);
uint32_t getReportInterval() { return _reportInterval; }
virtual void autoReport();
Expand Down
8 changes: 6 additions & 2 deletions FluidNC/src/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ void AllChannels::flushRx() {
size_t AllChannels::write(uint8_t data) {
_mutex_general.lock();
for (auto channel : _channelq) {
channel->write(data);
if (channel->all_messages()) {
channel->write(data);
}
}
_mutex_general.unlock();
return 1;
Expand Down Expand Up @@ -264,7 +266,9 @@ void AllChannels::stopJob() {
size_t AllChannels::write(const uint8_t* buffer, size_t length) {
_mutex_general.lock();
for (auto channel : _channelq) {
channel->write(buffer, length);
if (channel->all_messages()) {
channel->write(buffer, length);
}
}
_mutex_general.unlock();
return length;
Expand Down
1 change: 1 addition & 0 deletions FluidNC/src/UartChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class UartChannel : public Channel, public Configuration::Configurable {
void group(Configuration::HandlerBase& handler) override {
handler.item("uart_num", _uart_num);
handler.item("report_interval_ms", _report_interval_ms, 0, 5000);
handler.item("all_messages", _all_messages);
}
};

Expand Down

0 comments on commit 6db0190

Please sign in to comment.