Arduino Pro IDE (alpha) now available

Go To Last Post
33 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino announced the release of the alpha version of a completely new development environment for Arduino — the Arduino Pro IDE. The new architecture opens the door to new features like:

  • Sketch synchronisation with Arduino Create Editor
  • Debugger
  • Fully open to third party plug-ins 
  • Support for additional languages other than C++
  • The new Arduino Pro IDE is based on the latest technologies: 
  • The Arduino CLI running in daemon mode provides all the main Arduino features.
  • The application frontend is based on the Eclipse Theia Open Source IDE.
  • Electron, the framework behind Eclipse Theia, allows the use of web technologies on desktop environments.

 

https://www.eenewsembedded.com/news/arduino-pro-ide-alpha-now-available?news_id=122441

 

See also:

 

https://github.com/arduino/arduino-pro-ide

 

https://blog.arduino.cc/2019/10/18/arduino-pro-ide-alpha-preview-with-advanced-features/

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wonder how the "debugger" is going to work in that?

 

Also:

awneil wrote:
The new Arduino Pro IDE is based on the latest technologies: 
Does that mean Eclipse I wonder ? ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Does that mean Eclipse I wonder ? ;-) 

Apparently not:

In the blog comments, Massimo Banzi wrote:
We’re using Theia and we engaged directly with Typefox (the developers of Theia)

 

https://blog.arduino.cc/2019/10/...

 

But that's not up for debate:

I would love people to stop having debates about the technology and focus on what something does and how it improves your life

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He's a bit of an idiot if he thinks people aren't going to discuss IDE technologies - it's like religion or politics - everyone has strong views about what works and what does not work. (and don't anyone ever mention TI CodeComposer to me!!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Indeed.

 

I'd have thought you'd need a pretty compelling reason not to use Eclipse these days.

 

I had never heard of Theia, but it seems it is Eclipse-based:

Eclipse Theia is an extensible platform to develop multi-language Cloud & Desktop IDEs with state-of-the-art web technologies.

 

 

https://theia-ide.org/ 

 

https://www.typefox.io/

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds interesting.
Any idea of the intended cost for a single home user?

Last Edited: Mon. Oct 21, 2019 - 11:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Definitely an ALPHA

Happy Trails,

Mike

JaxCoder.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kerlin wrote:
the intended cost
If they start charging for what was previously an "open" project I think the vast majority of folks would just walk away.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kerlin wrote:
Any idea of the intended cost for a single home user?

You're going to have to ask the Arduino people that!

 

Note that I am just quoting what I saw in an online publication, and what I have found by googling.

 

I have no involvement with this, and no inside info on Arduino's plans.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

He's a bit of an idiot if he thinks people aren't going to discuss IDE technologies - it's like religion or politics - everyone has strong views about what works and what does not work. (and don't anyone ever mention TI CodeComposer to me!!)

 

My "IDE" is GNU Nano editor and GNU Make. I have a Makefile that gets the target name from the directory it's in (for example "project.cpp" and friends are in a directory named "project". I edit the source and friends with nano, run "make", lather-rinse-repeat. Usually all I have to change in the Makefile is the CPU type and maybe fuse bits or "F_CPU". 

 

Sometimes if I'm super lazy, I use "inotifywait" to remake the executable each time I save an edit. That way I don't even need to go between edit and make repeatedly.

 

Arduino "IDE". Blah!

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

kerlin wrote:
the intended cost
If they start charging for what was previously an "open" project I think the vast majority of folks would just walk away.

 

I wonder if they will FINALLY give users the option to link in the floating point support or the option to use stdin/out/err instead of mountains of "Serial.print" statements and the "dtostrf" nonsense?

 

Arduino is so dumbed-down I think it is actually a hindrance to learning C/CPP. Not to mention their fear of using an extra 1.5k of flash in a 256mb board holding a whopping 6k binary.

 

Earth to Arduino devs: CPP is NOT Java and all Arduino users are NOT brain dead idiots!

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Krupski wrote:
I think it is actually a hindrance to learning C/CPP.

That was never the objective of Arduino.

 

The raison d'etre of Arduino was for people with no programming experience to avoid having to learn programming.

 

