progress
This commit is contained in:
parent
68ab694d8a
commit
91f2dd54be
45
marlin2.cpp
45
marlin2.cpp
@ -86,10 +86,43 @@ namespace esphome {
|
||||
}
|
||||
|
||||
if(!MarlinOutput.compare("ok") || !MarlinOutput.compare(" ok")) {
|
||||
listingFile = false;
|
||||
MarlinOutput="";
|
||||
return;
|
||||
}
|
||||
|
||||
if(!listingFile && MarlinOutput.compare("Begin file list") == 0) {
|
||||
ESP_LOGD(TAG, "Listing of files started!");
|
||||
listingFile = true;
|
||||
//reset string for next line
|
||||
MarlinOutput="";
|
||||
return;
|
||||
}
|
||||
|
||||
if(listingFile && MarlinOutput.compare(".GCO ")) {
|
||||
int first_space = MarlinOutput.find(' ');
|
||||
int second_space = MarlinOutput.find(' ', first_space + 1);
|
||||
|
||||
if(first_space > 0) {
|
||||
std::string short_name = MarlinOutput.substr(0, first_space);
|
||||
std::string long_name = short_name;
|
||||
|
||||
if (second_space > first_space){
|
||||
long_name = MarlinOutput.substr(second_space + 1);
|
||||
}
|
||||
|
||||
file_table_[long_name] = short_name;
|
||||
ESP_LOGD(TAG, "Uloženo do tabulky: %s => %s", long_name.c_str(), short_name.c_str());
|
||||
|
||||
}
|
||||
|
||||
//reset string for next line
|
||||
MarlinOutput="";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Parse periodic Temperature read out message
|
||||
if(
|
||||
MarlinOutput.find(" T:") == 0 ||
|
||||
@ -218,17 +251,11 @@ namespace esphome {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t first_space = MarlinOutput.find(' ');
|
||||
size_t second_space = MarlinOutput.find(' ', first_space + 1);
|
||||
|
||||
if(second_space == std::string::npos && first_space == std::string::npos) {
|
||||
std::string short_name = MarlinOutput.substr(0, first_space);
|
||||
std::string long_name = MarlinOutput.substr(second_space + 1);
|
||||
|
||||
file_table_[long_name] = short_name;
|
||||
|
||||
ESP_LOGD(TAG, "Uloženo do tabulky: %s => %s", long_name.c_str(), short_name.c_str());
|
||||
|
||||
if(MarlinOutput.find("End file list") != std::string::npos) {
|
||||
ESP_LOGD(TAG, "Listing of files stopped!");
|
||||
listingFile = false;
|
||||
//reset string for next line
|
||||
MarlinOutput="";
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user