Commit Graph

3580 Commits

Author SHA1 Message Date
Matthijs Kooijman 4b3db72a46 Fix two signedness warnings
This helps towards #1792
2014-02-19 16:09:30 +01:00
Matthijs Kooijman 1c6a57e15d Include stdio.h in dtostrf.c
This makes the declaration of sprintf available, so the function is not
implicitely declared, which triggers two compiler warnings.

This helps towards #1792
2014-02-19 16:09:30 +01:00
Matthijs Kooijman 8e35973ff9 Remove check that is always false
len is an unsigned variable, so it will never be less than 0.

This helps towards #1792.
2014-02-19 16:09:30 +01:00
Matthijs Kooijman b196a4a9c5 Suppress "unused parameter" warnings
A bunch of functions have parameters they do not use, but which cannot
be removed for API compatibility.

In syscalls_sam3.c, there are a lot of these, so this adds an "UNUSED"
macro which adds the "unused" variable attribute if supported (GCC
specific), or is just a noop on other compilers.

In CDC.cpp, there's only three of these variables, so this commit just
forces a dummy evaluation of them to suppress the warnings.

This helps towards #1792.
2014-02-19 16:09:30 +01:00
Matthijs Kooijman 4cf21dcdd1 Don't store peeked characters in a char variable
peekNextDigit() returns an int, so it can return -1 in addition to all
256 possible bytes. By putting the result in a signe char, all bytes
over 128 will be interpreted as "no bytes available". Furthermore, it
seems that on SAM "char" is unsigned by default, causing the
"if (c < 0)" line a bit further down to always be false.

Using an int is more appropriate.

A different fix for this issue was suggested in #1399. This fix helps
towards #1728.
2014-02-19 16:09:30 +01:00
JC Wren 12b706551d SD.c: Fix error in comment for remove()
Comment was duplicated from mkdir() and not updated.
2014-02-19 16:09:30 +01:00
J.C. Wren a991f26b8d Sd2Card.cpp: fix compiler warning
All the while() loops that check for the SPI transfer to be complete have the
semi-colon immediately after the closing parenthesis.  This both causes a
compiler warning of "warning: suggest a space before ';' or explicit braces
around empty body in 'while' statement", and is considered a less-than-ideal
programming practice.  This patch breaks the semi-colon on to the next line,
both eliminating the compiler error and making the code more readable.

In all probability the test should be moved into a macro or a inlineable
sub-routine.
2014-02-19 16:09:30 +01:00
Matthijs Kooijman ece02e93bd Instead of #defining true and false, include stdbool.h
In C++, true and false are language keywords, so there is no need to
define them as macros. Including stdbool.h in C++ effectively changes
nothing. In C, true, false and also the bool type are not available, but
including stdbool.h will make them available.

Using stdbool.h means that we get true, false and the bool type in
whatever way the compiler thinks is best, which seems like a good idea
to me.

This also fixes the following compiler warnings if a .c file includes
both stdbool.h and Arduino.h:

	warning: "true" redefined [enabled by default]
	 #define true 0x1

	warning: "false" redefined [enabled by default]
	#define false 0x0

This fixes #1570 and helps toward fixing #1728.

This only changed the AVR core, the SAM core already doesn't define true
and false (but doesn't include stdbool.h either).
2014-02-19 16:09:29 +01:00
Matthijs Kooijman 3035239a4e Use a union in IPAddress for uint8_t[] <-> uint32_t conversion
Previously, pointer casting was used, but this resulted in strict-aliasing warnings:

IPAddress.h: In member function ‘IPAddress::operator uint32_t() const’:
IPAddress.h:46:61: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     operator uint32_t() const { return *((uint32_t*)_address); };
                                                             ^
IPAddress.h: In member function ‘bool IPAddress::operator==(const IPAddress&) const’:
IPAddress.h:47:81: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
                                                                                 ^
IPAddress.h:47:114: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };

