A application which shows line by line sequence of the gcode - g-code

is there any application which I can load the gcode from a CNC for example and I can check line by line graphically what is going on line by line in my g-code?
I mean like the apple swift playground?

I would recommend this one. If you are a programmer you can even edit the source code to make it more close to your needs.
https://www.codeproject.com/Articles/17424/CNC-Graphical-Backplotter

I use the grbl-Plotter https://github.com/svenhb/GRBL-Plotter for editing GCode, simulating and controle my cnc router.

Related

Eclipse CDT: Mapping console output to source file and line

While debugging code it helps to have source filename and line number on console output. I already use FILE and LINE macros. But it would be great if double clicking a line in the console output would take me to the exact source line which was responsible for outputting that line of log. Can eclipse parse console output and do something like this? It need not work all the time, only when the log line is in a specific format and the source filename and line number are valid.
It's possible to use a workaround if you add the pydev plugin and a few lines of python to call your main function. You can find the needed code here: https://github.com/oct15demo/python_calls_cpp
As noted there, I posted a query on the Eclipse forum to find out the status of any ongoing effort or obstacles to implement within Eclipse.
I could not find out any further information on the feature, if it's there, it's well hidden.
Update March 17, 2022, I shall be working on the feature for Eclipse, don't have an estimate of time yet.

Can any programs read a text file into c++ code?

Is it possible for a program to open up a text file and use it as c++ code? If so, how? What if a program wanted to append code from a text file to itself? Can that happen?
Thanks!
Depends on what you mean by "text file" and "use it as c++ code." If by "text file" you mean a file containing uncompiled C++ code, and by "use it as C++ code" you mean execute it, the answer is no, you'd need to compile it first before it's of any real use (unless you want to write some sort of interpreter or compiler).
With regards to your second question, I suppose it's possible, but it'd be really hard because you would need to compile the C++ code in that text file into binary, then insert it into the program in a meaningful way.
If you're doing this just for curiosity, you might have better luck with an interpreted language (such as Perl or Ruby). I was a bit curious myself, so I took a stab at the problem with the following ruby script (saved in alpha.rb):
File.open('alpha.rb', 'a') do |file1|
file1.puts "\nprint 'Sneaky Addition!'";
end
After you run it, you'll see that a new line of code has been added. If you run it a second time, it'll run the code. I believe the reason that it isn't run the first time is that the file is already loaded into Ruby when it's run, so it doesn't see the change to the file until it reloads it.
Of course, we could possibly get around this by using a second file (as explained here)...
Alpha.rb
print "Alpha running...\n"
File.open('beta.rb', 'a') do |beta|
beta.puts("\nprint \"But alpha got the last word.\\n\"")
end
load 'beta.rb';
Beta.rb
print "Beta running...\n"
File.open('alpha.rb', 'w') do |alpha|
alpha.puts("print \"Sneaky Beta addition.\\n\"")
alpha.puts("\nprint \"Beta overwrote alpha!\\n\"")
alpha.puts("\nprint \"This code only works once =) \\n\"")
end
load 'alpha.rb'
I suppose you might be able to do something similar in C++, but it'd be much more complicated since you would be compiling your code into binary, and even then you probably can't just append it.

How can output be directed to specific coordinates in the linux terminal?

To be more specific, I am looking for an equivalent to the Windows API function: WriteConsoleOutputCharacter. I know this style of direct output is possible, as I have seen the behaviour used before in the time that I have used Linux. However, I am still a baby when it comes to Linux specific C libraries, and have not been able to ascertain any clues as to where I may find such functionality. Any assistance would be appreciated.
Check out ncurses library.
It allows you to create some text-based UI in terminal. It is more than you asked, but if you need more than only this one function it may be best option for you.
You can use the ANSI control sequence
Say, following will print 'ddd' string 3 lines above the prompt in bash
echo -e "\e[3Addd"
This line will put a clock in right upper conner of a terminal (from commandlinefu.com)
while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done

Xcode change/remove comment template

Recently I've been learning how to program C. For most of the time, I have been using the C version of Eclipse. Recently, I tried out Xcode. I am using a Mac running Mac OS X Lion - Xcode version 4.1.
There is one grievance I have: at the top of every file that I create, there is this little section of comments that I wish to remove or better yet, change.
When I create a file, something like this is put at the top of the file by default:
//
// FILE.c
// PROJECT NAME
//
// Created by Martin Tuskevicius on DATE.
// Copyright YEAR ORGANIZATION (my school name for some reason). All rights reserved.
//
Obviously the things in capitals would be replaced with an actual value. For those of you have use, or have used Xcode, for programming C - do you know a way of how to change or remove these default comments?
I really appreciate any help.
Thanks!
UPDATE:
According to #Michael Dautermann 's comment below, change templates in Xcode.app bundle is not a good way. Check https://stackoverflow.com/a/33743/380774 for more information.
You can remove or change the header in File Templates, I'm using Xcode 4.3, and the File Templates is in /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates.
Please do not edit files inside Xcode, that will break the application signature and will cause Xcode to refuse to start up after the next restart or so.
Create an IDETemplateMacros.plist file containing a dictionary with a FILEHEADER key (string) instead.
You can put the file in
for all users on a single project by dropping it in your project's or workspace's xcshareddata folder (e.g. MyAppWorkspace.xcworkspace/xcshareddata/IDETemplateMacros.plist)
for yourself for a single project by copying it into e.g MyAppWorkspace.xcworkspace/xcuserdata/YOURNAMEHERE.xcuserdatad
global for all projects that you open in your account by dropping the file in ~/Library/Developer/Xcode/UserData/
You can change it in Xcode project File.
This is my image for tutorial :D
Very easy!!!

Bolding text in console output

For extra credit, the professor wants us to use bolding and/or underlining to text output in the current project.
The example he gave was b\bb o\bo l\bl d\bd is displayed as b o l d
Following that example, I marked up SPACE as
printf("\033[7mS\bSP\bPA\bAC\bCE\E- move forward one page\033[0m");
I'm also implementing reverse video by enclosing strings within \033[7m and \033[0m fields. The reverse video inverts the colors of the line appropriately, but doesn't seem to be affecting the bolding, since both strings with and without the reverse video are not bolding.
Could it be the standard shell used in Ubuntu 10.10 that is at fault?
I agree about using curses, but given your starting point ....
I think you want to use the 'bright' feature of VT100 for the bold, ESC[1m
You can probably find better doc on VT100 codes, but using this page I found the codes. ANSI/VT100 Escape Codes
I hope this helps.
Unless you're just trying to be masochistic, try using curses (or ncurses) instead.
// warning: Going from distant memory here...
curs_attron(A_INVERSE); // maybe A_REVERSE? I don't remember for sure.
curs_addstr("SPACE - move forward one page");
curs_attroff(A_INVERSE);

Resources