Fixed code related to position reads

Make sure we don't send a 105 while waiting for position
Make sure we send a M114 immediately after G28, G29, G30
Better error timing for sending commands (less resend issues)
This commit is contained in:
Lars Brubaker 2017-04-11 10:41:23 -07:00
parent fb925df5c4
commit b2515aa2ac
3 changed files with 71 additions and 56 deletions

View file

@ -59,12 +59,19 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
{
}
public void Add(string line)
public void Add(string line, bool forceTopOfQueue = false)
{
// lock queue
lock (locker)
{
commandQueue.Add(line);
if (forceTopOfQueue)
{
commandQueue.Insert(0, line);
}
else
{
commandQueue.Add(line);
}
}
}

View file

@ -44,10 +44,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
public override string ReadLine()
{
if (nextReadTimeMs < UiThread.CurrentTimerMs
if (!PrinterConnectionAndCommunication.Instance.WatingForPositionRead
&& nextReadTimeMs < UiThread.CurrentTimerMs
&& PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
{
nextReadTimeMs = UiThread.CurrentTimerMs + 1000;
nextReadTimeMs = UiThread.CurrentTimerMs + 5000;
return "M105";
}