diff --git a/src/com/t_oster/liblasercut/LibInfo.java b/src/com/t_oster/liblasercut/LibInfo.java index 60801aa041d5b7532c074e3b6d60829c723605d9..dc823046f9d3a3f2f0b93b2ce65ab70a9fea1dfe 100644 --- a/src/com/t_oster/liblasercut/LibInfo.java +++ b/src/com/t_oster/liblasercut/LibInfo.java @@ -46,7 +46,8 @@ public class LibInfo SampleDriver.class, ExportSVG.class, GenericGcodeDriver.class, - SmoothieBoard.class + SmoothieBoard.class, + Marlin.class }; } } diff --git a/src/com/t_oster/liblasercut/drivers/Marlin.java b/src/com/t_oster/liblasercut/drivers/Marlin.java new file mode 100644 index 0000000000000000000000000000000000000000..4cad848d0b09da7802ddeb6b72426fa4013e4fe7 --- /dev/null +++ b/src/com/t_oster/liblasercut/drivers/Marlin.java @@ -0,0 +1,110 @@ +/** + * This file is part of LibLaserCut. + * Copyright (C) 2011 - 2014 Thomas Oster <mail@thomas-oster.de> + * + * LibLaserCut is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LibLaserCut is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibLaserCut. If not, see <http://www.gnu.org/licenses/>. + * + **/ +package com.t_oster.liblasercut.drivers; + +import com.t_oster.liblasercut.drivers.GenericGcodeDriver; +import java.io.IOException; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +/** + * This class implements a driver for the laser cutter fork of Marlin. + * + * @author quillford + */ +public class Marlin extends GenericGcodeDriver { + + public Marlin() + { + //set some Marlin specific defaults + setIdentificationLine("start"); + setWaitForOKafterEachLine(true); + setBaudRate(115200); + setLineend("CRLF"); + setInitDelay(10); + setPreJobGcode(getPreJobGcode()+",G28 XY,M3"); + setPostJobGcode(getPostJobGcode()+",G0 X0Y0,M5"); + + //Marlin has no way to upload over the network so remove the upload url text + setHttpUploadUrl(""); + setHost(""); + } + + @Override + public String getIdentificationLine() + { + return("start"); + } + + @Override + public String[] getPropertyKeys() + { + List<String> result = new LinkedList<String>(); + result.addAll(Arrays.asList(super.getPropertyKeys())); + result.remove(GenericGcodeDriver.SETTING_IDENTIFICATION_STRING); + result.remove(GenericGcodeDriver.SETTING_WAIT_FOR_OK); + result.remove(GenericGcodeDriver.SETTING_BAUDRATE); + result.remove(GenericGcodeDriver.SETTING_LINEEND); + result.remove(GenericGcodeDriver.SETTING_INIT_DELAY); + result.remove(GenericGcodeDriver.SETTING_HTTP_UPLOAD_URL); + result.remove(GenericGcodeDriver.SETTING_HOST); + return result.toArray(new String[0]); + } + + /** + * Waits for the Identification line and returns null if it's alright + * Otherwise it returns the wrong line + * @return + * @throws IOException + */ + @Override + protected String waitForIdentificationLine() throws IOException + { + if (getIdentificationLine() != null && getIdentificationLine().length() > 0) + { + String line = waitForLine(); + if (line.startsWith(getIdentificationLine())) + {//we received the identification line ("start"), now we have to skip the rest of Marlin's dump + while(!(waitForLine().startsWith("echo:SD"))) + { + //do nothing and wait until Marlin has dumped all of the settings + } + return null; + } + } + return null; + } + + + @Override + public String getModelName() + { + return "Marlin"; + } + + @Override + public Marlin clone() + { + Marlin clone = new Marlin(); + clone.copyProperties(this); + return clone; + } + +} \ No newline at end of file