So I guess it has a bit of a split personality nowadays ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Krupski wrote:
My "IDE" is GNU Nano editor and GNU Make.
On Windows I have a synonym setup so I can invoke Notepad++ by typing "nano" ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Arduino announced the release of the alpha version of a completely new development environment for Arduino — the Arduino Pro IDE. The new architecture opens the door to new features like:

  • Sketch synchronisation with Arduino Create Editor
  • Debugger
  • Fully open to third party plug-ins 
  • Support for additional languages other than C++
  • The new Arduino Pro IDE is based on the latest technologies: 
  • The Arduino CLI running in daemon mode provides all the main Arduino features.
  • The application frontend is based on the Eclipse Theia Open Source IDE.
  • Electron, the framework behind Eclipse Theia, allows the use of web technologies on desktop environments.

 

https://www.eenewsembedded.com/news/arduino-pro-ide-alpha-now-available?news_id=122441

 

See also:

 

https://github.com/arduino/arduino-pro-ide

 

https://blog.arduino.cc/2019/10/18/arduino-pro-ide-alpha-preview-with-advanced-features/

 

 

All this to write a program to blink the pin 13 led without using delay()... 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Krupski wrote:
I think it is actually a hindrance to learning C/CPP.

That was never the objective of Arduino.

 

The raison d'etre of Arduino was for people with no programming experience to avoid having to learn programming.

 

So I guess it has a bit of a split personality nowadays ?

 

I can completely understand making things "stupid easy" so that a rank beginner can get fast, gratifying results, but the Arduino "culture" actively discourages people from growing and they seem totally closed to the idea of offering more "options" when the new user outgrows "blink.ino".

 

For example, they will encourage users who want to do something simple such as display a floating point number to use barely documented oddball functions rather than simply doing a "printf(" %5.1f\n") " because... horrors... the floating point version of the crt library uses 1.5k more flash... or fret over code that "blocks" such as a simple delay loop... because the AVR has SO MANY background processes running... or when a user needs double precision for a GPS program, he/she will be asked WHY they need doubles, instructed on the evils of software double precision math (it takes 4 milliseconds to run instead of 2... the HORROR!).

 

Sorry but the Arduino crowd seems to me to be the most sarcastic, most unhelpful and greatest purveyors of incorrect "fact" that I have ever encountered.

 

Once a rank beginner is no longer a beginner, their ability to grow is clamped by the Arduino crowd (IMHO).

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Krupski wrote:
My "IDE" is GNU Nano editor and GNU Make.
On Windows I have a synonym setup so I can invoke Notepad++ by typing "nano" ;-)

 

Yeah I get it. On the rare times when I NEED to run Windoze, I always get a "command or filename not found" when I mistakenly type "cp" instead of "copy" or wonder why "cd .." errors or why "nano" doesn't exist or why I can't string a bunch of commands together with "&&" ... ad-nauseaum.​ laugh​​​​​​

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why don’t we turn it around and note some of the more positive aspects of Arudino?

Here’s what I like-
100% open source - there was no hidden magic
Runs on the three major platforms
The environment was set up so you could press one button to compile and download
Method of ‘library’ management
‘standardised’ set of core functions
Huge selection of ‘libraries’ - this alone is a huge step forward.

As for the Arduino forum - can’t say I’ve participated in these. What does my head in is the Raspberry Pi clan. Everyone is an expert and all these bloggers seem to feed each other. One person blogs something then the others regurgitate it even if it is wrong. Then there’s the ‘evanangelists’ - Lord give me strength!

Don’t get me wrong - Arduino is not all beer and skittles. When one can purchase an obscure Chinese RISC-V based board that is 64bit, dual core and has 8MB of internal ram for $15USD, plug it in and since it has Arduino support I can write some simple code, press a button and it has compiled and downloaded. It has libraries for the camera and lcd. similarly with the teensy4.0 I purchased recently. Basically plug it in and I’m running. Do I care for digitalWrite etc? Not really. But I can look at the core code and find out quickly how to get down and dirty at register level. For me, that is the ‘advantage’ of Arduino.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I started with Arduino a few years back after a life event. I needed a distraction, and Arduino was fun, but trying to do my own boards was frustrating, and my C++ skittles are not very colorful, I very much prefer the limitations of C.

 

@Kartman why you are down with R-Pi, it is a Linux networking machine on a $10 board. I have had some running for a few years now. They run the AVR toolchain just like my Ubuntu desktop. But sadly I can not use VScode to remote into them (they are Zeros, not 3 or 4)

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Down with the RasPi? What gave you that impression? I made comment on the 'community'. I can't recall what I last needed to search on for the Pi - but I was led from blog to blog and it all seems they'd copied each other and it was hard to find a solid solution in all the 'noise'. Apart from shitty i/o. the Pi is fine for what it is - a set top box.

 

