Arduino 1.0 is Out: Here’s What You Need To Know

5 views
Skip to first unread message

Jeremy

unread,
Dec 1, 2011, 3:22:22 PM12/1/11
to RS
 
 

Sent to you by Jeremy via Google Reader:

 
 

via MAKE by Brian Jepson on 12/1/11


The Arduino team just released version 1.0 of the Arduino development environment! With it comes a bunch of changes that will affect you, especially if you use any add-on libraries:

The language changes include modifications to the Serial class, addition of DHCP and DNS support to the Ethernet library, a new SoftwareSerial library, multi-file support in the SD library, modifications to the Wire library and UDP class, etc.

While the Arduino team has been hard at work on 1.0, we’ve been working on an update to Michael Margolis’ Arduino Cookbook, and to help you make sense of Arduino 1.0, we’re sharing Michael’s Appendix H, Migrating to Arduino 1.0.

Although the Arduino Cookbook won’t be in print (or ebook) for a couple more weeks, you can get in on the action now with our early release: Buy it now on oreilly.com:

With this digital Early Release edition of Arduino Cookbook, 2nd edition, you get the entire book bundle in its earliest form – the author’s raw and unedited content – so you can take advantage of this content long before the book’s official release. You’ll also receive updates when significant changes are made, as well as the final ebook version.

Appendix H. Migrating to Arduino 1.0

Although it should not difficult to get sketches written for previous Arduino versions working with Arduino 1.0, that release has important changes you need to be aware of. The first thing you will notice when launching the software is the look of the IDE. Some icons are different from previous versions of the software and there are changes and additions in the menus. The error messages when dealing with selecting boards have been improved and the new ADK and Ethernet boards have been added.

More significant are changes in the underlying core software and libraries. The stated purpose of 1.0 is to introduce disruptive changes that will smooth the way for future enhancements but break some code written for older software. New header files mean that older contributed libraries will need updating. Methods in Ethernet and Wire have been changed and there are subtle differences in the print functionality.

New functionality has been added to Streams (the underlying class that anything that uses .print() statements), Ethernet, Wire (I2C), and low level input/output.

Improvements have been made to the way libraries handle dependencies and to simplify the support for new boards. Because of these changes, third party libraries will need updating, although many popular ones may already have been updated.

The file extension used for sketches has been changed from .pde to .ino to differentiate Processing files from Arduino and to remove the inconvenience of accidental opening of a file in the wrong IDE.

Sketches opened in the 1.0 IDE will be renamed from .pde to .ino when the file is saved. Once renamed, you will not be able to open them in older versions without changing the extension back. There is a option in the File→Preferences dialog to disable this behavior if you don’t want the files renamed.

The following is a summary of the changes you need to make for 1.0 to compile sketches written for earlier releases. You will find examples of these in the Chapters covering Serial, Wire, Ethernet, and Libraries.

Migrating print statements

There are a few changes in how print() (or println) is handled:

Working with byte datatypes
print(byte)now prints the integer value of the byte as ASCII characters, previous releases sent the actual character. This affects Serial, Ethernet, Wire or any other library that has a class derived from the Print class. Change:
Serial.print(byteVal)

To:

Serial.write(val); //send as char
The BYTE keyword
The BYTE keyword is no longer supported. Change:
Serial.print(val, BYTE)

To:

Serial.write(val); //sends as char
Return values from write() methods
Classes derived from Print must implement a write method to write data to the device that the class supports. The signature of the write method has changed from void to size_t to return the number of characters written. If you have a class derived from Print you need to modify the write method as follows and return the number of characters written (typically 1). Change:
void write

To:

size_t write
Migrating Wire (I2C) statements
You’ll need to make some changes when working with the Wire library. First, Wire method names have been changed to make them consistent with other services based on Streams. Change:
Wire.send()

To:

Wire.write()

And change:

Wire.receive()

To:

Wire.read()

Second, the write method requires types for constant arguments. You now need to specify the type for literal constant arguments to write. So, for example, change:

write(0x10)

To:

write((byte)0x10)

Migrating Ethernet statements

Arduino 1.0 changes a number of things in the Ethernet library.

Client class
The client Ethernet classes and methods have been renamed. Change:
client client(server, 80)

To:

EthernetClient client;

And change:

if(client.connect())

To:

if(client.connect(serverName, 80)>0)

Note: client.connect should test for values > 0 to ensure that errors returned as negative values are detected.

Server class

Change:

Server server(80)

To:

EthernetServer server(80)

And change:

UDP

To:

EthernetUDP

Migrating Libraries

If your sketch includes any libraries that have not been designed for 1.0 then you will need to change the library if it uses any of the old header files that have been replaced with the new Arduino.h file. If you include any of these libraries, change:

#include "wiring.h"
#include "WProgram.h"
#include "WConstants.h"
#include "pins_arduino.h"

To:

#include "Arduino.h"

You can use a conditional include to enable libraries to also compile in earlier versions. For example, you could replace #include "WProgram.h" with the following:

#if ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

New Stream Parsing functions

Arduino 1.0 introduced a simple parsing capability to enable finding and extracting strings and numbers from any of the objects derived from Stream, such as: Serial, Wire and Ethernet. These functions include:

    find(char *target);
    findUntil(char *target,char *term);
    readBytes(buffer,length);
    readBytesUntil(term,buffer,length);
    parseInt();
    parseFloat();

 
 

Things you can do from here:

 
 

coggs

unread,
Dec 1, 2011, 5:35:56 PM12/1/11
to Reverse Space
I just DL'd it for grins.

If you never left the Arduino IDE and never did allot of library
importing none of this has any impact...

It's still the same zip. No setup.exe, so you just unzip ostensibly
into C:\arduino-1.0 or wherever. Wherever in my case is always C:
\Arduino; I have several versions on standby and mark them with a file
at the top named THIS_IS_0022 or THIS_IS_0017, etc. So I just unzipped
and renamed it to C:\Arduino.

I don't represent your typical Arduino user. I only use the Arduino
distro for their avr-gcc tool chain, and I do my builds with a win32
version of make and bash courtesy Github.

I*try* to maintain my code such that it will be reasonably easy to
back-port it into the full Arduino IDE, but this is a moving target
for reasons which should be far too obvious.

At any rate, for my purposes, I am happy to say they haven't mucked
with the core avr-gcc tool chain. But apparently they did muck with
everything else;

I have a build which uses hacked copies of hardware/arduino/cores/
arduino (Wprogram.h and friends), and another which uses the distro's
versions.

Upshot is that if all you are depending on is the compiler tool chain,
then this release represents no big deal. If you do rely on their .h's
as-is, then you might have some work to do..

..c
www.cogwheelcircuitworks.com
www.cogwheel.com
www.linkedin.com/in/bobcoggeshall

On Dec 1, 3:22 pm, Jeremy <jth...@gmail.com> wrote:
>   Sent to you by Jeremy via Google Reader: Arduino 1.0 is Out: Here’s
> What You Need To Know via MAKE by Brian Jepson on 12/1/11
>

Reply all
Reply to author
Forward
0 new messages