Go Down

Topic: Which Library Development Environment? (Read 2540 times) previous topic - next topic

I'm finding library development slow going. I want to develop my own libraries for Arduino without the constant code-compile-load-run routine. I've tried Processing (doesn't use .h and .cpp files like Arduino) and I've looked into using Eclipse for C/C++ development (too much set-up and screwing around).

What do people use to write libraries? Or does nobody write their own libraries from scratch?

Thanks!
There are 3 kinds of people in the world. Those who are good at maths, and those who aren't.

AWOL

#1
Feb 15, 2011, 11:05 am Last Edit: Feb 15, 2011, 11:07 am by AWOL Reason: 1
Quote
I want to develop my own libraries for Arduino without the constant code-compile-load-run routine

How else are you going to debug and test?

An emulator/simulator?
If you're interacting with hardware or built-in peripherals, these can be even more of PITA to get working than the cycle you describe.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

AlphaBeta

I use Notepad++ and logic. If you design your program first, on paper or using some tool on the computer, you might cut the cycle drastically.
A lot of my libraries are written cycling just once: http://arduino.cc/playground/Profiles/AlphaBeta

You should try to become your own compiler, and embed a lot of mental cues in your code.
If you once have a bug because you do if (x = 42) and meant if (x == 42)then adopt a convention to always  start with the constant like if (42 = x) which will be an error, and it looks like an error as well, right? Then you spot that, and correct it to if ( 42 == x) without the need for a complete cycle.
Always comment code that are not self descriptive and that use many language constructs (no need to comment that a getChar method gets a char, and it is no need to comment that i++ increments i).

I also find that it's a good exercise to manually run through the code, as a personal core review and a verification that the logic is sound.


Good luck! Writing libraries for the Arduino has thought me a lot, I'm sure it will teach you a lot as well.
Any problems? Just ask :)

robtillaart

Quote
I use Notepad++

I second that,

When writing a library I always start with thinking about the interface. What functions make sense? What param-list makes sense per function? What internal structure is needed?  - and yes in this last step I often use paper -  Then I start coding with the constructor and build up the lib in small steps, and testing (almost) every step.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

gardner

For parts that are just logic, I write them on a real computer and create test harnesses and test them in a UNIX environment with a debugger, if necessary.  When they are working as expected, I paste them into a sketch or module.

This is only possible for something like a communication protocol or something, that has very fixed interfaces.  If you have interrupts or special hardware to debug, you have to do it on Arduino hardware.

I have found some things help there:  Using a MEGA gives you extra HW UARTS, which may make it easier to generate debugging information.  It also has more memory, so having gobs of extra debugging crap around -- buffers to format debug messages and strings and whatnot is much more feasible.

logic

I wrote a Makefile as a build/test harness for my LCD library, and work on everything using my traditional tools (vi, make, gcc, etc) on my native machine (I actually went so far as to write a thin ncurses-based "LCD" backend for testing my drawing routines, which also forced me to abstract the hardware out a bit more).

So basically, for things that aren't explicitly tied to hardware, it's make, gcc, and vim for me. Your tools may vary. :)
-Ed
Felix qui potuit rerum cognoscere causas.

westfw

Quote
I write them on a real computer and create test harnesses and test them in a UNIX environment with a debugger, if necessary.  When they are working as expected, I paste them into a sketch or module.


+1
With EMACS, of course :-)

logic

-Ed
Felix qui potuit rerum cognoscere causas.

Thanks everyone, I value your experience and efforts to help me. Gardner got closest to what I was looking for. I should have said I'm writing "just logic" classes like Time; Text (String); Location (for GPS). I can remove dependency on actual hardware by, for example, mocking a GPS device that just returns a single NMEA sentence when called. I guess I want a "nice" C/C++ environment for Win7. I have run Ubuntu in the past (and loved it) but had hardware issues with my current machine. I've developed in Notepad++ with cygwin and had good success, but it's not integrated. I guess I could try Visual Studio? Oh hey, here's a question.

If I write and run C++ on a Windows machine, aren't all the data types 32-bit, or even 64-bit? If I want to test for things like overflow on an 8-bit integer I'd have to somehow define an 8-bit data type wouldn't I? Otherwise it's not actually simulating what would happen on an 8-bit microcontroller, is it?