I have a collection of Pi's and various other Linux boards but I tend to use wireless routers and derivative boards for some of my embedded Linux work. Many of them have shitty i/o as well, so uart or USB is the easiest solid interface. As a point of comparison, something like the Beaglebone has far better i/o - lots of uarts, real i2C, spi etc. 'real' in that there is hardware support opposed to bit bashing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Why don’t we turn it around and note some of the more positive aspects of Arudino?

 

Oh yes.. agree completely. The way Arduino is set up anyone can develop a cool project and have a very good chance of it working, which results is gratification (positive feedback) that builds on itself. No complaints here.

 

But, those who are encouraged by their success invariably learn more and develop more complex projects.

 

And THAT'S where the problems begin. The Arduino people's desire to not waste a single byte of flash prevents new users from realizing that, yes, CPP does indeed support their ideas and needs, but some of these functions are WITHHELD from them in the name of saving a few bytes. Furthermore, the option to USE these functions at the risk of building a larger (or slower - or both) binary is denied them.

 

They want to save memory? That's OK, but it's MY ARDUINO and if I want to spend more flash, the Arduino people should not be telling me "it won't work' or "it's not supported" or "no, we won't tell you how to do it the standard way".

 

Also, some of the well known people are downright rude, arrogant or condescending. Others pass on and perpetuate plainly incorrect information.

 

Sorry to rant about it, but so often I've spent time writing lenghty posts on "that other site" genuinely trying to help a person who just needs a few things explained and has instead been torn apart by the "experts".

 

I know what it feels like to finally begin to understand something and just need help AT MY LEVEL to finally "get it" and I really hate seeing people on the verge of understanding be instead turned off by a rude know-it-all or, worse, someone who doesn't take the user's LEVEL of understanding into account and swamps them with too much info.

 

I've been told that I'm a "great teacher", but all I really do is try to get students to UNDERSTAND, not just memorize. If a person understands, they have no need to memorize.

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In some of the Arduino platforms I run there's printf() available. print and println get annoying past printing simple stuff.

As for double on avr-gcc, it is my understanding it only gives you single precision floating point. Double just gets mapped to single. Not an Arduino-ism.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

In some of the Arduino platforms I run there's printf() available. print and println get annoying past printing simple stuff.

As for double on avr-gcc, it is my understanding it only gives you single precision floating point. Double just gets mapped to single. Not an Arduino-ism.

 

Yes, "float" and "double" are (in Arduino land) the same thing. I understand the importance of conserving resources in a small embedded microcontroller environment, but the OPTION to use doubles should be available for those who need it (or merely want it). Same goes for floating point output and printf. Leave them out by default, but give the user the option to use them if he/she wants, rather than withholding it from the user because, of course, THEY know better than a mere mortal beginner! angry

 

The AVR toolchain (avr-gcc / avr-libc) has a nice function to setup any character device (serial, LCD, etc) to use stdout, stderr and stdin if appropriate (no stdin for an LCD display obviously!) smiley

 

I wrote a simp!e library for the Arduino that handles all the stuff involved in connecting streams to stdin/out/err with a simple object. For examp!e, to connect stdin/out/err to a serial port, all you do is include the tiny library and write "STDIO.open (Serial);"

 

It can even connect different devices at the same time (for example stdin and stdout to serial but route stderr to something else like another serial port or an LCD). I use it all the time to send debug data to  VFD display for testing.

 

