Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the FluidConsole project #238

Open
wants to merge 9 commits into
base: Devt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions FluidNC.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29306.81
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1738
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FluidNC", "FluidNC.vcxproj", "{11C8A44F-A303-4885-B5AD-5B65F7FE41C0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests.vcxproj", "{33ECE513-60D1-4949-A4A9-C95D353C2CF0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FluidNCConsole", "FluidNCConsole.vcxproj", "{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -29,6 +31,14 @@ Global
{33ECE513-60D1-4949-A4A9-C95D353C2CF0}.Release|x64.Build.0 = Release|x64
{33ECE513-60D1-4949-A4A9-C95D353C2CF0}.Release|x86.ActiveCfg = Release|Win32
{33ECE513-60D1-4949-A4A9-C95D353C2CF0}.Release|x86.Build.0 = Release|Win32
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Debug|x64.ActiveCfg = Debug|x64
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Debug|x64.Build.0 = Debug|x64
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Debug|x86.ActiveCfg = Debug|Win32
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Debug|x86.Build.0 = Debug|Win32
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Release|x64.ActiveCfg = Release|x64
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Release|x64.Build.0 = Release|x64
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Release|x86.ActiveCfg = Release|Win32
{8CE82A5A-3357-4179-8E8B-5D5B5B52B37B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 11 additions & 0 deletions FluidNC/src/FileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "SDCard.h"
#include "Logging.h"
#include <sys/stat.h>
#ifdef FLUIDNC_CONSOLE
#include <filesystem>
#endif

int FileStream::available() {
return 1;
Expand Down Expand Up @@ -45,7 +48,15 @@ size_t FileStream::position() {
FileStream::FileStream(String filename, const char* mode, const char* defaultFs) : FileStream(filename.c_str(), mode, defaultFs) {}

FileStream::FileStream(const char* filename, const char* mode, const char* defaultFs) : Channel("file") {
#ifdef FLUIDNC_CONSOLE
std::string cur_path = std::filesystem::current_path().string();
if (cur_path.back() != '\\')
cur_path += '\\';

const char* actualLocalFs = cur_path.c_str();
#else
const char* actualLocalFs = "/spiffs/";
#endif
const char* sdPrefix = "/sd/";
const char* localFsPrefix = "/localfs/";

Expand Down
53 changes: 47 additions & 6 deletions FluidNC/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,55 @@ void loop() {

void WEAK_LINK machine_init() {}

# if 0
bberkhin marked this conversation as resolved.
Show resolved Hide resolved
int main() {
setup(); // setup()
while (1) { // loop()
loop();
#ifdef FLUIDNC_CONSOLE
#include "ComPortX86.h"
#include "InputFile.h"


int main(int argc, char *argv[]){

setup();

allChannels.deregistration(&Uart0); // USB Serial
allChannels.deregistration(&WebUI::inputBuffer); // Macros

Channel *pin = nullptr;
Channel *pout = nullptr;

if (argc == 1) { //console input
pin = new ComPortX86(nullptr);
}
else if (strncasecmp(argv[1], "COM", 3) == 0) { //com port
pin = new ComPortX86(argv[1]);
}
else {
pout = new ComPortX86(nullptr); // run file from command line, ouput to console
infile = new InputFile("/localfs", argv[1], WebUI::AuthenticationLevel::LEVEL_GUEST, *pout);
readyNext = true;
}

if (pin)
allChannels.registration(pin);
if (pout)
allChannels.registration(pout);

if ( config )
config->_verboseErrors = true;

// unlock GRBL to easy debugging
do_command_or_setting("X", nullptr, WebUI::AuthenticationLevel::LEVEL_ADMIN, pout != nullptr ? *pout : *pin);

loop();

if (pin)
delete pin;
if ( pout )
delete pout;
if ( infile )
delete infile;

return 0;
}
# endif
#endif

#endif
5 changes: 3 additions & 2 deletions FluidNC/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void protocol_main_loop() {
break;
}
#ifdef DEBUG_REPORT_ECHO_RAW_LINE_RECEIVED
report_echo_line_received(line, *chan);
report_echo_line_received(line, *chan);
bberkhin marked this conversation as resolved.
Show resolved Hide resolved
#endif
display("GCODE", line);
// auth_level can be upgraded by supplying a password on the command line
Expand Down Expand Up @@ -742,7 +742,8 @@ void protocol_exec_rt_system() {
if (rtSeq) {
rtSeq = false;
log_error("planner " << pl_seq0 << " stepper " << st_seq0);
rtReset = true;
rtReset = true; //rtReset = true; comment this becouse this appear if G0 instruction does not chenge the position
bberkhin marked this conversation as resolved.
Show resolved Hide resolved

}
if (rtCrash) {
rtCrash = false;
Expand Down
7 changes: 7 additions & 0 deletions FluidNC/src/Report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include <cstring>
#include <cstdio>
#include <cstdarg>
#ifdef FLUIDNC_CONSOLE
#include <iostream>
#endif

#ifdef DEBUG_REPORT_HEAP
EspClass esp;
Expand Down Expand Up @@ -412,7 +415,11 @@ void report_build_info(const char* line, Print& channel) {
// Prints the character string line that was received, which has been pre-parsed,
// and has been sent into protocol_execute_line() routine to be executed.
void report_echo_line_received(char* line, Print& channel) {
#ifdef FLUIDNC_CONSOLE
std::cout << "[echo: " << line << "]\n";
#else
channel << "[echo: " << line << "]\n";
#endif
}

// Calculate the position for status reports.
Expand Down
Loading