Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
peteruithoven committed May 28, 2014
2 parents 772d22f + c2af901 commit 9297117
Show file tree
Hide file tree
Showing 25 changed files with 220 additions and 108 deletions.
16 changes: 8 additions & 8 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.base.1393411930" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
<option id="gnu.both.asm.option.include.paths.483079410" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<option id="gnu.both.asm.option.include.paths.483079410" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/opt/local/include"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1533646304" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.242196438" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base.1672574065" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option id="gnu.cpp.compiler.option.include.paths.517459043" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<option id="gnu.cpp.compiler.option.include.paths.517459043" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/opt/local/include"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.846371916" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
Expand Down Expand Up @@ -79,22 +79,22 @@
<builder arguments="-C build/${ConfigName}" buildPath="" command="make" enableAutoBuild="true" id="cdt.managedbuild.target.gnu.builder.macosx.base.1826285585" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.macosx.base"/>
<tool id="cdt.managedbuild.tool.macosx.c.linker.macosx.base.210798062" name="MacOS X C Linker" superClass="cdt.managedbuild.tool.macosx.c.linker.macosx.base"/>
<tool id="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base.1427633180" name="MacOS X C++ Linker" superClass="cdt.managedbuild.tool.macosx.cpp.linker.macosx.base">
<option id="macosx.cpp.link.option.paths.538746761" name="Library search path (-L)" superClass="macosx.cpp.link.option.paths" valueType="libPaths"/>
<option id="macosx.cpp.link.option.libs.977038629" name="Libraries (-l)" superClass="macosx.cpp.link.option.libs" valueType="libs"/>
<option id="macosx.cpp.link.option.paths.538746761" name="Library search path (-L)" superClass="macosx.cpp.link.option.paths"/>
<option id="macosx.cpp.link.option.libs.977038629" name="Libraries (-l)" superClass="macosx.cpp.link.option.libs"/>
<inputType id="cdt.managedbuild.tool.macosx.cpp.linker.input.1803170133" superClass="cdt.managedbuild.tool.macosx.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.assembler.macosx.base.849550952" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.macosx.base">
<option id="gnu.both.asm.option.include.paths.1742157853" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<option id="gnu.both.asm.option.include.paths.1742157853" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/opt/local/include"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1228178557" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.macosx.base.1652892187" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.macosx.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base.1915088355" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.macosx.base">
<option id="gnu.cpp.compiler.option.include.paths.1137365864" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<option id="gnu.cpp.compiler.option.include.paths.1137365864" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="/opt/local/include"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2067590615" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
Expand All @@ -118,10 +118,10 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Release">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/print3d"/>
</configuration>
<configuration configurationName="Default">
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/print3d"/>
</configuration>
<configuration configurationName="Debug">
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ src/*.o
src/print3d
src/Testing
build
*~
.*.swp
16 changes: 16 additions & 0 deletions .settings/de.loskutov.anyedit.AnyEditTools.prefs
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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_CUSTOM +@BUSYBOX_CONFIG_INOTIFYD
endef

define Package/print3d/description
Expand All @@ -33,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

Expand All @@ -41,8 +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-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
Expand Down
2 changes: 1 addition & 1 deletion build-local.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

MAKE=make
CMAKE=cmake
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/drivers/AbstractDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ class AbstractDriver {
: name(n)
{}
};

// typedef (shorthand) for list of firmware descriptions
typedef std::vector<FirmwareDescription> 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
};
Expand Down
70 changes: 37 additions & 33 deletions src/drivers/DriverFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 3 additions & 4 deletions src/drivers/DriverFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@

class DriverFactory {
public:
typedef std::vector<const AbstractDriver::DriverInfo*> 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<const AbstractDriver::DriverInfo*> 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)
*/
};

Expand Down
31 changes: 21 additions & 10 deletions src/drivers/GCodeBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "GCodeBuffer.h"
#include <algorithm>
#include <stdlib.h>
#include <string.h>
using std::string;
Expand Down Expand Up @@ -149,10 +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, " buffer: ");
//LOG(Logger::BULK, " %s",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
Expand All @@ -161,31 +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));
}
}

//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--;
while((posDoubleNewline = buffer->find("\n\n", posDoubleNewline)) != string::npos) {
// LOG(Logger::BULK, " erase double lines: %i",posDoubleNewline);
buffer->replace(posDoubleNewline, 2, "\n");
}

// remove empty first line
if(buffer->find("\n",0) == 0) {
buffer->erase(0, 1);
LOG(Logger::BULK, " erase first empty line");
}

//LOG(Logger::BULK, " >buffer: ");
//LOG(Logger::BULK, " %s",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());
}
2 changes: 2 additions & 0 deletions src/drivers/MakerbotDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") );
Expand Down
5 changes: 5 additions & 0 deletions src/drivers/MarlinDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") );
Expand Down Expand Up @@ -265,6 +267,9 @@ 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("mamba3d") );
supportedFirmware.push_back( AbstractDriver::FirmwareDescription("marlin_generic") );

info.supportedFirmware = supportedFirmware;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion src/frontends/cmdline/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
4 changes: 3 additions & 1 deletion src/frontends/cmdline/fe_cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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':
Expand Down
Loading

0 comments on commit 9297117

Please sign in to comment.