Converting between unrelated types like this is commonly done using a union,
which do not break the strict-aliasing rules. Using that union, inside
IPAddress there is now an attribute _address.bytes for the raw byte
arra, or _address.dword for the uint32_t version.

Since we now have easy access to the uint32_t version, this also removes
two memcpy invocations that can just become assignments.

This patch does not change the generated code in any way, the compiler
already optimized away the memcpy calls and the previous casts mean
exactly the same.

This is a different implementation of a part of #1399 and it helps
toward fixing #1728.
2014-02-19 16:09:29 +01:00
Matthijs Kooijman 9dca56dced Don't use IPAddress::_address from EthernetClass
EthernetClass is a friend class of IPAddress, so it is allowed to use
its _address attribute directly. However, it should be using
IPAddress::raw_address() instead, like all the other friend classes do.

This changes allows changing the _address attribute to fix some warnings
next.
2014-02-19 16:09:29 +01:00
Matthijs Kooijman 5b83043290 Include stdint.h from IPAddress.h on SAM
This happened for AVR in 34885b01, this commit makes the SAM version
identical again.
2014-02-18 21:10:35 +01:00
Cristian Maglie 4e334b2e96 Merge branch 'master' into ide-1.5.x
Conflicts:
	app/src/processing/app/Base.java
2014-02-17 14:39:17 +01:00
Cristian Maglie 3a72c02480 Removed unused code, fixed indentation. 2014-02-17 14:19:40 +01:00
Cristian Maglie 57bee97d7b Local (user installed) libraries have priority over system libraries
See #1853
2014-02-17 14:19:40 +01:00
Federico Fissore 2115d63af5 Merge remote-tracking branch 'arduino/master' into ide-1.5.x 2014-02-17 09:17:46 +01:00
Federico Fissore 1d060cafe0 Merge pull request #1867 from felixphew/patch-2
Update README.md
2014-02-17 09:17:05 +01:00
felixphew fd2ecf71b8 Update README.md
Decapitalised secondary headings and linked the *Credits* section
2014-02-17 07:32:09 +11:00
Cristian Maglie 92958ef4cb Merge pull request #1863 from matthijskooijman/ide-1.5.x-serial-int
In HardwareSerial, don't use int for buffer indices
2014-02-14 15:42:26 +01:00
Cristian Maglie 8504bca280 Merge branch 'ide-1.5.x' of github.com:dpslwk/Arduino into dpslwk-ide-1.5.x 2014-02-14 15:35:47 +01:00
Matthijs Kooijman 6372eb8c6c In HardwareSerial, don't use int for buffer indices
The index attributes have been uint8_t for a while, so there is no point
in using int for local variables. This should allow the compiler to
generate slightly more efficient code, but (at least on gcc 4.8.2) it
also confuses the register allocator, causing this change to increase
code size by 2 bytes instead due to extra push/pop instructions (but
this will probably change in the future if the compiler improves).
2014-02-14 10:25:34 +01:00
Cristian Maglie 6104b2879d Merge remote-tracking branch 'arduino/master' into ide-1.5.x 2014-02-13 18:16:48 +01:00
Cristian Maglie cc6d7cdbd1 Added license for Client, IPAddressm and Server (master branch)
See #1847 and #1117
2014-02-13 17:49:14 +01:00
Cristian Maglie 8eaaeebadf Added license for Arduino.h, binary.h and main.cpp (master branch)
See #1847 and #1117
2014-02-13 17:48:47 +01:00
Cristian Maglie 79f5a34954 Revert "Changed pins definition in variants from constants to #defines."
This reverts commit e2b15c852b.
2014-02-13 17:37:00 +01:00
Cristian Maglie a96c8cab12 Merge branch 'master' into ide-1.5.x 2014-02-12 17:17:33 +01:00
Cristian Maglie 2a8c06381f Added some friendly messages for Arduino Robot include errors on old sketches
After merging #1859, old sketches that uses Robot_Control library must include
Wire.h and SPI.h to work properly.
2014-02-12 15:28:53 +01:00
Cristian Maglie 9dd425515b Merge branch 'master' of github.com:X-Y/Arduino into X-Y-master 2014-02-12 14:51:46 +01:00
Cristian Maglie eb1e2f2db1 Revert "Changed pins definition in variants from constants to #defines."
This reverts commit 7fcba37acf.
2014-02-12 14:46:48 +01:00
Xun Yang 53adddcb33 Fixed issue #1478, #1599, #1709, motors being opposite, updated turning algorithm 2014-02-12 02:02:20 +01:00
Cristian Maglie a44f4bef7c Merge remote-tracking branch 'arduino/master' into ide-1.5.x
Conflicts:
	app/src/processing/app/Base.java
