From 166fa305902bac56837b7c8e10a5d2c13d1a990a Mon Sep 17 00:00:00 2001 From: Wouter R Date: Mon, 10 Mar 2014 15:23:07 +0100 Subject: [PATCH 01/19] Replace 10sec wait loop construct for starting print3d servers with inotifyd. Guard print3d init script against repeated start invocation. --- Makefile | 4 +++- src/script/print3d-manager.sh | 14 +------------- src/script/print3d-new-device.sh | 14 ++++++++++++++ src/script/print3d-runner.sh | 0 src/script/print3d_init | 19 +++++++++++++++++-- 5 files changed, 35 insertions(+), 16 deletions(-) mode change 100644 => 100755 src/script/print3d-manager.sh create mode 100755 src/script/print3d-new-device.sh mode change 100644 => 100755 src/script/print3d-runner.sh mode change 100644 => 100755 src/script/print3d_init diff --git a/Makefile b/Makefile index 9f58d56..d347632 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,12 @@ include $(INCLUDE_DIR)/cmake.mk CMAKE_OPTIONS = -DLUAPATH=/usr/lib/lua +#Note: as mentioned in http://wiki.openwrt.org/doc/devel/dependencies, the inotifyd dep will not be checked on installation through opkg define Package/print3d SECTION:=mods CATEGORY:=Doodle3D TITLE:=3D printer driver - DEPENDS:=+uclibcxx +kmod-usb-acm +kmod-usb-serial +kmod-usb-serial-ftdi +libuci + DEPENDS:=+uclibcxx +kmod-usb-acm +kmod-usb-serial +kmod-usb-serial-ftdi +libuci +@BUSYBOX_CONFIG_INOTIFYD endef define Package/print3d/description @@ -43,6 +44,7 @@ define Package/print3d/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d_init $(1)/etc/init.d/print3d $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-manager.sh $(1)/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-runner.sh $(1)/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-new-device.sh $(1)/bin/ endef define Package/print3d/postinst diff --git a/src/script/print3d-manager.sh b/src/script/print3d-manager.sh old mode 100644 new mode 100755 index 41feab6..2f14601 --- a/src/script/print3d-manager.sh +++ b/src/script/print3d-manager.sh @@ -8,16 +8,4 @@ PRINT3D_RES_PATH=/tmp PRINT3D_RUNNER=/bin/print3d-runner.sh -sleep 10 -while true; do - for DEV in $(ls /dev/ttyACM* /dev/ttyUSB*); do - DEVBASE=`basename ${DEV}` - SOCKET=$PRINT3D_RES_PATH/print3d-${DEVBASE} - if [ ! -S $SOCKET ]; then - $PRINT3D_RUNNER ${DEVBASE} & - #disown $$ - sleep 2 - fi - done - sleep 5 -done +inotifyd /bin/print3d-new-device.sh /dev:n diff --git a/src/script/print3d-new-device.sh b/src/script/print3d-new-device.sh new file mode 100755 index 0000000..101f8be --- /dev/null +++ b/src/script/print3d-new-device.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +PRINT3D_RES_PATH=/tmp +PRINT3D_RUNNER=/bin/print3d-runner.sh + +DEVBASE=`dmesg | tail -2 | sed -n -e 's/.*\(tty\w*\).*/\1/p'` +SOCKET=$PRINT3D_RES_PATH/print3d-${DEVBASE} + +logger -t print3d-mgr "Starting print3d server for /dev/$DEVBASE" +if [ ! -S $SOCKET ]; then + $PRINT3D_RUNNER ${DEVBASE} & + #disown $$ + sleep 2 +fi diff --git a/src/script/print3d-runner.sh b/src/script/print3d-runner.sh old mode 100644 new mode 100755 diff --git a/src/script/print3d_init b/src/script/print3d_init old mode 100644 new mode 100755 index 018f5c9..82502f1 --- a/src/script/print3d_init +++ b/src/script/print3d_init @@ -8,14 +8,29 @@ START=99 start() { + ps | grep 'print3d-manager.sh' | grep -v grep > /dev/null 2> /dev/null + if [ $? -eq 0 ]; then + echo "print3d manager already running" + exit 1 + fi + + logger -t print3d-mgr "Starting print3d manager" + + /bin/print3d-manager.sh > /dev/null 2> /dev/null & + + #Note: power cycling the USB port also causes inotifyd to detect an 'already connected' device echo 0 > /sys/devices/virtual/gpio/gpio8/value sleep 1 echo 1 > /sys/devices/virtual/gpio/gpio8/value - - /bin/print3d-manager.sh > /dev/null 2> /dev/null & } stop() { + #Note: this method of stopping processes is too coarse, it should keep pid files or something similar + #and print3d-runner.sh should use an exit handler (`trap exit_handler TERM`) to make sure the socket is removed + + logger -t print3d-mgr "Stopping print3d manager" + #P3D_MGR_PID=`pidof print3d-manager.sh` killall print3d-manager.sh + killall inotifyd killall print3d } From c9b3513c0d61cd5931a7e488fabcdff912a2f786 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Thu, 20 Mar 2014 21:37:09 +0100 Subject: [PATCH 02/19] Move print3d scripts to a better location (see: http://www.linuxbase.org/betaspecs/fhs/fhs/ch04s07.html). Fix dependency on busybox. --- Makefile | 9 +++++---- src/script/print3d-manager.sh | 5 +---- src/script/print3d-new-device.sh | 7 ++++++- src/script/print3d_init | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d347632..b4e834a 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ define Package/print3d SECTION:=mods CATEGORY:=Doodle3D TITLE:=3D printer driver - DEPENDS:=+uclibcxx +kmod-usb-acm +kmod-usb-serial +kmod-usb-serial-ftdi +libuci +@BUSYBOX_CONFIG_INOTIFYD + DEPENDS:=+uclibcxx +kmod-usb-acm +kmod-usb-serial +kmod-usb-serial-ftdi +libuci +@BUSYBOX_CUSTOM +@BUSYBOX_CONFIG_INOTIFYD endef define Package/print3d/description @@ -34,6 +34,7 @@ endef define Package/print3d/install $(INSTALL_DIR) $(1)/bin + $(INSTALL_DIR) $(1)/usr/libexec $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/usr/lib/lua @@ -42,9 +43,9 @@ define Package/print3d/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/frontends/lua/print3d.so $(1)/usr/lib/lua/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d_init $(1)/etc/init.d/print3d - $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-manager.sh $(1)/bin/ - $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-runner.sh $(1)/bin/ - $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-new-device.sh $(1)/bin/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-manager.sh $(1)/usr/libexec/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-runner.sh $(1)/usr/libexec/ + $(INSTALL_BIN) $(PKG_BUILD_DIR)/script/print3d-new-device.sh $(1)/usr/libexec/ endef define Package/print3d/postinst diff --git a/src/script/print3d-manager.sh b/src/script/print3d-manager.sh index 2f14601..071cf4f 100755 --- a/src/script/print3d-manager.sh +++ b/src/script/print3d-manager.sh @@ -5,7 +5,4 @@ # This software is licensed under the terms of the GNU GPL v2 or later. # See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details. -PRINT3D_RES_PATH=/tmp -PRINT3D_RUNNER=/bin/print3d-runner.sh - -inotifyd /bin/print3d-new-device.sh /dev:n +inotifyd /usr/libexec/print3d-new-device.sh /dev:n diff --git a/src/script/print3d-new-device.sh b/src/script/print3d-new-device.sh index 101f8be..837c22e 100755 --- a/src/script/print3d-new-device.sh +++ b/src/script/print3d-new-device.sh @@ -1,7 +1,12 @@ #!/bin/sh +# This file is part of the Doodle3D project (http://doodle3d.com). +# +# Copyright (c) 2013, Doodle3D +# This software is licensed under the terms of the GNU GPL v2 or later. +# See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details. PRINT3D_RES_PATH=/tmp -PRINT3D_RUNNER=/bin/print3d-runner.sh +PRINT3D_RUNNER=/usr/libexec/print3d-runner.sh DEVBASE=`dmesg | tail -2 | sed -n -e 's/.*\(tty\w*\).*/\1/p'` SOCKET=$PRINT3D_RES_PATH/print3d-${DEVBASE} diff --git a/src/script/print3d_init b/src/script/print3d_init index 82502f1..505053f 100755 --- a/src/script/print3d_init +++ b/src/script/print3d_init @@ -16,7 +16,7 @@ start() { logger -t print3d-mgr "Starting print3d manager" - /bin/print3d-manager.sh > /dev/null 2> /dev/null & + /usr/libexec/print3d-manager.sh > /dev/null 2> /dev/null & #Note: power cycling the USB port also causes inotifyd to detect an 'already connected' device echo 0 > /sys/devices/virtual/gpio/gpio8/value From a94de0fa421c88a11cccedfd45623ae722341a78 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Thu, 20 Mar 2014 21:39:02 +0100 Subject: [PATCH 03/19] Eclipse-related changes. --- .cproject | 16 ++++++++-------- .settings/de.loskutov.anyedit.AnyEditTools.prefs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .settings/de.loskutov.anyedit.AnyEditTools.prefs diff --git a/.cproject b/.cproject index cc5305c..8d4971a 100644 --- a/.cproject +++ b/.cproject @@ -35,14 +35,14 @@ - - @@ -79,22 +79,22 @@ - - - @@ -118,10 +118,10 @@ - + - + diff --git a/.settings/de.loskutov.anyedit.AnyEditTools.prefs b/.settings/de.loskutov.anyedit.AnyEditTools.prefs new file mode 100644 index 0000000..09266be --- /dev/null +++ b/.settings/de.loskutov.anyedit.AnyEditTools.prefs @@ -0,0 +1,16 @@ +activeContentFilterList=*.makefile,makefile,*.Makefile,Makefile,Makefile.*,*.mk,MANIFEST.MF +addNewLine=true +convertActionOnSaave=AnyEdit.CnvrtTabToSpaces +eclipse.preferences.version=1 +ignoreBlankLinesWhenTrimming=false +inActiveContentFilterList= +javaTabWidthForJava=true +org.eclipse.jdt.ui.editor.tab.width=2 +projectPropsEnabled=false +removeTrailingSpaces=true +replaceAllSpaces=false +replaceAllTabs=false +saveAndAddLine=false +saveAndConvert=false +saveAndTrim=true +useModulo4Tabs=false From 3642afbdf752081fe962a60bf3dfaa77e7288add Mon Sep 17 00:00:00 2001 From: Wouter R Date: Sun, 23 Mar 2014 00:44:56 +0100 Subject: [PATCH 04/19] Add test for filtering pure comment line. --- src/unittest/server/t_GCodeBuffer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/unittest/server/t_GCodeBuffer.cpp b/src/unittest/server/t_GCodeBuffer.cpp index 934c39a..fd1c796 100644 --- a/src/unittest/server/t_GCodeBuffer.cpp +++ b/src/unittest/server/t_GCodeBuffer.cpp @@ -84,6 +84,11 @@ struct t_GCodeBuffer : public fructose::test_base { fructose_assert_eq(rv, true); fructose_assert_eq(lineBuf, "line "); + buffer.set("; pure comment"); + fructose_assert_eq(buffer.getTotalLines(), 0); + rv = buffer.getNextLine(lineBuf); + fructose_assert_eq(rv, false); + buffer.set("car+new mix\r\n\r\n\n\n\n"); fructose_assert_eq(buffer.getTotalLines(), 1); rv = buffer.getNextLine(lineBuf); From 2ed102ade767545e385d29b4a833b8acd631bbee Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Thu, 27 Mar 2014 11:09:47 +0100 Subject: [PATCH 05/19] MakerbotDriver: go to idle state when connected --- src/drivers/MakerbotDriver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/drivers/MakerbotDriver.cpp b/src/drivers/MakerbotDriver.cpp index 9ab5d06..247aec3 100644 --- a/src/drivers/MakerbotDriver.cpp +++ b/src/drivers/MakerbotDriver.cpp @@ -468,6 +468,7 @@ int MakerbotDriver::parseResponse(int cmd, int toolcmd) { else if (toolcmd==32) targetTemperature_ = t; else if (toolcmd==33) targetBedTemperature_ = t; else LOG(Logger::WARNING, "parseResponse: unrecognized or missing tool command (%u)", toolcmd); + if(getState() == CONNECTING) setState(IDLE); // we have communication break; } case 3: break; //clear buffer case 7: break; //abort From 7d362b07f6f0bf32cd012e131bf44f6489e01f5c Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Thu, 10 Apr 2014 13:13:41 +0200 Subject: [PATCH 06/19] build-local contains bash-isms. depend on bash The *buntu's come with dash as the default shell and build-local.sh fails to build because of it as it requires bash. Signed-off-by: Olliver Schinagl --- build-local.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-local.sh b/build-local.sh index 7d565cb..610a3af 100755 --- a/build-local.sh +++ b/build-local.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash MAKE=make CMAKE=cmake From 1873c0ed370d03d583aeb0d351c1d71448dc2335 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Fri, 11 Apr 2014 23:52:25 +0200 Subject: [PATCH 07/19] Git should not track *~ and .*.swp files *~ and .*.swp files are backup files used by editors. Git should always ignore them. Signed-off-by: Olliver Schinagl --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e0a29b1..5ad41d8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ src/*.o src/print3d src/Testing build +*~ +.*.swp From 3d56599d2d3bedb7fe0d89147c45455035ded966 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 14 Apr 2014 11:26:31 +0200 Subject: [PATCH 08/19] Add missing algorithm.h define for std::count std::count requires algorithm.h to be included or the compiler gives an error. Signed-off-by: Olliver Schinagl --- src/drivers/GCodeBuffer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/drivers/GCodeBuffer.cpp b/src/drivers/GCodeBuffer.cpp index e3a7076..6ed6a1f 100644 --- a/src/drivers/GCodeBuffer.cpp +++ b/src/drivers/GCodeBuffer.cpp @@ -7,6 +7,7 @@ */ #include "GCodeBuffer.h" +#include #include #include using std::string; From d17f895e2bd3aba332633960cbb3fa8ea0177393 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 14 Apr 2014 11:24:18 +0200 Subject: [PATCH 09/19] Fix compiler warnings/errors due to wrong types The compiler warns and errors due to the mis-use of unsigned vs signed and size_t vs int in the unittests. Signed-off-by: Olliver Schinagl --- src/unittest/include/fructose/test_root.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unittest/include/fructose/test_root.h b/src/unittest/include/fructose/test_root.h index 00729fc..716a31e 100644 --- a/src/unittest/include/fructose/test_root.h +++ b/src/unittest/include/fructose/test_root.h @@ -510,7 +510,7 @@ class test_root private: void split(std::vector &tokens, const std::string& text, char sep) { - int start = 0, end = 0; + unsigned int start = 0, end = 0; while ((end = text.find(sep, start)) != std::string::npos) { tokens.push_back(text.substr(start, end - start)); start = end + 1; @@ -773,7 +773,7 @@ test_root::do_get_suite(const test_root::suite& available_tests, test_info current_test_info; bool include_all = false; - for (size_t i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) { if (found_tests) { From 97dbd271d31807d1dd923c41253c205b41c68e26 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 14 Apr 2014 11:28:20 +0200 Subject: [PATCH 10/19] Correct the usage of %zi vs %d in printf currentLine, totalLines, bufferedLines are all ints and thus do not require the 'z' length modifier that is required for size_t. Signed-off-by: Olliver Schinagl --- src/frontends/cmdline/actions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontends/cmdline/actions.c b/src/frontends/cmdline/actions.c index 3f1717c..14005d2 100644 --- a/src/frontends/cmdline/actions.c +++ b/src/frontends/cmdline/actions.c @@ -196,7 +196,7 @@ static int act_printProgress() { comm_closeSocket(); - printf("print progress: %zi of %zi lines (%zi buffered)", currentLine, totalLines, bufferedLines); + printf("print progress: %d of %d lines (%d buffered)", currentLine, totalLines, bufferedLines); if (totalLines != 0) printf(" (%.1f%%)", (float)currentLine / totalLines * 100); printf("\n"); From aeb427f699d2020d20c54ffe1dcdca289eb5f417 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 14 Apr 2014 11:36:10 +0200 Subject: [PATCH 11/19] Add a -p option to choose which printer the print server controls When not using UCI to obtain the configuration settings, a dummy variable forces a makerbot (or whatever printer) as default. Using -p one of the available printers can be configured via the commandline. When -p is not supplied, uci (or the dummy var) is used instead. Missing still is to print the list of available printers when using -p help or an empty -p. Since there is a function in the 'TODO' area to print a list of printers, this item is also TODO. Signed-off-by: Olliver Schinagl --- src/server/Server.cpp | 10 ++++++++-- src/server/Server.h | 2 +- src/server/main.cpp | 14 +++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/server/Server.cpp b/src/server/Server.cpp index ce94011..5160eab 100644 --- a/src/server/Server.cpp +++ b/src/server/Server.cpp @@ -32,13 +32,19 @@ const bool Server::FORK_BY_DEFAULT = false; const int Server::SOCKET_MAX_BACKLOG = 5; //private const int Server::SELECT_LOG_FAST_LOOP = -1; -Server::Server(const string& serialPortPath, const string& socketPath) : +Server::Server(const string& serialPortPath, const string& socketPath, const string& printerName) : socketPath_(socketPath), log_(Logger::getInstance()), socketFd_(-1), printerDriver_(0) { if (!settings_init()) LOG(Logger::ERROR, "could not initialize uci settings context"); const char *uci_key = "wifibox.general.printer_type"; - const char *printerType = settings_get(uci_key); + const char *printerType; + + if (printerName.empty()) + printerType = settings_get(uci_key); + else + printerType = printerName.c_str(); + if (printerType) { LOG(Logger::INFO, "printer type from settings: '%s'", printerType); printerDriver_ = DriverFactory::createDriver(printerType, *this, serialPortPath, 115200); diff --git a/src/server/Server.h b/src/server/Server.h index f45e32f..1c660c4 100644 --- a/src/server/Server.h +++ b/src/server/Server.h @@ -25,7 +25,7 @@ class Server { typedef std::vector vec_ClientP; typedef std::set set_int; - Server(const std::string& serialPortName, const std::string& socketPath); + Server(const std::string& serialPortName, const std::string& socketPath, const std::string& printerName); ~Server(); int start(bool fork = FORK_BY_DEFAULT); diff --git a/src/server/main.cpp b/src/server/main.cpp index a5ad5d3..e5fe45b 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -29,18 +29,20 @@ static struct option long_options[] = { {"no-fork", no_argument, NULL, 'F'}, {"force", no_argument, NULL, 'S'}, {"device", required_argument, NULL, 'd'}, + {"printer", required_argument, NULL, 'p'}, {NULL, 0, NULL, 0} }; int main(int argc, char** argv) { string serialDevice = ""; + string printerName = ""; int doFork = 0; //-1: don't fork, 0: leave default, 1: do fork bool showHelp = false, forceStart = false; Logger::ELOG_LEVEL logLevel = Logger::WARNING; char ch; - while ((ch = getopt_long(argc, argv, "hQqvVfFSd:", long_options, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "hQqvVfFSd:p:", long_options, NULL)) != -1) { switch (ch) { case 'h': showHelp = true; break; case 'Q': logLevel = Logger::QUIET; break; @@ -51,6 +53,7 @@ int main(int argc, char** argv) { case 'F': doFork = -1; break; case 'S': forceStart = true; break; case 'd': serialDevice = optarg; break; + case 'p': printerName = optarg; break; } } @@ -78,6 +81,7 @@ int main(int argc, char** argv) { printf("\t-F,--no-fork\t\tDo not fork the server process\n"); printf("\t-S,--force\t\tForce starting the server with a default device if none could be found\n"); printf("\t-d,--device\t\tThe printer serial device to use (any prefix path will be cut off)\n"); + printf("\t-p,--printer\t\tThe 3D printer driver to use (use help to get more information)\n"); ::exit(0); } @@ -111,13 +115,17 @@ int main(int argc, char** argv) { size_t lastSlash = serialDevice.rfind('/'); if (lastSlash != string::npos) serialDevice = serialDevice.substr(lastSlash + 1); } - std::cout << "Using printer device: '" << serialDevice << "'" << endl; + std::cout << "printer type: '" << printerName << "'" << endl; + if (printerName.compare("help") == 0) { + // TODO: print list of available printers. + } + Logger& log = Logger::getInstance(); log.open(stderr, logLevel); - Server s("/dev/" + serialDevice, ipc_construct_socket_path(serialDevice.c_str())); + Server s(printerName, "/dev/" + serialDevice, ipc_construct_socket_path(serialDevice.c_str())); int rv; From f3a57bb2bbbbfde341d268bae252443916f226e9 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 14 Apr 2014 11:30:34 +0200 Subject: [PATCH 12/19] Require a device ID for several actions, fixes segfault THe AT_GET_TEST an AT_GET_PROGRESS actions require a device ID when, also when called from -g. If this is not done, calling these actions via -g causes segfaults. Signed-off-by: Olliver Schinagl --- src/frontends/cmdline/fe_cmdline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/frontends/cmdline/fe_cmdline.c b/src/frontends/cmdline/fe_cmdline.c index 07798ce..53d4678 100644 --- a/src/frontends/cmdline/fe_cmdline.c +++ b/src/frontends/cmdline/fe_cmdline.c @@ -62,8 +62,10 @@ void parseOptions(int argc, char **argv) { deviceIdRequired = 1; } else if (strcmp(optarg, "test") == 0) { action = AT_GET_TEST; + deviceIdRequired = 1; } else if (strcmp(optarg, "progress") == 0) { action = AT_GET_PROGRESS; + deviceIdRequired = 1; } break; case 't': From 62928f62aab0936a43ae7379a3d4c00ebf79564a Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 14 Apr 2014 11:39:37 +0200 Subject: [PATCH 13/19] Fix segfault when doing serial communication. The serial module does not account for the \0 character when mallocing. Request 1 extra byte of memory to account for \0. Signed-off-by: Olliver Schinagl --- src/drivers/Serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/Serial.cpp b/src/drivers/Serial.cpp index 0252487..35b71b1 100644 --- a/src/drivers/Serial.cpp +++ b/src/drivers/Serial.cpp @@ -293,7 +293,7 @@ string* Serial::extractLine() { if (p == buffer_ + bufferSize_) return NULL; int lineLen = p - buffer_; - char* lineCopy = (char*)malloc(lineLen); + char* lineCopy = (char*)malloc(lineLen + 1); memcpy(lineCopy, buffer_, lineLen); //this is rather ugly but at least it should work... From 7b01f602ad733eecac389b11e01b7a90aabb9808 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Tue, 29 Apr 2014 13:26:27 +0000 Subject: [PATCH 14/19] Use getopt's api as intended, store the return value in an int, not char getopt returns an integer which is -1 when there is no more options left to be parsed. Currently this result is stored in a char, which by definition is undefined whether it is signed or unsigned. On ARM it may be unsigned and thus -1 never happens. Signed-off-by: Olliver Schinagl --- src/frontends/cmdline/fe_cmdline.c | 2 +- src/server/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontends/cmdline/fe_cmdline.c b/src/frontends/cmdline/fe_cmdline.c index 53d4678..40c6141 100644 --- a/src/frontends/cmdline/fe_cmdline.c +++ b/src/frontends/cmdline/fe_cmdline.c @@ -50,7 +50,7 @@ static ACTION_TYPE action = AT_NONE; void parseOptions(int argc, char **argv) { - char ch; + int ch; while ((ch = getopt_long(argc, argv, "hqvg:tpsd:Fw:f:c:rkK:", long_options, NULL)) != -1) { switch (ch) { case 'h': action = AT_SHOW_HELP; break; diff --git a/src/server/main.cpp b/src/server/main.cpp index e5fe45b..d4eafe4 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) { int doFork = 0; //-1: don't fork, 0: leave default, 1: do fork bool showHelp = false, forceStart = false; Logger::ELOG_LEVEL logLevel = Logger::WARNING; - char ch; + int ch; while ((ch = getopt_long(argc, argv, "hQqvVfFSd:p:", long_options, NULL)) != -1) { switch (ch) { From 72b4ab55736edeefdec9a94fba21d05b291aa027 Mon Sep 17 00:00:00 2001 From: Wouter R Date: Thu, 1 May 2014 14:48:35 +0200 Subject: [PATCH 15/19] Improve handling of cmdline options in server. Add support to list supprted printer drivers and supported models. Fix CMakeLists.txt to build with all warnings enabled. Remove dummy printer type from settings.c. Fix wrong type in test_root.h. Minor stylistic changes. --- src/CMakeLists.txt | 4 +- src/drivers/AbstractDriver.h | 4 ++ src/drivers/DriverFactory.cpp | 70 ++++++++++++----------- src/drivers/DriverFactory.h | 7 +-- src/drivers/MakerbotDriver.cpp | 2 + src/drivers/MarlinDriver.cpp | 2 + src/server/Server.cpp | 17 +++--- src/server/Server.h | 2 +- src/server/main.cpp | 52 +++++++++++++---- src/settings.c | 7 --- src/unittest/include/fructose/test_root.h | 2 +- 11 files changed, 103 insertions(+), 66 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 19543d9..3b0801d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,8 +6,8 @@ if(APPLE) set(CMAKE_OSX_ARCHITECTURES x86_64;i386) endif() -#add_definitions(-Wall -Werror) -add_definitions(-Wall) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") option(GENERATE_DOCS "generate documentation" OFF) #option(PRINT3D_DEBUG "debugging support" OFF) diff --git a/src/drivers/AbstractDriver.h b/src/drivers/AbstractDriver.h index 0e8a34a..af81966 100644 --- a/src/drivers/AbstractDriver.h +++ b/src/drivers/AbstractDriver.h @@ -27,12 +27,16 @@ class AbstractDriver { : name(n) {} }; + // typedef (shorthand) for list of firmware descriptions typedef std::vector vec_FirmwareDescription; + // typedef (shorthand) for create instance function of driver typedef AbstractDriver* (*creatorFunc)(Server& server, const std::string& serialPortPath, const uint32_t& baudrate); + // driver info per driver (used in DriverFactory) struct DriverInfo { + std::string name; vec_FirmwareDescription supportedFirmware; creatorFunc creator; //pointer to driver's create function }; diff --git a/src/drivers/DriverFactory.cpp b/src/drivers/DriverFactory.cpp index b737e3a..932455e 100644 --- a/src/drivers/DriverFactory.cpp +++ b/src/drivers/DriverFactory.cpp @@ -15,37 +15,41 @@ AbstractDriver* DriverFactory::createDriver(const std::string& driverName, Server& server, const std::string& serialPortPath, const uint32_t& baudrate) { - static vec_DriverInfoP driverInfos; - - //LOG(Logger::VERBOSE, "createDriver()"); - - // list all printer drivers (their driver info) - if(driverInfos.empty()) { - driverInfos.push_back( &MarlinDriver::getDriverInfo() ); - driverInfos.push_back(&MakerbotDriver::getDriverInfo()); - LOG(Logger::VERBOSE, " num drivers: %i",driverInfos.size()); - } - - // loop trough driver info's - vec_DriverInfoP::iterator d; - for (d = driverInfos.begin(); - d != driverInfos.end(); - ++d) { - const AbstractDriver::DriverInfo& di = **d; - - // loop trough driver info's supported firmware - AbstractDriver::vec_FirmwareDescription::const_iterator f; - for (f = di.supportedFirmware.begin(); - f != di.supportedFirmware.end(); - ++f) { - - //LOG(Logger::VERBOSE, " firmware name: %s",(*f).name.c_str()); - // if match create driver instance - if((*f).name == driverName) { - LOG(Logger::INFO, "Created firmware: %s",(*f).name.c_str()); - return di.creator(server, serialPortPath,baudrate); - } - } - } - return 0; + const vec_DriverInfoP& driverInfos = getDriverInfo(); + + //LOG(Logger::VERBOSE, "createDriver()"); + LOG(Logger::VERBOSE, " num drivers: %i",driverInfos.size()); + + // loop trough driver info's + vec_DriverInfoP::const_iterator d; + for (d = driverInfos.begin(); d != driverInfos.end(); ++d) { + const AbstractDriver::DriverInfo& di = **d; + + // loop trough driver info's supported firmware + AbstractDriver::vec_FirmwareDescription::const_iterator f; + for (f = di.supportedFirmware.begin(); + f != di.supportedFirmware.end(); + ++f) { + + //LOG(Logger::VERBOSE, " firmware name: %s",(*f).name.c_str()); + // if match create driver instance + if((*f).name == driverName) { + LOG(Logger::INFO, "Created firmware: %s",(*f).name.c_str()); + return di.creator(server, serialPortPath, baudrate); + } + } + } + + return 0; +} + +const DriverFactory::vec_DriverInfoP& DriverFactory::getDriverInfo() { + static vec_DriverInfoP driverInfos; + + if(driverInfos.empty()) { + driverInfos.push_back( &MarlinDriver::getDriverInfo()); + driverInfos.push_back(&MakerbotDriver::getDriverInfo()); + } + + return driverInfos; } diff --git a/src/drivers/DriverFactory.h b/src/drivers/DriverFactory.h index b121f9f..8f234ad 100644 --- a/src/drivers/DriverFactory.h +++ b/src/drivers/DriverFactory.h @@ -16,17 +16,16 @@ class DriverFactory { public: + typedef std::vector vec_DriverInfoP; + static AbstractDriver* createDriver(const std::string& driverName, Server& server, const std::string& serialPortPath, const uint32_t& baudrate); + static const vec_DriverInfoP& getDriverInfo(); private: - typedef std::vector vec_DriverInfoP; - /* * TODO: * - function to check whether a given driver instance is still correct for current config; * and return a new instance of correct type if not (use copy constructor of driver classes to clone) - * - provide function to return all driver names - * - convencience function to return all supported printer types for all drivers (query each driver and collect results) */ }; diff --git a/src/drivers/MakerbotDriver.cpp b/src/drivers/MakerbotDriver.cpp index 247aec3..758e155 100644 --- a/src/drivers/MakerbotDriver.cpp +++ b/src/drivers/MakerbotDriver.cpp @@ -193,6 +193,8 @@ const AbstractDriver::DriverInfo& MakerbotDriver::getDriverInfo() { static AbstractDriver::DriverInfo info; if (supportedFirmware.empty()) { + info.name = "Makerbot"; + supportedFirmware.push_back( AbstractDriver::FirmwareDescription("makerbot_replicator2") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("makerbot_replicator2x") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("makerbot_thingomatic") ); diff --git a/src/drivers/MarlinDriver.cpp b/src/drivers/MarlinDriver.cpp index 6cd5265..c524c1a 100644 --- a/src/drivers/MarlinDriver.cpp +++ b/src/drivers/MarlinDriver.cpp @@ -234,6 +234,8 @@ const AbstractDriver::DriverInfo& MarlinDriver::getDriverInfo() { static AbstractDriver::DriverInfo info; if (supportedFirmware.empty()) { + info.name = "Marlin"; + supportedFirmware.push_back( AbstractDriver::FirmwareDescription("rigidbot") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("ultimaker") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("ultimaker2") ); diff --git a/src/server/Server.cpp b/src/server/Server.cpp index 5160eab..4435c1d 100644 --- a/src/server/Server.cpp +++ b/src/server/Server.cpp @@ -40,19 +40,22 @@ Server::Server(const string& serialPortPath, const string& socketPath, const str const char *uci_key = "wifibox.general.printer_type"; const char *printerType; - if (printerName.empty()) + if (printerName.empty()) { printerType = settings_get(uci_key); - else + if (printerType) + LOG(Logger::INFO, "printer type from settings: '%s'", printerType); + else + LOG(Logger::ERROR, "could not retrieve printer type from settings"); + } else { printerType = printerName.c_str(); + LOG(Logger::INFO, "printer type from command line: '%s'", printerType); + } if (printerType) { - LOG(Logger::INFO, "printer type from settings: '%s'", printerType); printerDriver_ = DriverFactory::createDriver(printerType, *this, serialPortPath, 115200); - if (printerDriver_ == 0) { + + if (!printerDriver_) LOG(Logger::ERROR, "no printer driver found for type '%s'", printerType); - } - } else { - LOG(Logger::ERROR, "could not retrieve printer type from settings"); } driverDelay = 0; diff --git a/src/server/Server.h b/src/server/Server.h index 1c660c4..9601aa1 100644 --- a/src/server/Server.h +++ b/src/server/Server.h @@ -25,7 +25,7 @@ class Server { typedef std::vector vec_ClientP; typedef std::set set_int; - Server(const std::string& serialPortName, const std::string& socketPath, const std::string& printerName); + Server(const std::string& serialPortName, const std::string& socketPath, const std::string& printerName = ""); ~Server(); int start(bool fork = FORK_BY_DEFAULT); diff --git a/src/server/main.cpp b/src/server/main.cpp index d4eafe4..a8c46de 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -12,10 +12,12 @@ #include #include #include "../ipc_shared.h" +#include "../drivers/DriverFactory.h" #include "Logger.h" #include "Server.h" using std::string; +using std::cout; using std::cerr; using std::endl; @@ -54,6 +56,9 @@ int main(int argc, char** argv) { case 'S': forceStart = true; break; case 'd': serialDevice = optarg; break; case 'p': printerName = optarg; break; + + case ':': case '?': + ::exit(1); } } @@ -85,21 +90,41 @@ int main(int argc, char** argv) { ::exit(0); } + //handle the '-p help' case before looking for devices + if (printerName.compare("help") == 0) { + DriverFactory::vec_DriverInfoP infos = DriverFactory::getDriverInfo(); + cout << "Listing supported printer drivers and device models they support." << endl; + + for (DriverFactory::vec_DriverInfoP::const_iterator d_it = infos.begin(); + d_it != infos.end(); ++d_it) { + const AbstractDriver::DriverInfo* di = *d_it; + cout << "* Models supported by driver '" << di->name << "':"; + + for (AbstractDriver::vec_FirmwareDescription::const_iterator m_it = di->supportedFirmware.begin(); + m_it != di->supportedFirmware.end(); ++m_it) { + cout << " " << (*m_it).name; + } + cout << "." << endl; + } + + ::exit(0); + } + if (serialDevice.empty()) { char **devlist = ipc_find_devices(); if (!devlist) { //no list - cerr << "error retrieving device list (" << strerror(errno) << ")" << endl; + cerr << "Error: could not retrieve device list (" << strerror(errno) << ")." << endl; exit(1); } if (!devlist[0] && !forceStart) { //no devices and no force-start - cerr << "no devices found, please connect a printer or re-run with '-S'" << endl; + cerr << "Error: no devices found, please connect a printer or re-run with '-S'." << endl; ::exit(1); } else if (!devlist[0]) { //no devices but force-start requested serialDevice = IPC_DEFAULT_DEVICE_ID; } else if (devlist[1] != 0) { //more than one device - cerr << "more than one device found (listed below), please specify one of the following:" << endl; + cerr << "Error: more than one device found (listed below), please specify one of the following:" << endl; for (int i = 0; devlist[i] != 0; i++) { const char *item = devlist[i]; cerr << " '" << item << "'"; @@ -115,23 +140,28 @@ int main(int argc, char** argv) { size_t lastSlash = serialDevice.rfind('/'); if (lastSlash != string::npos) serialDevice = serialDevice.substr(lastSlash + 1); } - std::cout << "Using printer device: '" << serialDevice << "'" << endl; + cout << "Using printer device: '" << serialDevice << "'." << endl; - std::cout << "printer type: '" << printerName << "'" << endl; - if (printerName.compare("help") == 0) { - // TODO: print list of available printers. - } + if (!printerName.empty()) + cout << "Using printer type: '" << printerName << "'." << endl; + else + cout << "Using printer type from UCI configuration." << endl; Logger& log = Logger::getInstance(); log.open(stderr, logLevel); - Server s(printerName, "/dev/" + serialDevice, ipc_construct_socket_path(serialDevice.c_str())); + Server s("/dev/" + serialDevice, ipc_construct_socket_path(serialDevice.c_str()), printerName); + + if (!s.getDriver()) { + cerr << "Error: could not create printer driver." << endl; + ::exit(1); + } int rv; if (doFork == 0) rv = s.start(); else rv = s.start((doFork == 1) ? true : false); - if (rv >= 0) exit(0); - else exit(1); + if (rv >= 0) ::exit(0); + else ::exit(1); } diff --git a/src/settings.c b/src/settings.c index 84f45ff..2aebc1a 100644 --- a/src/settings.c +++ b/src/settings.c @@ -17,9 +17,6 @@ #ifdef USE_LIB_UCI static struct uci_context *ctx = NULL; -#else -//static const char *dummy_response = "ultimaker"; -static const char *dummy_response = "makerbot_generic"; #endif @@ -67,10 +64,6 @@ const char *settings_get(const char *uci_spec) { } #else - if (strcmp(uci_spec, "wifibox.general.printer_type") == 0) { - return dummy_response; - } else { return NULL; - } #endif } diff --git a/src/unittest/include/fructose/test_root.h b/src/unittest/include/fructose/test_root.h index 716a31e..ca71cbc 100644 --- a/src/unittest/include/fructose/test_root.h +++ b/src/unittest/include/fructose/test_root.h @@ -510,7 +510,7 @@ class test_root private: void split(std::vector &tokens, const std::string& text, char sep) { - unsigned int start = 0, end = 0; + std::string::size_type start = 0, end = 0; while ((end = text.find(sep, start)) != std::string::npos) { tokens.push_back(text.substr(start, end - start)); start = end + 1; From 6b51dc9055259baee76ae79fd601e9a4b8341ee5 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Wed, 21 May 2014 17:46:19 +0200 Subject: [PATCH 16/19] Comment in gcode issue fix 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove empty line at start of part that’s checked --- src/drivers/GCodeBuffer.cpp | 41 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/drivers/GCodeBuffer.cpp b/src/drivers/GCodeBuffer.cpp index 6ed6a1f..6bd0dc6 100644 --- a/src/drivers/GCodeBuffer.cpp +++ b/src/drivers/GCodeBuffer.cpp @@ -150,10 +150,13 @@ void GCodeBuffer::updateStats(string *buffer, size_t pos) { } void GCodeBuffer::cleanupGCode(string *buffer, size_t pos) { - //LOG(Logger::BULK, " cleanupGCode"); - //LOG(Logger::BULK, " buffer: "); - //LOG(Logger::BULK, " %s",buffer->c_str()); - + LOG(Logger::BULK, "cleanupGCode"); + LOG(Logger::BULK, " pos: %i",pos); + //if(pos >= 34957 && pos <= 35926) { + if(pos == 0) { + LOG(Logger::BULK, " ////////// buffer: "); + LOG(Logger::BULK, " \n%s\n////////// end buffer",buffer->c_str()); + } size_t buflen = buffer->length(); //replace \r with \n @@ -162,31 +165,49 @@ void GCodeBuffer::cleanupGCode(string *buffer, size_t pos) { //remove all comments (;...) std::size_t posComment = 0; while((posComment = buffer->find(';', pos)) != string::npos) { - //LOG(Logger::BULK, " posComment: %i",posComment); + LOG(Logger::BULK, " posComment: %i",posComment); size_t posCommentEnd = buffer->find('\n', posComment); - //LOG(Logger::BULK, " posCommentEnd: %i",posCommentEnd); + LOG(Logger::BULK, " posCommentEnd: %i",posCommentEnd); if(posCommentEnd == string::npos) { buffer->erase(posComment); - //LOG(Logger::BULK, " erase until npos"); + LOG(Logger::BULK, " erase until npos"); } else { buffer->erase(posComment, posCommentEnd - posComment); - //LOG(Logger::BULK, " erase: %i - %i",posComment,(posCommentEnd - posComment)); + LOG(Logger::BULK, " erase: %i - %i",posComment,(posCommentEnd - posComment)); } } +// if(pos >= 34957 && pos <= 37926) { + if(pos == 0) { + LOG(Logger::BULK, " ////////// >buffer: "); + LOG(Logger::BULK, " \n%s\n////////// end >buffer",buffer->c_str()); + } //replace \n\n with \n std::size_t posDoubleNewline = pos; + // -1 to make sure we also check the first line of the part we're checking + if(posDoubleNewline > 0) posDoubleNewline--; + LOG(Logger::BULK, " posDoubleNewline: %i",posDoubleNewline); while((posDoubleNewline = buffer->find("\n\n", posDoubleNewline)) != string::npos) { + LOG(Logger::BULK, " erase double lines: %i",posDoubleNewline); buffer->replace(posDoubleNewline, 2, "\n"); } +// if(pos >= 34957 && pos <= 37926) { + if(pos == 0) { + LOG(Logger::BULK, " ////////// >>buffer: "); + LOG(Logger::BULK, " \n%s\n////////// end >>buffer",buffer->c_str()); + } // remove empty first line if(buffer->find("\n",0) == 0) { buffer->erase(0, 1); + LOG(Logger::BULK, " erase first empty line"); } + // ToDo: remove last empty line? - //LOG(Logger::BULK, " >buffer: "); - //LOG(Logger::BULK, " %s",buffer->c_str()); +// if(pos >= 34957 && pos <= 37926) { + LOG(Logger::BULK, " ////////// >>>buffer: "); + LOG(Logger::BULK, " \n%s\n////////// end >>>buffer",buffer->c_str()); +// } bufferSize_ -= (buflen - buffer->length()); } From b3e796ef9d2f950f69aad4605fd4fbe3215a79fe Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Wed, 21 May 2014 22:15:19 +0200 Subject: [PATCH 17/19] Comment in geode issue fix 2 Make sure the buffer ends with an empty line, so new lines are added on their own line --- src/drivers/GCodeBuffer.cpp | 45 ++++++++++++++----------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/src/drivers/GCodeBuffer.cpp b/src/drivers/GCodeBuffer.cpp index 6bd0dc6..e94b5a1 100644 --- a/src/drivers/GCodeBuffer.cpp +++ b/src/drivers/GCodeBuffer.cpp @@ -150,13 +150,10 @@ void GCodeBuffer::updateStats(string *buffer, size_t pos) { } void GCodeBuffer::cleanupGCode(string *buffer, size_t pos) { - LOG(Logger::BULK, "cleanupGCode"); - LOG(Logger::BULK, " pos: %i",pos); - //if(pos >= 34957 && pos <= 35926) { - if(pos == 0) { - LOG(Logger::BULK, " ////////// buffer: "); - LOG(Logger::BULK, " \n%s\n////////// end buffer",buffer->c_str()); - } +// LOG(Logger::BULK, "cleanupGCode"); +// LOG(Logger::BULK, " pos: %i",pos); +// LOG(Logger::BULK, " ////////// buffer: "); +// LOG(Logger::BULK, " \n%s\n////////// end buffer",buffer->c_str()); size_t buflen = buffer->length(); //replace \r with \n @@ -165,49 +162,41 @@ void GCodeBuffer::cleanupGCode(string *buffer, size_t pos) { //remove all comments (;...) std::size_t posComment = 0; while((posComment = buffer->find(';', pos)) != string::npos) { - LOG(Logger::BULK, " posComment: %i",posComment); +// LOG(Logger::BULK, " posComment: %i",posComment); size_t posCommentEnd = buffer->find('\n', posComment); - LOG(Logger::BULK, " posCommentEnd: %i",posCommentEnd); +// LOG(Logger::BULK, " posCommentEnd: %i",posCommentEnd); if(posCommentEnd == string::npos) { buffer->erase(posComment); - LOG(Logger::BULK, " erase until npos"); +// LOG(Logger::BULK, " erase until npos"); } else { buffer->erase(posComment, posCommentEnd - posComment); - LOG(Logger::BULK, " erase: %i - %i",posComment,(posCommentEnd - posComment)); +// LOG(Logger::BULK, " erase: %i - %i",posComment,(posCommentEnd - posComment)); } } -// if(pos >= 34957 && pos <= 37926) { - if(pos == 0) { - LOG(Logger::BULK, " ////////// >buffer: "); - LOG(Logger::BULK, " \n%s\n////////// end >buffer",buffer->c_str()); - } //replace \n\n with \n std::size_t posDoubleNewline = pos; // -1 to make sure we also check the first line of the part we're checking if(posDoubleNewline > 0) posDoubleNewline--; - LOG(Logger::BULK, " posDoubleNewline: %i",posDoubleNewline); while((posDoubleNewline = buffer->find("\n\n", posDoubleNewline)) != string::npos) { - LOG(Logger::BULK, " erase double lines: %i",posDoubleNewline); +// LOG(Logger::BULK, " erase double lines: %i",posDoubleNewline); buffer->replace(posDoubleNewline, 2, "\n"); } -// if(pos >= 34957 && pos <= 37926) { - if(pos == 0) { - LOG(Logger::BULK, " ////////// >>buffer: "); - LOG(Logger::BULK, " \n%s\n////////// end >>buffer",buffer->c_str()); - } // remove empty first line if(buffer->find("\n",0) == 0) { buffer->erase(0, 1); LOG(Logger::BULK, " erase first empty line"); } - // ToDo: remove last empty line? -// if(pos >= 34957 && pos <= 37926) { - LOG(Logger::BULK, " ////////// >>>buffer: "); - LOG(Logger::BULK, " \n%s\n////////// end >>>buffer",buffer->c_str()); -// } + // Make sure we end with an empty line + char& lastChar = buffer->at(buffer->length()-1); + if(lastChar != '\n') { + buffer->append("\n"); +// LOG(Logger::BULK, " add empty line at end"); + } +// LOG(Logger::BULK, " ////////// >>>buffer: "); +// LOG(Logger::BULK, " \n%s\n////////// end >>>buffer",buffer->c_str()); bufferSize_ -= (buflen - buffer->length()); } From ad143903818fca8b2d43eca80e27db159414075c Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Thu, 22 May 2014 15:15:25 +0200 Subject: [PATCH 18/19] Added Builder3D printers to supported printers --- src/drivers/MarlinDriver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/drivers/MarlinDriver.cpp b/src/drivers/MarlinDriver.cpp index c524c1a..4c598d2 100644 --- a/src/drivers/MarlinDriver.cpp +++ b/src/drivers/MarlinDriver.cpp @@ -267,6 +267,8 @@ const AbstractDriver::DriverInfo& MarlinDriver::getDriverInfo() { supportedFirmware.push_back( AbstractDriver::FirmwareDescription("tantillus") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("minifactory") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("vision_3d_printer") ); + supportedFirmware.push_back( AbstractDriver::FirmwareDescription("builder3d") ); + supportedFirmware.push_back( AbstractDriver::FirmwareDescription("bigbuilder3d") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("marlin_generic") ); info.supportedFirmware = supportedFirmware; From c2af901ec7c747a939164678c265da3b9bf5ca65 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Wed, 28 May 2014 17:09:08 +0200 Subject: [PATCH 19/19] Added Mamba3D printer type --- src/drivers/MarlinDriver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/drivers/MarlinDriver.cpp b/src/drivers/MarlinDriver.cpp index 4c598d2..e59e292 100644 --- a/src/drivers/MarlinDriver.cpp +++ b/src/drivers/MarlinDriver.cpp @@ -269,6 +269,7 @@ const AbstractDriver::DriverInfo& MarlinDriver::getDriverInfo() { supportedFirmware.push_back( AbstractDriver::FirmwareDescription("vision_3d_printer") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("builder3d") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("bigbuilder3d") ); + supportedFirmware.push_back( AbstractDriver::FirmwareDescription("mamba3d") ); supportedFirmware.push_back( AbstractDriver::FirmwareDescription("marlin_generic") ); info.supportedFirmware = supportedFirmware;