#include "ConfigValue.h"
#include "FileConfigSource.h"
#include "ConfigCache.h"
+#include <malloc.h>
+
using namespace std;
#include <string>
// Transfer all values found in the file to the passed cache
void FileConfigSource::transfer_values_to_cache( ConfigCache* cache ){
-
+
+
+ printf("Before file reading\n");
+ malloc_stats();
+
+
+
// Default empty value
ConfigValue* result = new ConfigValue;
FILE *lp = fopen(this->get_config_file().c_str(), "r");
string buffer;
int c;
+
+ int debug_total = 0;
+
// For each line
do {
c = fgetc (lp);
if (c == '\n' || c == EOF){
+
+ printf("key:<%s> \r\n", buffer.c_str());
+
// We have a new line
if( buffer[0] == '#' ){ buffer.clear(); continue; } // Ignore comments
if( buffer.length() < 3 ){ buffer.clear(); continue; } //Ignore empty lines
size_t begin_key = buffer.find_first_not_of(" ");
size_t begin_value = buffer.find_first_not_of(" ", buffer.find_first_of(" ", begin_key));
- string key = buffer.substr(begin_key, buffer.find_first_of(" ", begin_key) - begin_key).append(" ");
- vector<uint16_t> check_sums = get_checksums(key);
-
- //for( uint16_t i = 0; i < check_sums.size(); i++ ){
- // printf("%u ", check_sums.at(i));
- //}
- //printf("\r\n");
+
+ vector<uint16_t> check_sums = get_checksums(buffer.substr(begin_key, buffer.find_first_of(" ", begin_key) - begin_key).append(" "));
+ printf("before trouble\r\n");
+ printf("sizeof(ConfigValue): %u\r\n", sizeof(ConfigValue));
+ malloc_stats();
+
+ printf("trouble \r\n");
result = new ConfigValue;
+
+ malloc_stats();
+ printf("after trouble\r\n");
+
+
result->found = true;
result->check_sums = check_sums;
+
result->value = buffer.substr(begin_value, buffer.find_first_of("\r\n# ", begin_value+1)-begin_value);
+
+ debug_total += result->value.size();
+ printf("value:<%s> %d \r\n", result->value.c_str(), debug_total);
+
// Append the newly found value to the cache we were passed
cache->replace_or_push_back(result);
-
+
buffer.clear();
+
}else{
buffer += c;
}
} while (c != EOF);
fclose(lp);
+
+
+ printf("After file reading config\n");
+ malloc_stats();
+
+
+
}
// Return true if the check_sums match
return this->has_characters(string("!"));
}
- string value;
+ double default_double;
vector<uint16_t> check_sums;
+ string value;
+ string default_string;
uint16_t check_sum;
bool found;
bool default_set;
- double default_double;
- string default_string;
};
#include "modules/robot/Robot.h"
#include "modules/robot/Stepper.h"
#include "modules/robot/Player.h"
-
+#include <malloc.h>
// List of callback functions, ordered as their corresponding events
const ModuleCallback kernel_callback_functions[NUMBER_OF_DEFINED_EVENTS] = {
// The kernel is the central point in Smoothie : it stores modules, and handles event calls
Kernel::Kernel(){
+
+ printf("Before config\n");
+ malloc_stats();
+
+
+
// Config first, because we need the baud_rate setting before we start serial
this->config = new Config();
+
+
+ printf("After config\n");
+ malloc_stats();
+
+
+
// Serial second, because the other modules might want to say something
this->streams = new StreamOutputPool();
this->serial = new SerialConsole(USBTX, USBRX, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(9600)->as_number());
-
+
+
+ printf("In Kernel\n");
+ malloc_stats();
+
+
+
this->add_module( this->config );
this->add_module( this->serial );
+ printf("After config\n");
+ malloc_stats();
+
+
+
+
// HAL stuff
this->slow_ticker = new SlowTicker();
this->step_ticker = new StepTicker();
this->adc = new Adc();
this->digipot = new Digipot();
+
+ printf("After HAL\n");
+ malloc_stats();
+
+
+
// LPC17xx-specific
NVIC_SetPriority(TIMER0_IRQn, 1);
NVIC_SetPriority(TIMER2_IRQn, 2);
this->step_ticker->set_reset_delay( microseconds_per_step_pulse / 1000000L );
this->step_ticker->set_frequency( base_stepping_frequency );
+
+ printf("Before modules\n");
+ malloc_stats();
+
+
+
// Core modules
this->add_module( this->gcode_dispatch = new GcodeDispatch() );
+
+
+ printf("Before robot\n");
+ malloc_stats();
+
+
+
this->add_module( this->robot = new Robot() );
+
+ printf("Before stepper\n");
+ malloc_stats();
+
+
+
this->add_module( this->stepper = new Stepper() );
+
+
+ printf("Before planner\n");
+ malloc_stats();
+
+
+
this->add_module( this->planner = new Planner() );
+
+
+ printf("Before player\n");
+ malloc_stats();
+
+
+
this->add_module( this->player = new Player() );
+
+
+ printf("Before pauser\n");
+ malloc_stats();
+
+
+
this->add_module( this->pauser = new Pauser() );
//LocalFileSystem local("local"); // LPC17xx specific : comment if you are not running a mBed
USBCDCMSC cdcmsc(&sd); // LPC17xx specific : Composite serial + msc USB device
+
+#include <malloc.h>
+#include "mbed.h"
+
int main() {
-
+
+
Kernel* kernel = new Kernel();
+ printf("After Kernel\n");
+ malloc_stats();
+
+
+ mallinfo();
+
kernel->streams->printf("Smoothie ( grbl port ) version 0.6.1 \r\n");
//kernel->add_module( new Laser(p21) );
kernel->add_module( new PauseButton() );
kernel->add_module( new Endstops() );
+ printf("After modules\n");
+ malloc_stats();
+
kernel->add_module( &cdcmsc );
+ printf("After USB\n");
+ malloc_stats();
+
kernel->streams->printf("start\r\n");
while(1){