2014-02-11 16:44:07 +01:00
Cristian Maglie b78fcf5139 Merge pull request #1853 from PaulStoffregen/master
If 2 libs have same .h file, use the lib with same dir name
2014-02-11 16:24:05 +01:00
PaulStoffregen ef4f0f3bc9 If 2 libs have same .h file, use the lib with same dir name 2014-02-10 14:18:47 -08:00
Cristian Maglie 397046a844 Added license for Arduino.h, binary.h and main.cpp
See #1847
2014-02-10 12:55:16 +01:00
Cristian Maglie 9eb0c1495c Added license for Client, IPAddressm and Server
See #1847
2014-02-10 12:55:16 +01:00
Cristian Maglie 9d46f1ff12 Added license for avr/HardwareSerial.
See #1847
2014-02-10 12:55:16 +01:00
Cristian Maglie d60f1df996 Added command line option --verbose-build and --verbose-upload 2014-02-10 12:55:16 +01:00
Fede85 5dfafe7847 WiFi Shield examples: added the firmware version check 2014-02-06 18:40:48 +01:00
Federico Fissore 1fe82d847c Merge remote-tracking branch 'arduino/ide-1.5.x' into ide-1.5.x 2014-02-06 10:22:20 +01:00
Federico Fissore 0c62798fcb Fixed typo in test 2014-02-06 10:21:54 +01:00
Cristian Maglie 793b139d39 Merge remote-tracking branch 'arduino/master' into ide-1.5.x 2014-02-05 15:58:30 +01:00
Cristian Maglie b415903b69 Merge pull request #1836 from KonradIT/master
Use markdown lang in the readme.
2014-02-05 12:32:20 +01:00
Scott Fitzgerald 1c28dab57b Updated Listfiles SD example
Changed SS pin to 4 for consistency with other examples
2014-02-02 14:35:04 +04:00
Cristian Maglie b6fa3c7261 Update .classpath 2014-01-30 11:03:22 +01:00
Konrad Iturbe 7ea7c5291d Rename README.mkdn to README.md 2014-01-29 22:18:24 +01:00
Konrad Iturbe ede9b56407 Update and rename readme.txt to README.mkdn 2014-01-29 21:59:23 +01:00
Konrad Iturbe 9b86cb6e42 Update readme.txt 2014-01-29 21:57:29 +01:00
Cristian Maglie 5cf8671b4a Merge pull request #1835 from ribbons/hardwareserial-warning
Reorder HardwareSerial initialisation list to fix compiler warnings
2014-01-29 12:44:55 -08:00
Matt Robinson 6315177191 Reorder HardwareSerial init to fix compiler warn
Switch the tx and rx buffer head/tail entries in the HardwareSerial
initialisation list so that they match the order the fields are defined
in. This fixes a compiler warning (repeated for each of the
HardwareSerial source files the header is used in).
2014-01-29 20:10:32 +00:00
Cristian Maglie fbea640055 Fixed macosx app template to reflect jssc update 2014-01-29 16:40:49 +01:00
Scott Fitzgerald 017326acc6 Minor changes to Communication Examples
Added a note to the included Processing sketches about replacing
println(Serial.list()) with Serial.printArray() if using Processing 2.1
or later
2014-01-29 14:27:09 +04:00