Two years ago you provided code for non-blocking service of a G43 G49 status LED, which worked great for me (thanks!);
https://www.cnczone.com/forums/dynomoti ... ost2231526
Code: Select all
#include "KMotionDef.h"
#define TMP 10 // which spare persist to use to transfer data
#include "KflopToKMotionCNCFunctions.c"
void ServiceToolOffsetMode(void);
main(){
for (;;){ // forever loop
ServiceToolOffsetMode();
}
}
#define STATUSBIT 46
// periodically set Virtual Bit based on Tool Table Index
// keeps track of state of sequence to always return immediately
void ServiceToolOffsetMode(void){
static BOOL WaitingForResponse = FALSE;
static double LastTime = 0;
int HWORD;
if (WaitingForResponse){ // Waiting for a response from the PC?
if (persist.UserData[PC_COMM_PERSIST] <= 0){ // Has PC Responded??
HWORD = persist.UserData[TMP + 2]; // Get Tool H Word
SetStateBit(STATUSBIT, HWORD != -1); // -1 indicates no active offset
LastTime = Time_sec();
WaitingForResponse = FALSE;
}
}
else{
if (Time_sec() > LastTime + 0.3){ // only request periodically
DoPCIntNoWait(PC_COMM_GET_MISC_SETTINGS, TMP); // Request settings from PC
WaitingForResponse = TRUE; // Remember we are waiting for a response
}
}
}
DoPCIntNoWait(PC_COMM_GET_MISC_SETTINGS, TMP);
for either of them. My goal is a non-blocking way to service the first two (left-to-right) of these three LEDs; I have three axes (X, Y, & Z), so calling both GetOriginOffset and GetAxisOffset, to check for reasonable non-zero values in all three axes, takes almost 1 second (or about 840,000 micro seconds - your non-blocking code only needs 2 micro seconds!).
If there is no way to use DoPCIntNoWait to get these answers, are there values on the KFLOP which could be checked (instead of calling KMotionCNC)? E.g. for the latter (AxisOffset), is there a way to get Vars[5211] (for X, and 5212 and 5213 for Y & Z) directly, and could they be tested to determine if a global offset is in effect (I think not, since after a G92.2, when the Internal Offset != Internal Var, a test would still return a yes, when the DRO was not being shifted.)?
Is there something similar for the former (Vars[?] for the OriginOffset values)?
I'm hoping to avoid adding a thread to continually service these two function calls.
Note; I've edited this post several times in an attempt to clarify my question and disclose my assumptions.