From 11779b8f978ee61b84f974103b592b8b6b561584 Mon Sep 17 00:00:00 2001
From: Thomas Oster <thomas.oster@rwth-aachen.de>
Date: Thu, 23 Jul 2015 20:46:32 +0200
Subject: [PATCH] Make initializationLine less restrictive

---
 .../liblasercut/drivers/GenericGcodeDriver.java      | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java b/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java
index 9f4ff08..2ad5987 100644
--- a/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java
+++ b/src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java
@@ -357,6 +357,7 @@ public class GenericGcodeDriver extends LaserCutter {
     String line = "";
     while ("".equals(line))
     {//skip empty lines
+      //TODO: Add Timeout
       line = in.readLine();
     }
     System.out.println("< "+line);//TODO: remove
@@ -373,11 +374,16 @@ public class GenericGcodeDriver extends LaserCutter {
   {
     if (getIdentificationLine() != null && getIdentificationLine().length() > 0)
     {
-      String line = waitForLine();
-      if (!getIdentificationLine().equals(line))
+      String line = "";
+      for (int trials = 3; trials > 0; trials--)
       {
-        return line;
+        line = waitForLine();
+        if (line.startsWith(getIdentificationLine()))
+        {
+          return null;
+        }
       }
+      return line;
     }
     return null;
   }
-- 
GitLab