Prusa MINI Firmware overview
EmergencyParser Class Reference

#include <emergency_parser.h>

Collaboration diagram for EmergencyParser:

Public Types

enum  State : char {
  EP_RESET, EP_N, EP_M, EP_M1,
  EP_M10, EP_M108, EP_M11, EP_M112,
  EP_M4, EP_M41, EP_M410, EP_IGNORE
}
 

Public Member Functions

 EmergencyParser ()
 

Static Public Member Functions

static FORCE_INLINE void enable ()
 
static FORCE_INLINE void disable ()
 
static FORCE_INLINE void update (State &state, const uint8_t c)
 

Static Public Attributes

static bool killed_by_M112
 

Member Enumeration Documentation

◆ State

Enumerator
EP_RESET 
EP_N 
EP_M 
EP_M1 
EP_M10 
EP_M108 
EP_M11 
EP_M112 
EP_M4 
EP_M41 
EP_M410 
EP_IGNORE 
43  : char {
44  EP_RESET,
45  EP_N,
46  EP_M,
47  EP_M1,
48  EP_M10,
49  EP_M108,
50  EP_M11,
51  EP_M112,
52  EP_M4,
53  EP_M41,
54  EP_M410,
55  #if ENABLED(HOST_PROMPT_SUPPORT)
56  EP_M8,
57  EP_M87,
58  EP_M876,
59  EP_M876S,
60  EP_M876SN,
61  #endif
62  EP_IGNORE // to '\n'
63  };

Constructor & Destructor Documentation

◆ EmergencyParser()

EmergencyParser::EmergencyParser ( )
71 { enable(); }
Here is the call graph for this function:

Member Function Documentation

◆ enable()

static FORCE_INLINE void EmergencyParser::enable ( )
static
73 { enabled = true; }
Here is the caller graph for this function:

◆ disable()

static FORCE_INLINE void EmergencyParser::disable ( )
static
75 { enabled = false; }

◆ update()

static FORCE_INLINE void EmergencyParser::update ( State state,
const uint8_t  c 
)
static
77  {
78  switch (state) {
79  case EP_RESET:
80  switch (c) {
81  case ' ': break;
82  case 'N': state = EP_N; break;
83  case 'M': state = EP_M; break;
84  default: state = EP_IGNORE;
85  }
86  break;
87 
88  case EP_N:
89  switch (c) {
90  case '0': case '1': case '2':
91  case '3': case '4': case '5':
92  case '6': case '7': case '8':
93  case '9': case '-': case ' ': break;
94  case 'M': state = EP_M; break;
95  default: state = EP_IGNORE;
96  }
97  break;
98 
99  case EP_M:
100  switch (c) {
101  case ' ': break;
102  case '1': state = EP_M1; break;
103  case '4': state = EP_M4; break;
104  #if ENABLED(HOST_PROMPT_SUPPORT)
105  case '8': state = EP_M8; break;
106  #endif
107  default: state = EP_IGNORE;
108  }
109  break;
110 
111  case EP_M1:
112  switch (c) {
113  case '0': state = EP_M10; break;
114  case '1': state = EP_M11; break;
115  default: state = EP_IGNORE;
116  }
117  break;
118 
119  case EP_M10:
120  state = (c == '8') ? EP_M108 : EP_IGNORE;
121  break;
122 
123  case EP_M11:
124  state = (c == '2') ? EP_M112 : EP_IGNORE;
125  break;
126 
127  case EP_M4:
128  state = (c == '1') ? EP_M41 : EP_IGNORE;
129  break;
130 
131  case EP_M41:
132  state = (c == '0') ? EP_M410 : EP_IGNORE;
133  break;
134 
135  #if ENABLED(HOST_PROMPT_SUPPORT)
136  case EP_M8:
137  state = (c == '7') ? EP_M87 : EP_IGNORE;
138  break;
139 
140  case EP_M87:
141  state = (c == '6') ? EP_M876 : EP_IGNORE;
142  break;
143 
144  case EP_M876:
145  switch (c) {
146  case ' ': break;
147  case 'S': state = EP_M876S; break;
148  default: state = EP_IGNORE; break;
149  }
150  break;
151 
152  case EP_M876S:
153  switch (c) {
154  case ' ': break;
155  case '0': case '1': case '2':
156  case '3': case '4': case '5':
157  case '6': case '7': case '8':
158  case '9':
159  state = EP_M876SN;
160  M876_reason = (uint8_t)(c - '0');
161  break;
162  }
163  break;
164  #endif
165 
166  case EP_IGNORE:
167  if (c == '\n') state = EP_RESET;
168  break;
169 
170  default:
171  if (c == '\n') {
172  if (enabled) switch (state) {
173  case EP_M108: wait_for_user = wait_for_heatup = false; break;
174  case EP_M112: killed_by_M112 = true; break;
175  case EP_M410: quickstop_stepper(); break;
176  #if ENABLED(HOST_PROMPT_SUPPORT)
177  case EP_M876SN: host_response_handler(M876_reason); break;
178  #endif
179  default: break;
180  }
181  state = EP_RESET;
182  }
183  }
184  }
Here is the call graph for this function:

Member Data Documentation

◆ killed_by_M112

bool EmergencyParser::killed_by_M112
static
EmergencyParser::EP_N
Definition: emergency_parser.h:45
host_response_handler
void host_response_handler(const uint8_t response)
Definition: marlin_server.cpp:1029
EmergencyParser::EP_M11
Definition: emergency_parser.h:50
EmergencyParser::EP_M108
Definition: emergency_parser.h:49
state
static volatile fsensor_t state
Definition: filament_sensor.c:23
EmergencyParser::EP_M
Definition: emergency_parser.h:46
EmergencyParser::killed_by_M112
static bool killed_by_M112
Definition: emergency_parser.h:65
wait_for_user
bool wait_for_user
Definition: Marlin.cpp:188
EmergencyParser::EP_M112
Definition: emergency_parser.h:51
EmergencyParser::EP_M41
Definition: emergency_parser.h:53
EmergencyParser::enable
static FORCE_INLINE void enable()
Definition: emergency_parser.h:73
EmergencyParser::EP_M410
Definition: emergency_parser.h:54
uint8_t
const uint8_t[]
Definition: 404_html.c:3
EmergencyParser::EP_IGNORE
Definition: emergency_parser.h:62
quickstop_stepper
void quickstop_stepper()
Definition: Marlin.cpp:272
EmergencyParser::EP_M1
Definition: emergency_parser.h:47
EmergencyParser::EP_M10
Definition: emergency_parser.h:48
EmergencyParser::EP_RESET
Definition: emergency_parser.h:44
EmergencyParser::EP_M4
Definition: emergency_parser.h:52
wait_for_heatup
bool wait_for_heatup
Definition: Marlin.cpp:184