any way to control cnc from network? maybe Python?

More
27 Feb 2014 15:08 #44226 by cnccircuits
Hi,

I was wondering if it would be possible to control LinuxCNC via a network socket?

the idea i have is still in the early stages of development but i have built an application that can generate and send position data out of a socket that i would really like to have LinuxCNC somehow interpret.

now i could build my application to control the CNC directly but i would like to use LinuxCNC to keep track of my machines positions and for safety reasons.

i was thinking of an application flow similar to this.

both LinuxCNC and my application establish a connection.
my application instructs LinuxCNC to go home.
my application sends some gcode to instruct LinuxCNC to move to some location, then waits for acknowledgments when it gets there.

its pretty simple for starters but id really just like to test a few things and get my feet wet.

any ideas??

thanks.

Please Log in or Create an account to join the conversation.

More
27 Feb 2014 16:55 #44229 by ArcEye

Please Log in or Create an account to join the conversation.

More
28 Feb 2014 07:14 #44246 by cnccircuits
yep, that was exactly what i was looking for!!

one question though:
is there a way to invoke the "Home Axis" button the say was as if it were pressed by the user on the gui?

i see commands for homing each axis but this just sets them to 0 and retains the current position. i need a way to tell the machine to go and seek until the home switches have been detected.

And thanks for making me aware of linuxcncrsh!!

Please Log in or Create an account to join the conversation.

More
28 Feb 2014 17:19 #44254 by ArcEye

is there a way to invoke the "Home Axis" button the say was as if it were pressed by the user on the gui?


www.linuxcnc.org/docs/devel/html/gui/halui.html
specifically
halui.joint.<n>.home (bit, in) - pin for homing the specific joint

But what it does depends upon how your ini file is set

www.linuxcnc.org/docs/devel/html/config/...d_sub_axis_section_a
www.linuxcnc.org/docs/devel/html/config/...homing-configuration

regards
The following user(s) said Thank You: cnccircuits

Please Log in or Create an account to join the conversation.

More
01 Mar 2014 05:04 #44271 by cnccircuits
hi ArcEye,

thank you so much for your help. ive made far more progress then i initially thought i would have by now and i really like the interface!!
i havnt had a chance to modify my ini file for the homing operation yet but its defiantly on the agenda.

i know i have many questions (probably too many) but this forum always seems to have the answers, and im very grateful for that!

but to add to the list of question on this subject i seem to have run into yet another issue :p but its not very significant (though i would like to understand how to resolve these errors in my application).

when i start a typical session with linuxcncrsh and switch to mdi mode then issue an mdi command without the axis homed, i see the gui spit out an error "can't issue MDI command when not homed" but my telnet session doesn't reflect it. i have tried turning on verbose to no avail. i have also issued the command "get error" right after generating the error and linuxcncrsh only echos "ERROR OK".
is there any way to retrieve these errors?

Thanks again so very much for all your help and have a great day!! :D

Please Log in or Create an account to join the conversation.

More
01 Mar 2014 15:28 #44286 by ArcEye

when i start a typical session with linuxcncrsh and switch to mdi mode then issue an mdi command without the axis homed, i see the gui spit out an error "can't issue MDI command when not homed" but my telnet session doesn't reflect it. i have tried turning on verbose to no avail. i have also issued the command "get error" right after generating the error and linuxcncrsh only echos "ERROR OK".
is there any way to retrieve these errors?


I think the errors in linuxcncrsh are specific to its operation and do not reflect the linuxcnc errors, but I will look through the code later to check exactly what it does report

regards

Please Log in or Create an account to join the conversation.

More
01 Mar 2014 19:34 - 01 Mar 2014 21:16 #44291 by ArcEye
Whilst I think about it, have a look at this thread.
www.linuxcnc.org/index.php/english/forum...art-locks-up?limit=6

I don't think this was ever fixed, so if you get any lock ups, try to make sure you initiate things in the order shown and that should prevent them.

There was a problem with absolute and relative values being displayed incorrectly, but Andy pushed a patch for that quite some while back.

I'll come back to the errors when I have done some reading

regards
Last edit: 01 Mar 2014 21:16 by ArcEye.

Please Log in or Create an account to join the conversation.

More
02 Mar 2014 00:03 #44301 by ArcEye
Hi

I have done some digging and think I have an answer re the error query

It hinges I think, upon what is an 'error' and what is an advisory message

The code in linuxcncrsh, in fact checks 3 different types, error_string, operator_display_string and operator_display_text.

