Pages: [1] 2   Go Down
Author Topic: Which Library Development Environment?  (Read 2098 times)
0 Members and 1 Guest are viewing this topic.
Maitland, Australia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 88
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25754
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 15, 2011, 05:07:48 am by AWOL » Logged

"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.

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rob Tillaart

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

Ontario
Offline Offline
God Member
*****
Karma: 24
Posts: 860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Aurora, IL USA
Offline Offline
Jr. Member
**
Karma: 3
Posts: 56
Felix qui potuit rerum cognoscere causas.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
Logged

-Ed
Felix qui potuit rerum cognoscere causas.

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6645
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)
Logged

Aurora, IL USA
Offline Offline
Jr. Member
**
Karma: 3
Posts: 56
Felix qui potuit rerum cognoscere causas.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ohnohedidnt. smiley
Logged

-Ed
Felix qui potuit rerum cognoscere causas.

Maitland, Australia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 88
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ...
Logged

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

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
 smiley
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6645
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8471
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Maitland, Australia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 88
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley 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++.
Logged

Pages: [1] 2   Go Up
Jump to: