コード例 #1
0
ファイル: cycle_homing.cpp プロジェクト: ADTL/g2
static stat_t _homing_axis_move(int8_t axis, float target, float velocity)
{
	float vect[] = {0,0,0,0,0,0};
	float flags[] = {false, false, false, false, false, false};

	vect[axis] = target;
	flags[axis] = true;
	cm_set_feed_rate(velocity);
	mp_flush_planner();										// don't use cm_request_queue_flush() here
	cm_request_cycle_start();
	ritorno(cm_straight_feed(vect, flags));
	return (STAT_EAGAIN);
}
コード例 #2
0
ファイル: macros.c プロジェクト: ustropo/MT01
stat_t feedRateOverride_Macro(void)
{
	switch (state)
	{
		case 0: cm_request_feedhold();
				state++; break;
		case 1: cm_request_cycle_start();
				state++; break;
		default:state = 0; macro_func_ptr = _command_dispatch; return (STAT_OK);
	}
	_execute_gcode_block();
	return (STAT_OK);
}
コード例 #3
0
ファイル: macros.c プロジェクト: ustropo/MT01
stat_t arcoOK_Macro(void)
{
	uint32_t lRet = pdFALSE;
	// set initial state for new move
//	memset(&gp, 0, sizeof(gp));						// clear all parser values
//	memset(&cm.gf, 0, sizeof(GCodeInput_t));		// clear all next-state flags
//	memset(&cm.gn, 0, sizeof(GCodeInput_t));		// clear all next-state values
//	cm.gn.motion_mode = cm_get_motion_mode(MODEL);	// get motion mode from previous block
	if (xMacroArcoOkSync == true)
	{
		switch (state)
		{
			case 0:	pl_arcook_start();
					lRet = xSemaphoreTake( xArcoOkSync, pdMS_TO_TICKS(3000) );
					if (lRet == pdFALSE)
					{
						uint32_t qSend = ARCO_OK_FAILED;
						xQueueSend( qKeyboard, &qSend, 0 );
						macro_func_ptr = command_idle;
						xMacroArcoOkSync = false;
			//			isCuttingSet(true);
						return (STAT_OK);
					}
					else
					{
						cm_request_cycle_start();
						stopDuringCut_Set(false);
						delay_thcStartStop(true);
						xMacroArcoOkSync = false; state = 0; macro_func_ptr = _command_dispatch; return (STAT_OK);
					}
					break;
			default:
					break;
		}
		_execute_gcode_block();
	}
	return (STAT_OK);
}
コード例 #4
0
ファイル: controller.c プロジェクト: leocafonso/MT01_grafico
stat_t _command_dispatch()
{
#ifdef __AVR
	stat_t status;

	// read input line or return if not a completed line
	// xio_gets() is a non-blocking workalike of fgets()
	while (true) {
		if ((status = xio_gets(cs.primary_src, cs.in_buf, sizeof(cs.in_buf))) == STAT_OK) {
			cs.bufp = cs.in_buf;
			break;
		}
		// handle end-of-file from file devices
		if (status == STAT_EOF) {						// EOF can come from file devices only
			if (cfg.comm_mode == TEXT_MODE) {
				fprintf_P(stderr, PSTR("End of command file\n"));
			} else {
				rpt_exception(STAT_EOF);				// not really an exception
			}
			tg_reset_source();							// reset to default source
		}
		return (status);								// Note: STAT_EAGAIN, errors, etc. will drop through
	}
#endif // __AVR
#ifdef __ARM
	// detect USB connection and transition to disconnected state if it disconnected
	if (SerialUSB.isConnected() == false) cs.state = CONTROLLER_NOT_CONNECTED;

	// read input line and return if not a completed line
	if (cs.state == CONTROLLER_READY) {
		if (read_line(cs.in_buf, &cs.read_index, sizeof(cs.in_buf)) != STAT_OK) {
			cs.bufp = cs.in_buf;
			return (STAT_OK);	// This is an exception: returns OK for anything NOT OK, so the idler always runs
		}
	} else if (cs.state == CONTROLLER_NOT_CONNECTED) {
		if (SerialUSB.isConnected() == false) return (STAT_OK);
		cm_request_queue_flush();
		rpt_print_system_ready_message();
		cs.state = CONTROLLER_STARTUP;

	} else if (cs.state == CONTROLLER_STARTUP) {		// run startup code
		cs.state = CONTROLLER_READY;

	} else {
		return (STAT_OK);
	}
	cs.read_index = 0;
#endif // __ARM
#ifdef __RX
	stat_t status;
	parse_gcode_func_selection(CODE_PARSER);
	// read input line or return if not a completed line
	// xio_gets() is a non-blocking workalike of fgets()
	while (true) {
		if ((status = xio_gets(cs.primary_src, cs.in_buf, sizeof(cs.in_buf))) == STAT_OK) {
			cs.bufp = cs.in_buf;
			break;
		}
		// handle end-of-file from file devices
		if (status == STAT_EOF) {						// EOF can come from file devices only
			//gfilerunning = false;
			xio_close(cs.primary_src);
//			macro_func_ptr = command_idle;
			if (cfg.comm_mode == TEXT_MODE) {
				fprintf_P(stderr, PSTR("End of command file\n"));
			} else {
				rpt_exception(STAT_EOF);				// not really an exception
			}
			tg_reset_source();							// reset to default source
		}
		return (status);								// Note: STAT_EAGAIN, errors, etc. will drop through
	}
#endif // __AVR
	// set up the buffers
	cs.linelen = strlen(cs.in_buf)+1;					// linelen only tracks primary input
	strncpy(cs.saved_buf, cs.bufp, SAVED_BUFFER_LEN-1);	// save input buffer for reporting

	// dispatch the new text line
	switch (toupper(*cs.bufp)) {						// first char

		case '!': { cm_request_feedhold(); break; }		// include for AVR diagnostics and ARM serial
		case '%': { cm_request_queue_flush(); break; }
		case '~': { cm_request_cycle_start(); break; }

		case NUL: { 									// blank line (just a CR)
			if (cfg.comm_mode != JSON_MODE) {
				text_response(STAT_OK, cs.saved_buf);
			}
			break;
		}
		case '$': case '?': case 'H': { 				// text mode input
			cfg.comm_mode = TEXT_MODE;
			text_response(text_parser(cs.bufp), cs.saved_buf);
			break;
		}
		case '{': { 									// JSON input
			cfg.comm_mode = JSON_MODE;
			json_parser(cs.bufp);
			break;
		}
		default: {										// anything else must be Gcode
			if (cfg.comm_mode == JSON_MODE) {			// run it as JSON...
				strncpy(cs.out_buf, cs.bufp, INPUT_BUFFER_LEN -8);					// use out_buf as temp
				sprintf((char *)cs.bufp,"{\"gc\":\"%s\"}\n", (char *)cs.out_buf);	// '-8' is used for JSON chars
				json_parser(cs.bufp);
			} else {									//...or run it as text
				text_response(gc_gcode_parser(cs.bufp), cs.saved_buf);
			}
		}
	}
	return (STAT_OK);
}