MCPcopy Create free account
hub / github.com/bdring/FluidNC / handleRealtimeCharacter

Method handleRealtimeCharacter

FluidNC/src/Channel.cpp:157–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void Channel::handleRealtimeCharacter(uint8_t ch) {
158 uint32_t cmd = 0;
159
160 if ((ch & 0xf8) == 0xf8) {
161 // 0xf8-0xff are not valid UTF-8 byte but can appear under some
162 // glitch conditions.
163 return;
164 }
165 int res = _utf8.decode(ch, cmd);
166 if (res == -1) {
167 // This can be caused by line noise on an unpowered pendant
168 log_debug("UTF8 decoding error " << to_hex(ch) << " " << to_hex(cmd));
169 _active = false;
170 return;
171 }
172 if (res == 0) {
173 return;
174 }
175 // Otherwise res==1 and we have decoded a sequence so proceed
176
177 _active = true;
178 if (cmd == PinACK) {
179 _ackwait = 0;
180 return;
181 }
182 if (cmd == PinNAK) {
183 log_verbose("NAK");
184 _ackwait = -1;
185 return;
186 }
187 if (cmd == PinRST) {
188 _ackwait = -1;
189 send_alarm(ExecAlarm::ExpanderReset);
190 return;
191 }
192 if (cmd >= PinLowFirst && cmd < PinLowLast) {
193 pin_event(cmd - PinLowFirst, false);
194 return;
195 }
196 if (cmd >= PinHighFirst && cmd < PinHighLast) {
197 pin_event(cmd - PinHighFirst, true);
198 return;
199 }
200 execute_realtime_command(static_cast<Cmd>(cmd), *this);
201}
202
203void Channel::push(uint8_t byte) {
204 if (is_realtime_command(byte)) {

Callers 1

runGCodeMethod · 0.80

Calls 4

to_hexFunction · 0.85
send_alarmFunction · 0.85
execute_realtime_commandFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected