@@ -63,7 +63,7 @@ void protocol_main_loop()
6363 // ------------------------------------------------------------
6464
6565 // Print welcome message
66- report_init_message ();
66+ // report_init_message();
6767
6868 // Check for and report alarm state after a reset, error, or an initial power up.
6969 if (sys .state == STATE_ALARM ) {
@@ -89,6 +89,7 @@ void protocol_main_loop()
8989 uint8_t line_remain = 0 ;
9090 uint8_t line_num = 0 ;
9191 uint8_t line_execute_p = 0 ;
92+
9293 for (;;) {
9394
9495 // Process one line of incoming serial data, as the data becomes available. Performs an
@@ -100,71 +101,80 @@ void protocol_main_loop()
100101 // exceed 256 characters, but the Arduino Uno does not have the memory space for this.
101102 // With a better processor, it would be very easy to pull this initial parsing out as a
102103 // seperate task to be shared by the g-code parser and Grbl's system commands.
103-
104- while ((c = serial_read ()) != SERIAL_NO_DATA ) {
105- if ((c == '\n' ) || (c == '\r' )) { // End of line reached
106- line [char_counter ] = 0 ; // Set string termination character.
107- receive_cmd_line (line );
108- comment = COMMENT_NONE ;
109- char_counter = 0 ;
110- break ;
111- } else {
112- if (comment != COMMENT_NONE ) {
113- // Throw away all comment characters
114- if (c == ')' ) {
115- // End of comment. Resume line. But, not if semicolon type comment.
116- if (comment == COMMENT_TYPE_PARENTHESES ) { comment = COMMENT_NONE ; }
117- }
118- } else {
119- if (c <= ' ' ) {
120- // Throw away whitepace and control characters
121- } else if (c == '/' ) {
122- // Block delete NOT SUPPORTED. Ignore character.
123- // NOTE: If supported, would simply need to check the system if block delete is enabled.
124- } else if (c == '(' ) {
125- // Enable comments flag and ignore all characters until ')' or EOL.
126- // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
127- // In the future, we could simply remove the items within the comments, but retain the
128- // comment control characters, so that the g-code parser can error-check it.
129- comment = COMMENT_TYPE_PARENTHESES ;
130- } else if (c == ';' ) {
131- // NOTE: ';' comment to EOL is a LinuxCNC definition. Not NIST.
132- comment = COMMENT_TYPE_SEMICOLON ;
133-
134- // TODO: Install '%' feature
135- // } else if (c == '%') {
136- // Program start-end percent sign NOT SUPPORTED.
137- // NOTE: This maybe installed to tell Grbl when a program is running vs manual input,
138- // where, during a program, the system auto-cycle start will continue to execute
139- // everything until the next '%' sign. This will help fix resuming issues with certain
140- // functions that empty the planner buffer to execute its task on-time.
104+ if ( uarm .effect_origin_check ){
105+ end_effector_check_limit ();
106+ }else {
107+ while ((c = serial_read ()) != SERIAL_NO_DATA ) {
108+ if ((c == '\n' ) || (c == '\r' )) { // End of line reached
109+ line [char_counter ] = 0 ; // Set string termination character.
110+ receive_cmd_line (line );
111+ comment = COMMENT_NONE ;
112+ char_counter = 0 ;
113+ break ;
114+ } else {
115+ if (comment != COMMENT_NONE ) {
116+ // Throw away all comment characters
117+ if (c == ')' ) {
118+ // End of comment. Resume line. But, not if semicolon type comment.
119+ if (comment == COMMENT_TYPE_PARENTHESES ) { comment = COMMENT_NONE ; }
120+ }
121+ } else {
122+ if (c <= ' ' ) {
123+ // Throw away whitepace and control characters
124+ } else if (c == '/' ) {
125+ // Block delete NOT SUPPORTED. Ignore character.
126+ // NOTE: If supported, would simply need to check the system if block delete is enabled.
127+ } else if (c == '(' ) {
128+ // Enable comments flag and ignore all characters until ')' or EOL.
129+ // NOTE: This doesn't follow the NIST definition exactly, but is good enough for now.
130+ // In the future, we could simply remove the items within the comments, but retain the
131+ // comment control characters, so that the g-code parser can error-check it.
132+ comment = COMMENT_TYPE_PARENTHESES ;
133+ } else if (c == ';' ) {
134+ // NOTE: ';' comment to EOL is a LinuxCNC definition. Not NIST.
135+ comment = COMMENT_TYPE_SEMICOLON ;
136+
137+ // TODO: Install '%' feature
138+ // } else if (c == '%') {
139+ // Program start-end percent sign NOT SUPPORTED.
140+ // NOTE: This maybe installed to tell Grbl when a program is running vs manual input,
141+ // where, during a program, the system auto-cycle start will continue to execute
142+ // everything until the next '%' sign. This will help fix resuming issues with certain
143+ // functions that empty the planner buffer to execute its task on-time.
141144
142- } else if (char_counter >= (LINE_BUFFER_SIZE - 1 )) {
143- // Detect line buffer overflow. Report error and reset line buffer.
144- report_status_message (STATUS_OVERFLOW );
145- comment = COMMENT_NONE ;
146- char_counter = 0 ;
147- } else if (c >= 'a' && c <= 'z' ) { // Upcase lowercase
148- line [char_counter ++ ] = c - 'a' + 'A' ;
149- } else {
150- line [char_counter ++ ] = c ;
151- }
152- }
153- }
154- }
155- parse_cmd_line ();
156-
157- // If there are no more characters in the serial read buffer to be processed and executed,
158- // this indicates that g-code streaming has either filled the planner buffer or has
159- // completed. In either case, auto-cycle start, if enabled, any queued moves.
160- //uarm_swift_tick_run();
161- protocol_auto_cycle_start ();
162- protocol_execute_realtime (); // Runtime command check point.
163- if (sys .abort ) { return ; } // Bail to main() program loop to reset system.
145+ } else if (char_counter >= (LINE_BUFFER_SIZE - 1 )) {
146+ // Detect line buffer overflow. Report error and reset line buffer.
147+ report_status_message (STATUS_OVERFLOW );
148+ comment = COMMENT_NONE ;
149+ char_counter = 0 ;
150+ } else if (c >= 'a' && c <= 'z' ) { // Upcase lowercase
151+ line [char_counter ++ ] = c - 'a' + 'A' ;
152+ } else {
153+ line [char_counter ++ ] = c ;
154+ }
155+ }
156+ }
157+ }
158+ //if( position_origin_flag && end_angle_origin_flag ){
159+ parse_cmd_line ();
160+ //}
161+
162+ // If there are no more characters in the serial read buffer to be processed and executed,
163+ // this indicates that g-code streaming has either filled the planner buffer or has
164+ // completed. In either case, auto-cycle start, if enabled, any queued moves.
165+ //uarm_swift_tick_run();
166+ protocol_auto_cycle_start ();
167+ protocol_execute_realtime (); // Runtime command check point.
168+ if (sys .abort ) { return ; } // Bail to main() program loop to reset system.
169+
170+ report_parse_result ();
171+ if ( uarm .motor_position_check ){
172+ check_motor_positon ();
173+ }
164174
165- report_parse_result ();
166- check_motor_positon ();
175+ }
167176 }
177+
168178 return ; /* Never reached */
169179}
170180
0 commit comments