I can handle populating the interpreter tool/offsets in suitable units when via my app, but the problem is if the running g-code switches G20/21, then I have no way of controlling what the interpreter does.
The easiest 'bodge' I can think would be to pre-scan the loaded file for G20/21, then prompt the user that units need to switched prior to running the file to ensure tools/offsets are in units to match the file.
I'll have a think about this.
Next query I have.
I'm working on the whole KFlop/PC communications. I'm working through the list of possible options (can so far Halt, EStop, Single Step and Run via a basic C program), but I'm needing a bit help to understand the conditions KMotionCNC applies to reading the MainStatus and calling ServiceKFlopCommands.-
Code: Select all
if (result == KMOTION_LOCKED)
{
m_ConnectedForStatus=true;
// Note only service the console
// after we have the token so we
// are sure of no getting blocked
TheFrame->KMotionDLL->ServiceConsole();
// upload bulk status
if (GetStatus())
{
Interpreter->Abort();
// error reading status
TheFrame->KMotionDLL->Failed();
m_ConnectedForStatus=false;
}
TheFrame->KMotionDLL->ReleaseToken();
UpdateScreen(m_ConnectedForStatus);
if (m_ConnectedForStatus)
ServiceKFLOPCommands();
}
else
{
m_ConnectedForStatus=false;
UpdateScreen(false);
}
Code: Select all
int CKMotionCNCDlg::GetStatus()
{
int i,result,n;
CString s;
int *p=(int *)&MainStatus;
int HostStatus=0;
if (ThreadIsExecuting) HostStatus += HOST_JOB_ACTIVE_BIT;
// KMotion is available read the status, include Job Status, and screen changes count
s.Format("GetStatus %x %x",HostStatus, Screen.EditScreenChangesCount);
if (TheFrame->KMotionDLL->WriteLine(s)) return 1;
n=sizeof(MainStatus)/sizeof(int);
s.Empty();
for (i=0; i<n; i++)
{
if (s.IsEmpty())
{
if (TheFrame->KMotionDLL->ReadLineTimeOut(s.GetBuffer(257),5000))
{
return 1;
}
s.ReleaseBuffer();
// change the CRLF at the to a space
s.Delete(s.GetLength()-2,2);
s += ' ';
}
// get a hex 32 bit int which may really be anything
result = sscanf(s.GetBuffer(0),"%8X",p++);
if (result!=1)
{
return 1;
}
if (s.GetLength() >=9)
{
s.Delete(0,9);
}
else
{
return 1;
}
// check if first word contains version
if (i==0)
{
if ((p[-1]>>16)==306) // check for previous version
{
}
if ((p[-1]>>16)==0)
{
// probably old version of DSP Code
// set version to something
MainStatus.VersionAndSize=0;
MainStatus.ThreadActive=0;
p[0] = p[-1];
p++;
n=n-2;
}
else
{
// update number of words to read
if (n!=(MainStatus.VersionAndSize & 0xffff))
{
int result = AfxMessageBox("Error: Status Record Size mismatch\r\r"
"Disable further status updates?",MB_ICONSTOP|MB_YESNO);
if (result == IDYES)
ReadStatus=false;
}
}
}
}
At the moment I have-
Code: Select all
if (!KFlopCommandInProgress)
{
int pc_comm = MainStatus.GetPC_comm(0);
if (pc_comm > 0)
{
KFlopCommandInProgress = true;
ServiceKFlopCommands(pc_comm);
}
}