[2.0.x] Emergency parser for multiple serial ports (#10524)
This commit is contained in:
@ -85,6 +85,10 @@
|
||||
|
||||
FORCE_INLINE void store_rxd_char() {
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
static EmergencyParser::State emergency_state; // = EP_RESET
|
||||
#endif
|
||||
|
||||
const ring_buffer_pos_t h = rx_buffer.head,
|
||||
i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(RX_BUFFER_SIZE - 1);
|
||||
|
||||
@ -160,7 +164,7 @@
|
||||
#endif // SERIAL_XON_XOFF
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
emergency_parser.update(c);
|
||||
emergency_parser.update(emergency_state, c);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,10 @@
|
||||
|
||||
FORCE_INLINE void store_rxd_char() {
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
static EmergencyParser::State emergency_state; // = EP_RESET
|
||||
#endif
|
||||
|
||||
const ring_buffer_pos_t h = rx_buffer.head,
|
||||
i = (ring_buffer_pos_t)(h + 1) & (ring_buffer_pos_t)(RX_BUFFER_SIZE - 1);
|
||||
|
||||
@ -182,7 +186,7 @@
|
||||
#endif // SERIAL_XON_XOFF
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
emergency_parser.update(c);
|
||||
emergency_parser.update(emergency_state, c);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,6 @@
|
||||
|
||||
#include "HardwareSerial.h"
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../../feature/emergency_parser.h"
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT == 0 || SERIAL_PORT_2 == 0
|
||||
HardwareSerial Serial = HardwareSerial(LPC_UART0);
|
||||
#elif SERIAL_PORT == 1 || SERIAL_PORT_2 == 1
|
||||
@ -254,7 +248,7 @@ void HardwareSerial::IRQHandler() {
|
||||
// Clear the FIFO
|
||||
while (UART_Receive(UARTx, &byte, 1, NONE_BLOCKING)) {
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
emergency_parser.update(byte);
|
||||
emergency_parser.update(emergency_state, byte);
|
||||
#endif
|
||||
if ((RxQueueWritePos + 1) % RX_BUFFER_SIZE != RxQueueReadPos) {
|
||||
RxBuffer[RxQueueWritePos] = byte;
|
||||
|
@ -23,6 +23,11 @@
|
||||
#ifndef HARDWARE_SERIAL_H_
|
||||
#define HARDWARE_SERIAL_H_
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../../feature/emergency_parser.h"
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <Stream.h>
|
||||
@ -32,8 +37,6 @@ extern "C" {
|
||||
#include "lpc17xx_pinsel.h"
|
||||
}
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
class HardwareSerial : public Stream {
|
||||
private:
|
||||
LPC_UART_TypeDef *UARTx;
|
||||
@ -48,6 +51,9 @@ private:
|
||||
uint32_t TxQueueWritePos;
|
||||
uint32_t TxQueueReadPos;
|
||||
#endif
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
EmergencyParser::State emergency_state;
|
||||
#endif
|
||||
|
||||
public:
|
||||
HardwareSerial(LPC_UART_TypeDef *UARTx)
|
||||
@ -59,6 +65,9 @@ public:
|
||||
, TxQueueWritePos(0)
|
||||
, TxQueueReadPos(0)
|
||||
#endif
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
, emergency_state(EmergencyParser::State::EP_RESET)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,11 @@
|
||||
#ifndef _HAL_SERIAL_H_
|
||||
#define _HAL_SERIAL_H_
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../../../feature/emergency_parser.h"
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -73,6 +78,11 @@ private:
|
||||
|
||||
class HalSerial {
|
||||
public:
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
EmergencyParser::State emergency_state;
|
||||
#endif
|
||||
|
||||
HalSerial() { host_connected = false; }
|
||||
|
||||
void begin(int32_t baud) {
|
||||
|
Reference in New Issue
Block a user