Giter VIP home page Giter VIP logo

Comments (5)

jcoffland avatar jcoffland commented on July 18, 2024 1

There is already the print() command. However, running such code in the simulator may not have the desired effect. Any GCode which is emitted by print() will be missed by the simulator. You could preprocess with TPL, then run the resulting GCode in the simulator.

from camotics.

jcoffland avatar jcoffland commented on July 18, 2024 1

It should be writing to the same stream. CAMotics::CommandLineApp::stream is also passed to TPLContext in TPLangApp::run() in tplang.cpp. This is what cb::StdModule::print() writes to. Are you saying that print() still ends up in stdout when you set --out <filename>? What build are you using?

from camotics.

jcoffland avatar jcoffland commented on July 18, 2024 1

I just tested this in my local build and the streams are the same. I in believe v1.2 print() always prints to stdout but that has been fixed. I've been trying to make a new CAMotics release for a long time now but haven't been able to find the time. You can always build from source.

from camotics.

gadelan avatar gadelan commented on July 18, 2024

That was a quick reply. Thank you!

We are not talking about the simulator. Just TPL. The simulator cannot understand arbitrary g-code. That's obvious.

I tried what you suggested using the tplang program as preprocessor. But, when executing

tplang test.tpl --out "test.nc"

Where the file test.tpl is

print("G0 X0 Y0");
print("G1 X10"); 

The resulting file test.nc is

G21
M2 

The command line console does show

G0 X0 Y0G1 X10

in the standard output, and we could use --out - but then we are conflating two different streams. One with the g-code and the standard output.

I have tried to understand how the print command works following the source code. The only appearance of "print" is in GCodeInterpreter::specialComment() which uses LOG_INFO. However, both message() and comment() call the same-named methods in GCode::GCodeMachine and these methods use GCode::GCodeMachine::stream which is the output file of CommandLineApp::build() initialized in CommandLineApp::init().

As far as I can understand the source code, there is no command to emit g-code from TPL. I mean, a command that has a semantics that says "write to the g-code file/stream". We can use print (to standard output) and make the g-code file be the standard ouput to get around that, but... is this it? By design?

from camotics.

gadelan avatar gadelan commented on July 18, 2024

tplang --version says 1.2

from camotics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.