It's handy to be able to use printf and formatting rather than the clumsy bunch of Serial.print calls. Without printf, even controlling numeric output is a pain (imagine calculating a digit's size and then sending the proper number of leading spaces to keep a number aligned on the display rather than simply using something like "%5u" to keep an int lined up!). Or setting up a buffer, then using "dstrtof" merely to print a float value rather than simply saying "%7.2f" (that is, IF they were nice enough to tell the newbie how to link in the float runtime so that the dreaded "?" wasn't displayed instead of the number!). And, "dstrtof" doesn't even provide the user defined number of digits after the decimal point like printf does.

 

All.this baloney to save 1 or 2 kb of flash when the binary barely uses 10% of the progmem anyway! Do they realize that all the extra, clumsy code required to do it the "Arduino way" takes extra space as well?

 

"Don't use printf, instead use a dozen Serial.print calls and a digit size calculation function. It will save space and make the code run 3 microseconds faster".

 

Pardon me while I roll my eyes and slowly shake my head...

 

And if someone dares to use malloc()... oh boy the flames really light up!

 

I hate being kicked in the face for trying to help. That's why I don't go "there" any longer.

 

Ugh... sorry for the rant again. I need to let it go...

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isn't it the case that once someone knows that the Arduino iDE is holding them back, that they have gained the necessary skills to move on to a more suitable system for them? I'll bet that 99.9% of Arduino users are perfectly happy with the standard out-of-box experience.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Krupski wrote:

Sorry to rant about it, but so often I've spent time writing lenghty posts on "that other site" genuinely trying to help a person who just needs a few things explained and has instead been torn apart by the "experts".

Thank goodness that never happens here...
Krupski wrote:
but the OPTION to use doubles should be available for those who need it (or merely want it).
I think you've missed Kartman's point.  This is not Arduino's 'fault'.  It is AVR GCC's 'fault'.  There are other toolchains which (e.g. ICC) which support 64-bit wide doubles, but they are not free and not open.  That won't fit the Arduino mold.  There is partial and experimental support for it in the very latest version of AVR GCC, and if it ever gets flushed out then it will also be available for Arduino.

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Krupski wrote:

but the OPTION to use doubles should be available for those who need it (or merely want it).

 

I think you've missed Kartman's point.  This is not Arduino's 'fault'.  It is AVR GCC's 'fault'.  There are other toolchains which (e.g. ICC) which support 64-bit wide doubles, but they are not free and not open.  That won't fit the Arduino mold.  There is partial and experimental support for it in the very latest version of AVR GCC, and if it ever gets flushed out then it will also be available for Arduino.

 

Yes I know, for example, that lack of support for 64 bit floating point (doubles) is avr-libc's "fault". But other things such as choosing to use certain runtime code is not available to the user as an EASY TO USE preference selection.

 

Despite the fact that the same certain questions appear over and over again in the forums demonstrates that these users have learned enough to need these "withheld" features and functions COULD easily be made available as a preference selection (and usually adding the checkbox and preference file key) is trivial, literally taking a few dozen lines of code and a few hours to implement.

 

But instead of providing the CHOICE to the user along with a warning (such as "that's left out to save memory, but if you really want it, go ahead and select it, but don't blame us when you run out of room"), the option is completely ignored and left out, requiring the user to use clunky workarounds or just say "heck with it" and give up. IMHO, thats wrong and stifles learning.

 

As an actual example, before I switched my Arduino projects from "IDE" to "Editor plus Makefile", I did my editing with the Nano editor and used the Arduino "IDE" merely as a "compile and upload" tool. I never used the IDE itself to generate or edit source. I had lots of.Motorola and Intel programming experience before I discovered that I could do a LOT more cool stuff with a $20 board than I could using my $70 Motorola 68HC11 EVBU  boards that didn't even have any flash.

 

Having lots of program space available, PLUS a decent amount of SRAM and EEPROM right on board a bitty little chip I could program in C instead of ASM was heaven. I didn't need or want to be sheltered from "printf" or "malloc" by the "experts".

 

Of.course, I quickly get tired of the relatively major effort required just to format and print a float instead of the dreaded question mark or the "dtostrf" kludge.

 

So, I invested an hour of my time to add a Preferences checkbox to the Arduino IDE called "Enable float support?" , recompiled the Java source and solved that problem. Note that up to that point, I knew nothing about JAVA and it was still easy. Even easier for the developers who KNOW JAVA and their own source code.

 

Yeah, if I use the option the code gets 1.5kb larger, but it's MY choice to use it if I need it. Why oh why can't the official Arduino developers add a few useful options to the "IDE" and prevent thousands of headaches and bad feelings?

 

I just don't understand why...

 

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is another angle to Arduino, it sort of started with Hernando Barragan's work, and has a history.

 

https://arduinohistory.github.io/

 

For me, that leaves a bad taste. Wiring software itself is now days licensed for non-commercial use only (form memory, last I looked).

 

my projects: https://github.com/epccs

Debugging is harder than programming - don’t write code you can’t debug! https://www.avrfreaks.net/forum/help-it-doesnt-work

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Exactly WHY would you want to use malloc() on a chip with 2k of ram? If you don't why it is a BAD idea, then maybe you shouldn't use it. Malloc() doesn't come free - ie it has overhead and possible bad side effects. If you understand these and use it within the constraints then you're home free. Again, on a chip with only 2k of ram - I'd be asking myself why I would want to use malloc().

 

I have no problem using printf() and double precision FP on the Arduino platform - I don't use an AVR though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ron_sutherland wrote:

There is another angle to Arduino, it sort of started with Hernando Barragan's work, and has a history.

 

https://arduinohistory.github.io/

 

For me, that leaves a bad taste. Wiring software itself is now days licensed for non-commercial use only (form memory, last I looked).

 

 

Wow. That was incredibly interesting. I had no idea what happened behind the scenes (or rather, I had the completely WRONG idea). Thanks for the link. Verrrry interesting..

 

Interestingly, I never really liked the "Arduino way". It looked to me to be an attempt to mold plain old C programming into kindergarten version of Java in an attempt at being "(new) user friendly".

 

I actually go out of my way to avoid non standard stuff like "digitalWrite" and use things like "PORTB |= (1<<3);". The Arduino specific functions always seemed like a crutch to me. I wanted to stay independent of them. The "Arduino way" always felt "dumbed down" to me (if that makes any sense?).

 

After reading the info you pointed me to, I now think I understand where my feelings came from (not the player's dishonesty, but the Wiring and Processing heritage that Arduino has).

 

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

Exactly WHY would you want to use malloc() on a chip with 2k of ram? If you don't why it is a BAD idea, then maybe you shouldn't use it.

 

 

One of the things I use malloc for is acquiring and working with variable amounts of data that I don't the size of at compile time. And it just feels wrong to declare a "big block" then maybe use it... or maybe not use it.

 

I am fully aware of the "dangers" of fragmentation, execution speed cost, the possibility of data or stack corruption and the possibility that a clean contiguous block may not be available and ruin my day, but I have yet to encounter ANY problems, errors or crashes due to malloc().

 

Maybe I'm just lucky? wink

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It could just be that the sequence you malloc() and free() avoids fragmentation. Change one thing and the code could be a house of cards. You might want to write some test code that mimics the use case and use the simulator in as7 to see how the memory allocation is actually working. Or pepper the code with printf()s. Then you can determine if your code works reliably by design or luck. If anything, you’ll have a better idea of how the memory allocator works. You might even find that it might just be easier to have a ‘big block’ and avoid all the malloc() shenanigans.

I’ve often been surprised at how my code actually runs vs what I thought it should do.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

It could just be that the sequence you malloc() and free() avoids fragmentation. Change one thing and the code could be a house of cards. You might want to write some test code that mimics the use case and use the simulator in as7 to see how the memory allocation is actually working. Or pepper the code with printf()s. Then you can determine if your code works reliably by design or luck. If anything, you’ll have a better idea of how the memory allocator works. You might even find that it might just be easier to have a ‘big block’ and avoid all the malloc() shenanigans.

I’ve often been surprised at how my code actually runs vs what I thought it should do.

 

Well, here is one function I use that allocates and frees memory and it works like a charm. No problems or crashes.

 

char *readline (const char *prompt)
{
    int c = 0; // character read
    int bsize = 0; // buffer size
    int inc = 4; // re-alloc increment
    int len = 0; // line length

    char *buf = (char *)(0); // buffer (user must free after using it)

    fprintf (stdout, "%s", prompt); // print prompt, if any

    while (1) { // continuous until break

        fflush (stdout);
        c = fgetc (stdin);  // grab a char

        if (len == 0 || len == bsize) {
            bsize += inc; // increase buffer size by increment
            buf = (char *) realloc (buf, (bsize * sizeof (char)));
        }

        switch (c) {

            case 0x0D:
            case 0x0A: { // end of line
                *(buf + len) = 0;
                return buf; // return line with null terminator
            }

            case 0x08:
            case 0x7F: { // backspace
                if (len > 0) { // if we CAN backspace....
                    len--; // move pointer back
                    *(buf + len) = 0; // invalidate char
                    fputc (0x08, stdout); // echo bs
                    fputc (0x20, stdout);
                    fputc (0x08, stdout);
                }
                break;
            }

            default: { // printable characters
                if (isprint (c)) {
                    *(buf + len) = c; // put char into buffer
                    len++; // prepare for another char
                    fputc (c, stdout); // echo to stdout
                }
                break;
            }
        }
    }
}

 

It also works find if the increment in 1 (that is, a re-alloc for each character).

 

By the way, this is run on a 328p or a MEGA2560.

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Speaking of Arduino options, here is my "Preferences" window of my hacked Arduino "IDE":

 

(click thumb for full size)

JPEG image

 

Probably the handiest options are the floating point options.

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Showing just one instance of use doesn't mean much. All it shows is you're calling the function correctly. You really want to instrument the allocator function and simulate the operations as your code would do in the real world. It all comes to the actual sequence of allocating, re-allocating and freeing - rinse and repeat. The size and sequence can either work in your favour or work against you. Think of it like a rubik's cube.

If you simply allocate some ram, extend it then free it then that is an ideal sequence - you might as well just statically allocate an array. If you get multiple tasks doing allocation, extending and freeing, then the outcome may not be so rosy.