Being a Computer Science student and professional developer (shock!) I'm not much interested in plugging in hardware and mashing together bits of other people's code. I want to write it all from scratch! That means countless hours developing libraries (as I've already done) that perform functions like the built-in String and available NewSoftSerial classes already do. It's as much about learning to write (fast and light) code for microcontrollers in general as it is to complete one of the many project ideas I have.

This forum is an amazing resource. Thanks again. No doubt I'll have another question shortly ...
There are 3 kinds of people in the world. Those who are good at maths, and those who aren't.

AlphaBeta

Being a Computer Science student and professional developer (shock!) I'm not much interested in plugging in hardware and mashing together bits of other people's code. I want to write it all from scratch!

This probably what most of us CS geeks thinks (especially while we're students), but it will get you nowhere in the real life. Actually, it will get you somewhere, and that is last.
UNLESS you're lucky enough to discover something no one has ever done before.

The sooner you learn the skill to 'mashing together bits of other people's code' the sooner you will become a great developer.
:)

Graynomad

Quote
aren't all the data types 32-bit, or even 64-bit? If I want to test for things like overflow on an 8-bit integer

I got caught porting a program to a Burroughs (I think) main frame years ago. A lot of the code used hash tables for lookup and calculating the hash values required catching overflow from 8-bit values.

The main frame had 9-BIT BYTES. Man that took some time to figure out :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

westfw

Quote
If I write and run C++ on a Windows machine, aren't all the data types 32-bit, or even 64-bit? If I want to test for things like overflow on an 8-bit integer I'd have to somehow define an 8-bit data type wouldn't I? Otherwise it's not actually simulating what would happen on an 8-bit microcontroller, is it?

No; there would be revolution in the street.  There are now standard defined types for data of a particular size (int8_t, int16_t, int32_t, int64_t and similar uint types for unsigned), and portable code should use those.    "char" is almost always 8bits, "short" is almost always 16bits.  Things beyond that get complicated.  (for portable code be especially careful not to assume that sizeof(void*) == sizeof(int) !)

I generally find "Integrated" to be overrated.  A good set of more customizable tools ends up being more powerful.  That said, "Eclipse" and "Netbeans" seem to be the up-and-coming standard IDEs, and include a good deal of customization capabilities.

Graynomad

I use Netbeans and love it. The Arduino port is not 100% I think and I have some issues with creating a new project but overall it's great.

However I just use it as a fancy editor, and make launcher. I still have a normal make file.

BTW, I just downloaded Notepad++, thanks for the tip there fellas, that's a keeper, it will be replacing my other programming editor (Textpad) I've been using for a long time.


______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Hey AlphaBeta, I have a pathalogical drive towards "perfection"; don't most programmers?. No mistakes. Correct code. My work day is 100% compromise and drives me crazy, so my Arduino stuff is my own little bit of nirvana. I know it's a fool's quest, but I have fun learning everything I can! Maybe I should switch to assembler so I can have bare-metal control? Hmmm - there's an idea.

Thanks for the reality check though!
There are 3 kinds of people in the world. Those who are good at maths, and those who aren't.

Camalaio

From my experience, most Computer Science students do not care about writing code from scratch. Most I know seem/seemed happy to use something premade.
I couldn't stand using someone else's code :p

That said, I use Code::Blocks. Not many people seem to talk about it, but me + Code::Blocks = happy. Oh yeah, +gcc also of course, but that can go without saying.

About your all datatypes being 32-/64-bit question...
Yes and no. For Windows. (And most Unix OS's)

You can store 8-bit values all you want on Windows, and have them act as such. The thing you must be aware of is word size.
In a 32-bit edition of Windows, 2^32 words are accesible. Each word is treated as 4 bytes, or 32 bits long. Because there are 2^32 separate addresses, and they have a 32-bit "resolution" due to 32-bit words (that is, if the numerical difference between two pointer values is 1, then they are 32 bits apart), the system must strip a whole word from memory, then just grab the first byte.
Likewise with 64-bit... but with 64-bits. Which is one of the reasons I am against 64-bit. Stripping whole words for 32-bit values is just ridiculous. There's always the argument amount a boolean value taking a whole word too in this sense!

Anyways. Code::Blocks. Check it out :) It's a slight pain for quick work unless you know/set-up some shortcuts. It allows you to work on single files of course, but like Eclipse/Netbeans, it is focused on a "Project" view.

Or use some Notepad-like program. Nothing wrong with Notepad++.

Go Up