Read Advanced Code

so I finished a few Intro programming classes. But most of those classes covered just the basics. What books/reference can I turn to in order to understand more advanced code. For example I am trying to understand how this particular code is working. Its comprised of multiple files and it is intended for a Arduino target (Its the autopilot from DIYDrones). The structure of the code is nothing like you see in a class(school) and I dont event know where to begin. I was expecting maybe a file with a declaration of a main() and be able to work my way up from there.


Classes hardly ever teach what large programs look like. There is usually some type of "makefile" that can build the entire program and generate the executable(s). The "makefile" is where I would begin. Is this code you have publicly available for download? If so, I would be willing to look through it and provide more information about it if I can.
Thanks for the quick reply Kevin.
The code is available at: https://code.google.com/p/arducopter/downloads/detail?name=ArduCopter-2.8.1.zip&can=2&q=
Once you have the Arducopter code donwloaded and unzipped you will also need the Arduino IDE, which you can find at:
From within Arduino IDE you can open the file Arducopter.pde (/.ino) and compile it.


Okay I will download this later on my personal computer since I am at work currently.

It looks as if the main is somewhere in the massive nest of includes provided for these Arduino boards. AP_HAL_MAIN() was a function I noticed in the source code of Arducopter.pde. I did not download the IDE for Arduino. I was only using a text editor to snoop around, but I'm guessing you could do a text search on you computer and you might find the main AP_HAL_MAIN
Last edited on
Hi Kevin,
I think I figured it out. There is a setup() and a loop() function, inherent to Arduino projects inside Arducopter.pde. It looks like the loop() function calls every other process. Thank you for taking the time for looking into it. Since I have have you on the "line" though quick question(s). You were mentioning something about a makefile earlier. Is that the general rule of thumb of deciphering large code? Will a main() function always exist? Will that be the only one? Did you pick up this skill from experience or literature?

I use makefiles in all my projects. Whether they are large or small makefiles are a really handy tool for building applications. Try one out yourself and you shall see how handy they can be. http://mrbook.org/tutorials/make/
That is a simple makefile tutorial to get you started. The makefiles included in that arduino code are more complex and probably difficult to learn from. I have always learned by making my own. Programming is a skill that is best to read and then immediately try it out yourself. Main functions will always exist if the code is meant to be executed on something. Executables have what is a called a "point of entry" this is the beginning of executable code. If you would like to learn more about different sections of an executable I would recommend learning the basics of assembly language.
Topic archived. No new replies allowed.