Propeller C Learning System/SimpleIDE
rjo__
Posts: 2,114
Hi guys.
I am trying to learn C because I think it is something I should understand, and I'm hoping what I learn will translate to other C environments, opening my eyes to
new opportunities and new ways to have fun.
I think I have failed to learn C in my first 62 years, because it is just so... so.... boring to get into. Very exciting I'm sure once you are into it, but that boring trudge up the hill has sent
me back down twice.
I was very pleasantly surprised to see Andy's latest efforts to educate people like me. I'm not sure who gives out awards for technical writing, but Andy deserves a life time achievement award.
His approach to C is just wonderful.
And so are you guys... if combining C with a Propeller doesn't do the trick for people like me, nothing will.
I am very reluctant to post even the most innocuous question about GCC and SimpleIDE, since it appears most people here are volunteers, who are already working as
fast as they can... great work, keep it up. Try to do something creative to relieve your stress.
However, on the off chance that there is one salaried employee among you... here goes:
What is up with the syntax checking?
Rich
I am trying to learn C because I think it is something I should understand, and I'm hoping what I learn will translate to other C environments, opening my eyes to
new opportunities and new ways to have fun.
I think I have failed to learn C in my first 62 years, because it is just so... so.... boring to get into. Very exciting I'm sure once you are into it, but that boring trudge up the hill has sent
me back down twice.
I was very pleasantly surprised to see Andy's latest efforts to educate people like me. I'm not sure who gives out awards for technical writing, but Andy deserves a life time achievement award.
His approach to C is just wonderful.
And so are you guys... if combining C with a Propeller doesn't do the trick for people like me, nothing will.
I am very reluctant to post even the most innocuous question about GCC and SimpleIDE, since it appears most people here are volunteers, who are already working as
fast as they can... great work, keep it up. Try to do something creative to relieve your stress.
However, on the off chance that there is one salaried employee among you... here goes:
What is up with the syntax checking?
Rich
Comments
Don't worry about posting questions: they provide useful feedback on what needs to be documented more. If it's nice and concise, the answers might even make it into the FAQ.
Can you elaborate? If there is a problem, then some context, sample code and a screenshot will help immensely.
I'm working on a Mac. OS X10.6.8 My generic problem with all computer languages is syntax. Logic is almost never my problem.
Question 1:
printf("n = %d\n", n); works fine, just like it should
but
printf("n=%x/n",n); also works perfectly
and
printf("n=%r/n",n); works, but doesn't print the value of n and it doesn't throw an error.
I would expect C to fail if I make a typo and at least point me to the right line in the code.
Question 2:
SimpleIDE has to know where to look for files. This is set through the Tools-> Properties. How deep into a folder's structure does SimpleIDE look? If I have a folder(directory) inside the folder(directory) set by Properties, will SimpleIDE
look there for what it needs? What is the level of recursion here?
Mac interface issues.
Unable to expand the Project Manager View. The text editor expands ok.
Unable to copy to system from the Build Status view. This means that I will not be able to post long error messages without rewriting them. Text editor copy and paste works fine.
I am using SimpleIDE, 0.9.26. I have followed the documentation as far as I can and read what is available in the forums, and I am unable to get a Spin based
project to run. I think I have my Properties set wrong, but can't figure out what I did wrong.
It won't fail, but the compiler will throw warnings if we ask it to do that. Andy opted not to enable all warnings.
In the strictest sense, the user is telling SimpleIDE and the GCC tools where to find libraries although SimpleIDE chooses the correct memory mode variant. The Add Library button does this when you click it and select a lib* folder. SimpleIDE chooses the correct library.a file to use at compile time from the different folders within the lib* folder.
In a future version, SimpleIDE will just look for the right files based on the includes and the properties library path; it is an experimental feature right now in version 0-9-28+.
That's the way it is. Use the horizontal scrollbar if necessary.
Right-click in Build Status, Select All. Copy/Paste.
Spin in SimpleIDE is different from Propeller Tool. In SimpleIDE, you open a file then use the Set Project command (F4 or COG button in project view); only then will you be able to build a Spin program with SimpleIDE. My next project is to make a Propeller-Tool compatible IDE.
The thing is printf prints a string. As in
But that string can have formatting characters in it so that you can embed numbers and such into the string being printed. As in:
That formatting string might be wrong, not producing the output you expect. But how is the compiler supposed to know if you put what you wanted int o the string or not? It cannot.
As far know %r is not a valid "format identifier". See list here for example: http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/FUNCTIONS/format.html
For me the following: Produces As expected.
However turninon all warnings with the -Wall compiler option gives me the following warnings:
You probably meant to type:
This must also be a typo: I'm guessing it should be but I don't know what tutorial you're working on.
The reason you're not getting an error message is that there is nothing wrong with the syntax. The compiler just sees that you want to call the function printf with the quoted string as the first parameter, and n as the second parameter, so it generates code to do all that. If the string has \r or \n in it (or any of the other codes with backslash-prefixes), the compiler replaces them in the final string that goes into your program. \r gets replaced by a byte with value 13, \n gets replaced with a byte of value 10. At the end of the string, the compiler stores an implicit byte with value 0.
At runtime, the printf function reads the format string character by character, and prints each character to the output device until it runs into the 0-byte. When it sees a percent sign, it interprets the following characters as a formatting rule, and "pulls in" the next parameter. For example, if there is a %x in the format string, the printf function knows that the next parameter must be an integer and that it must be printed in hexadecimal, lower case.
If you put a format string that it doesn't recognize (such as %r in your last example), printf ignores it. Remember this happens at runtime, so you don't get an error while compiling, although I think gcc is smart enough nowadays to do an extra check at compile time to make sure the format string corresponds to the following parameters, and it can give you a warning if it doesn't. Maybe you have to add a compiler option to do that, like -Wall (meaning "warn all"), I'm not sure.
One of the things you need to be careful about is giving printf fewer parameters than what is needed by the formatting string, or giving the wrong parameters. Printf doesn't know how many parameters you gave so it just gets the next parameter from the location where it would be if it would be there. If you give it a parameter %d to print an integer but you don't give it an integer to print, it will just print random garbage that happens to be on the stack. If you give it a %d but you pass a float or double as parameter, it will also print garbage because floats and doubles are stored in a different way (if you want to print the integer part of a float, you have to generate it by using e.g. round( ) ). If you give it a parameter %s to print a string, but no string to print, it will get the garbage from the stack, interpret it as pointer, and print random data from memory until it runs into a 0-byte that would normally indicate the end of a string. On bigger systems like PC's and Mac's that have memory protection hardware, your program will probably crash when you do that because chances are that it will run into some part of memory that it doesn't have access to, so the hardware will generate an exception and the operating system will kill your program with an error message that usually has no useful information for normal users :-)
I'm not sure what you mean here, but if you're talking about the folder options in the preferences that tell SimpleIDE where the compiler and other tools are: There is no automatic recursion so you can't just set eg the gcc folder to / and wait until SimpleIDE finds it: it won't work. The folders that you set in the options dialog have to be the folders where the loader, compiler etc. are stored. They are the base folders, and SimpleIDE will know where to find the right tools from there. For example if the propgcc folder is set to /propgcc, it will know to find e.g. gcc under /propgcc/propeller-elf/bin because it simply adds the relative path "propeller-elf/bin/gcc" to the "/propgcc" path.
As far as I know, you have to set the mode to SPIN on the project settings, and that should pretty much be it. You can't combine SPIN and C/C++ at this time, I don't think: it has to be either all SPIN or all C/C++/Assembler. Jazzed will correct me if I'm wrong.
===Jac
When I turn on the compiler "All Warnings," I now get:
"Ignoring "Simple printf" flag in program using -ltiny.
That's better.
Jazzed
On my mac, I'm absolutely not able to copy from the build status window.
With regard to Spin projects, I seem to remember being able able to create Spin projects before I upgraded and I think I'm doing it the right way... I am going to take a nap and see if that helps.
I think I screwed something up in my folder architecture when I upgraded. The only thing I did was to throw away the SimpleIDE app and install the new right over what was left of the old.
My real issue is learning C and I think you guys have taken care of that very nicely:)
Thanks everybody.
Rich
On Mac OS X, use Control-Click when Windows users tell you to Right-Click...
Control Click in the Build Status view will give you a pop-up menu that will allow "Select All" & "Copy".
dgately
On more thing. When you are creating the new IDE, please create one that is open and can be fully scripted. It doesn't have to be fancy... key scripting often works well. But the more robust, the greater the application base
and the wider the acceptance. Scripting would be extremely useful for integrating propeller apps with other computer resources.
I think of Propellers as something akin to the mid-brain or brain stem. Higher cortical functions... traditional computing environments, will always be useful at some level of problem solving.
Thanks for all your efforts.
Rich
Can you provide an example?
I suspect that Roy's OpenSpin and the propeller-load program may meet your needs.
@Dave, SimpleIDE provides a Warn All checkbox. Other options like -Werror can be set in the Project Manager Other Compiler Options box.
Another example, I used ImageJ ... cross-platform open software from NIH... to create a graphical interface for creating CNC code. http://forums.parallax.com/showthread.php/147789-Graphical-interface-to-create-Veroboard-G-Code. Very simple, adult play. But I use it:)
The same could be done with any variety of languages and programming environments that support scripting.
A good example of this kind of application, which is very simple to implement using a scripting language is the Scribbler2 App. I got the scribbler for my son. He mastered the graphical interface in about an hour.
Writing an app like this in something like imageJ is really straight forward... getting it automatically compiled and downloaded would benefit greatly from a scriptable IDE.
By making the IDE scriptable, you allow more opportunities for integration... I might not be able to get program "a" to communicate with program "b", but if I have a program "c" that can communicate with both, they can be made to talk to each other.
Scripting adds value and makes repurposing possible.
It is great fun and great learning to be able to get a Propeller to do what computers already do. Sometimes, however, I just want my Propeller to tell my computer what to do and sometimes I want my computer to return the favor.
Strangely enough Qt now comes with a scripting language. In fact entire Qt apps can be built in the scripting language without ever writing any C++ code.
That language is JavaScript.
I've briefly discussed scripting for regression testing with someone here though, and he said that Qt5 supports Javascript which seems to be good enough. I've planned to migrate to Qt5 at the next opportunity for some time now as it should solve certain problems I've faced over the last year. The new project will definitely be based on Qt5, and SimpleIDE will be updated at some point.
As an IDE, I'm not sure that SimpleIDE would be the correct medium for the type of communication between the computer and a Propeller board that you are discussing. What you are thinking has value for sure, but from SimpleIDE, I'm not so sure. And, as Heater stated, that would add a lot of complexity to SimpleIDE as its name implies, "simplicity". In the Arduino world, the IDE is used to build and load projects onto a board, and then most folks use Processing to communicate between the computer and the microcontroller board at app level. That paradigm seems closer to what you are wanting in scriptability.
An IDE should allow the simplest feature set to get your code edited, compiled and loaded onto your boards, with the possible additional feature of debugging. Scriptability should provide support to those ends as well as testing for the developers of the IDE to ensure against regressions when the IDE is updated. The goal of most microcontroller applications is to remove the need of the PC as a full-time connected device, right? Obviously, there are many applications where that is not the goal, but a communication link between microcontroller and computer is either easily contrived or could be handled by a computer-side application outside of the IDE.
I'm not sure I get the connection between the Scribbler2 app and scriptability of SimpleIDE. SimpleIDE does allow editing, compiling, linking and download of script-based code. Those "scripts" just happen to be Spin, PASM, GAS, C and C++.
Have you looked at Scratch on RaspberryPi? It is a good example of a scriptable interface. Perhaps something like that (12 Blocks comes to mind) is a better pardigm for scriptability between computer and propeller?
SimpleIDE's goal as I know it is in providing an IDE that satisfies the needs of educators and software developers that were looking for a C-based solution. It happily works with Spin, which is a real bonus. I think the features you are describing are excellent, but possibly goals for a different application.
Just my thoughts which are worth about $.02 U.S. dollars .
dgately
There is an open issue about supporting make files in SimpleIDE. Obviously it has been kept a low priority though.
I've convinced the Eclipse Plugin project owner that his code needs to be posted for community development. Still waiting ....
Yes, SimpleIDE will have more enhancements.
- My highest priority to finish right now for a general release is multi-user install support.
After general release, these enhancements are anticipated.Is there a case where a user wouldn't want to get all the warnings? IMHO, it's a mistake to not give beginners all the support that can be given to them as default.
The problem for beginners is that many of the warnings are difficult to interpret and they'll spend a lot of time trying to find out why their code gives off these warnings. Many warnings are rather esoteric to the beginner (I too am dumbfounded by some) and will just keep them from their objective of getting their propeller running. As the user becomes more experienced and would like to optimize their project, they can turn warnings on if they want to.
If most warnings provided were easily fixable, then it would benefit a brand new user, but many are mysterious from the point of that person who is just starting to code.
dgately
The warning can be a bit impenetrable but having code that mysteriously does not work as expected is far more impenetrable.
Our thinking was the same as dgately's when we requested the current level of warnings. Additionally, I was concerned because I've seen students start ignoring those messages because they seemed like too much information. They are much more likely to take heed if they see that box appear with helpful hints when they make compiler errors.
This is also the kind of stuff we talk about in educators courses. When time permits, I'll show teacher-attendees a few scenarios and how the warning messages look, collect opinions, and maybe make some changes if there's a clear majority. This might also be a situation where Simple View should have one level of warnings, and Project View maybe a different level.
Andy
I taught C at a Community College and had to emphasize to early learners the difference between warnings and hard errors. They often got caught-up on the content of large logs and removing warnings allowed them to at least get their compiles to complete. Just as I wouldn't hand a dictionary to a child who is just learning to talk, you want to give them the easiest path in starting to learn. Then build on that early-learning stage.
Just my experience...
Thanks,
dagtely
I think the problem you are going to run into is that everyone is going to want more, more, and still more.
I flew through the material and all I want is more:)
Rich
My background on this is tutoring C++ and the like at my university, and mentoring some high school kids with Java.
We've got a bunch of tutorials in the queue, and the plan is to crank 'em out all summer long.
For now, there are a few code examples that do not have tutorial pages in the Learn/Examples folder that might be worth a try...
Andy
When I (eventually) write the page on Learn that will be specifically for teachers setting up SimpleIDE for classroom use, I'll make sure to point that out specifically. Then, the teacher can set up the lab to his or her own teaching style, including letting the students pick their own preferences.
In my haze, I pointed the Properties' Spin Compiler path to a downloaded btsc.osx file(/Users/RJOhome/Downloads/prop2gcc-2013-04-14-mac/bin/bstc.osx). This morning
I figured it out an repointed to /opt/parallax/bin/bstc.osx; everything now works as advertised:)
Been there, done that. Will play some more with it.
What I really want for Christmas is to learn how to build a very simple library... did I miss it?
What I most enjoy about the Propeller is the feeling that I am actually talking to the machine. This happens most
in PASM... but Spin gets me there with waitcnt etc.
In C, I feel like I'm talking to a librarian about the Propeller:)
Rich