Page 1 of 1

External Command Error

Posted: Thu Jun 07, 2018 5:16 am
by Snyggis
Good Evening,

I am getting a strange error that I don't understand while running a C Program. A display window pops up in KMotionCNC which says "Invalid External Command Received". I have attached a screen shot. The only way to make it go away is to reboot the KFlop. I am running 434h.
The attachment Error Message.PNG is no longer available
It occurs when I run the program "Set Z Height.C" - AFTER - I have run the program "4X8 Router Tool Touch.c". It will not occur if I do not run "4X8 Router Tool Touch.c"

If I comment out this line it will not cause the error, but as soon as I remove the comment the error window pops up.
persist.UserData[ZOffset] = *(int *) & Offset; //Save offset as global variable

Does anyone know what I could be doing wrong? Been at it for a while and cant seem to make any sense of it.

Thanks!

Snyggis

Re: External Command Error

Posted: Thu Jun 07, 2018 5:19 am
by Snyggis
Not sure my attachments went through.

Re: External Command Error

Posted: Thu Jun 07, 2018 4:21 pm
by TomKerekes
Hi Snyggis,

You forgot to include your RouterIO.h file. But persist variables 100-107 are used to communicate commands to KMotionCNC so those aren't available for your use when using KMotionCNC. See PC-DSP.h file:

#define PC_COMM_PERSIST 100 // First Persist Variable that is uploaded in status
#define N_PC_COMM_PERSIST 8 // Number of Persist Variables that are uploaded in status

If you set a big value in Variable 100 KMotionCNC will try to interpret it as a command and report it as invalid.

HTH

Re: External Command Error

Posted: Thu Jun 07, 2018 10:05 pm
by Snyggis
Thanks Tom! That makes sense. In the example program that I copied the header file had the following:

#define TMP 10 // which spare persist to use to transfer data.

I was avoiding global variable 10, I guess that line means something else?

Here are the definitions from the header file, looks like I am using all of the global variables that I should not use.
#define ZOffset 100
#define S1Offset 101
#define S2Offset 102
#define S3Offset 103
#define S4Offset 104

Just change these to 50-54 and we should be good.

Thanks,

Snyggis

Re: External Command Error

Posted: Fri Jun 08, 2018 9:19 pm
by TomKerekes
Hi Snyggis,

Correct. The 100-107 variables are used to send commands and parameters to KMotionCNC. The TMP determines where KMotionCNC will place any returned values.

Hope that resolves the problem.