emcrsh.cc
static cmdResponseType getError(char *s, connectionRecType *context)
{
  const char *pErrorStr = "ERROR %s";
  
  if (updateError() != 0)
    sprintf(context->outBuf, pErrorStr, "emc_error: bad status from EMC");
  else
    if (error_string[0] == 0)
      sprintf(context->outBuf, pErrorStr, "OK");
    else {
      sprintf(context->outBuf, pErrorStr, error_string);
      error_string[0] = 0;
      }
  return rtNoError;
}

static cmdResponseType getOperatorDisplay(char *s, connectionRecType *context)
{
  const char *pOperatorDisplayStr = "OPERATOR_DISPLAY %s";
  
  if (updateError() != 0)
    sprintf(context->outBuf, pOperatorDisplayStr, "emc_operator_display: bad status from EMC");
  else
    if (operator_display_string[0] == 0)
      sprintf(context->outBuf, pOperatorDisplayStr, "OK");
    else {
      sprintf(context->outBuf, pOperatorDisplayStr, operator_display_string);
      operator_display_string[0] = 0;
      }
  return rtNoError; 
}

static cmdResponseType getOperatorText(char *s, connectionRecType *context)
{
  const char *pOperatorTextStr = "OPERATOR_TEXT %s";
  
  if (updateError() != 0)
    sprintf(context->outBuf, pOperatorTextStr, "emc_operator_text: bad status from EMC");
  else
    if (operator_text_string[0] == 0)
      sprintf(context->outBuf, pOperatorTextStr, "OK");
    else {
      sprintf(context->outBuf, pOperatorTextStr, operator_text_string);
      operator_text_string[0] = 0;
      }
  return rtNoError; 
}

To check it uses this function in shcom.cc
/*
  updateError() updates "errors," which are true errors and also
  operator display and text messages.
*/
int updateError()
{
    NMLTYPE type;

    if (0 == emcErrorBuffer || !emcErrorBuffer->valid()) {
	return -1;
    }

    switch (type = emcErrorBuffer->read()) {
    case -1:
	// error reading channel
	return -1;
	break;

    case 0:
	// nothing new
	break;

    case EMC_OPERATOR_ERROR_TYPE:
	strncpy(error_string,
		((EMC_OPERATOR_ERROR *) (emcErrorBuffer->get_address()))->
		error, LINELEN - 1);
	error_string[NML_ERROR_LEN - 1] = 0;
	break;

    case EMC_OPERATOR_TEXT_TYPE:
	strncpy(operator_text_string,
		((EMC_OPERATOR_TEXT *) (emcErrorBuffer->get_address()))->
		text, LINELEN - 1);
	operator_text_string[NML_TEXT_LEN - 1] = 0;
	break;

    case EMC_OPERATOR_DISPLAY_TYPE:
	strncpy(operator_display_string,
		((EMC_OPERATOR_DISPLAY *) (emcErrorBuffer->
					   get_address()))->display,
		LINELEN - 1);
	operator_display_string[NML_DISPLAY_LEN - 1] = 0;
	break;

    case NML_ERROR_TYPE:
	strncpy(error_string,
		((NML_ERROR *) (emcErrorBuffer->get_address()))->error,
		NML_ERROR_LEN - 1);
	error_string[NML_ERROR_LEN - 1] = 0;
	break;

    case NML_TEXT_TYPE:
	strncpy(operator_text_string,
		((NML_TEXT *) (emcErrorBuffer->get_address()))->text,
		NML_TEXT_LEN - 1);
	operator_text_string[NML_TEXT_LEN - 1] = 0;
	break;

    case NML_DISPLAY_TYPE:
	strncpy(operator_display_string,
		((NML_DISPLAY *) (emcErrorBuffer->get_address()))->display,
		NML_DISPLAY_LEN - 1);
	operator_display_string[NML_DISPLAY_LEN - 1] = 0;
	break;

    default:
	// if not recognized, set the error string
	sprintf(error_string, "unrecognized error %ld", type);
	return -1;
	break;
    }

    return 0;
}

The different strings are accessed with these commands

error
Returns the current EMC error string, or "ok" if no error.

operator_display
Returns the current EMC operator display string, or "ok" if none.

operator_text
Returns the current EMC operator text string, or "ok" if none.


I think you will find that trying to execute MDI before homed is not an 'error', because nothing went wrong, linuxcnc just refused the command because it did not have the 'homed' flag set.

Try the other commands in this situation and see what they return, I suspect one of them will contain the advisory message which appears in Axis

regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum