Access KMotion displayed position from C
Posted: Tue Feb 01, 2022 9:39 pm
Hello,
Is there an easy way to access the position of an axis from C?
We have an offset for our device so when I check ch0->Position I get "0" when the displayed X position is about 4 inches. That offset is set in our .set file in KMotionCNC. Those offset values also appear in the emc.var file in C:/KMotion435b/KMotion/Data. I've tried using the C commands fscanf() and sscanf() to read in those values but it seems like they either only pass in the first value in a line of text, or they grab the entire line. So I'm wondering if there are either:
1) A supported C command for parsing through files delimited by whitespace OR
2) An easy way to grab those values straight from memory similar to the channel values or the persist array
Note: It would be a hassle for us to just retype in all of these offsets as #define's, but that would be a solution, albeit a time-consuming one.
Is there an easy way to access the position of an axis from C?
We have an offset for our device so when I check ch0->Position I get "0" when the displayed X position is about 4 inches. That offset is set in our .set file in KMotionCNC. Those offset values also appear in the emc.var file in C:/KMotion435b/KMotion/Data. I've tried using the C commands fscanf() and sscanf() to read in those values but it seems like they either only pass in the first value in a line of text, or they grab the entire line. So I'm wondering if there are either:
1) A supported C command for parsing through files delimited by whitespace OR
2) An easy way to grab those values straight from memory similar to the channel values or the persist array
Note: It would be a hassle for us to just retype in all of these offsets as #define's, but that would be a solution, albeit a time-consuming one.