Skip to content

Commit 90b6a9b

Browse files
Merge branch 'master' into win-report-firmware-fix
2 parents bcb7ca3 + 1bb88b1 commit 90b6a9b

File tree

8 files changed

+105
-38
lines changed

8 files changed

+105
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
release.sh

Boards.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@ writePort(port, value, bitmask): Write an 8 bit port.
200200
#define PIN_TO_SERVO(p) ((p) - 2)
201201

202202

203+
// Arduino DUE
204+
#elif defined(__SAM3X8E__)
205+
#define TOTAL_ANALOG_PINS 12
206+
#define TOTAL_PINS 66 // 54 digital + 12 analog
207+
#define VERSION_BLINK_PIN 13
208+
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS)
209+
#define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS)
210+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
211+
#define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS)
212+
#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21) // 70 71
213+
#define PIN_TO_DIGITAL(p) (p)
214+
#define PIN_TO_ANALOG(p) ((p) - 54)
215+
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
216+
#define PIN_TO_SERVO(p) ((p) - 2)
217+
218+
203219
// Teensy 1.0
204220
#elif defined(__AVR_AT90USB162__)
205221
#define TOTAL_ANALOG_PINS 0
@@ -234,6 +250,22 @@ writePort(port, value, bitmask): Write an 8 bit port.
234250
#define PIN_TO_SERVO(p) (p)
235251

236252

253+
// Teensy 3.0
254+
#elif defined(__MK20DX128__)
255+
#define TOTAL_ANALOG_PINS 14
256+
#define TOTAL_PINS 38 // 24 digital + 10 analog-digital + 4 analog
257+
#define VERSION_BLINK_PIN 13
258+
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 34)
259+
#define IS_PIN_ANALOG(p) (((p) >= 14 && (p) <= 23) || ((p) >= 34 && (p) <= 38))
260+
#define IS_PIN_PWM(p) digitalPinHasPWM(p)
261+
#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS)
262+
#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19)
263+
#define PIN_TO_DIGITAL(p) (p)
264+
#define PIN_TO_ANALOG(p) (((p)<=23)?(p)-14:(p)-24)
265+
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
266+
#define PIN_TO_SERVO(p) (p)
267+
268+
237269
// Teensy++ 1.0 and 2.0
238270
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
239271
#define TOTAL_ANALOG_PINS 8

Firmata.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,18 @@ void FirmataClass::begin(void)
6767
void FirmataClass::begin(long speed)
6868
{
6969
Serial.begin(speed);
70-
begin(Serial);
71-
blinkVersion();
70+
FirmataSerial = &Serial;
71+
blinkVersion();
72+
printVersion();
73+
printFirmwareVersion();
7274
}
7375

7476
/* begin method for overriding default stream */
7577
void FirmataClass::begin(Stream &s)
7678
{
7779
FirmataSerial = &s;
80+
// do not call blinkVersion() here because some hardware such as the
81+
// Ethernet shield use pin 13
7882
printVersion();
7983
printFirmwareVersion();
8084
}

Firmata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* installed firmware. */
2222
#define FIRMATA_MAJOR_VERSION 2 // for non-compatible changes
2323
#define FIRMATA_MINOR_VERSION 3 // for backwards compatible changes
24-
#define FIRMATA_BUGFIX_VERSION 4 // for bugfix releases
24+
#define FIRMATA_BUGFIX_VERSION 6 // for bugfix releases
2525

2626
#define MAX_DATA_BYTES 32 // max number of data bytes in non-Sysex messages
2727

readme.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ Most of the time you will be interacting with arduino with a client library on t
3939
* Flash/AS3
4040
* [http://funnel.cc]
4141
* [http://code.google.com/p/as3glue/]
42+
* PHP
43+
* [https://bitbucket.org/ThomasWeinert/carica-firmata]
4244

4345
Note: The above libraries may support various versions of the Firmata protocol and therefore may not support all features of the latest Firmata spec nor all arduino and arduino-compatible boards. Refer to the respective projects for details.
4446

45-
##Updating Firmata in the Arduino IDE
47+
##Updating Firmata in the Arduino IDE (< Arduino 1.5)
4648
The version of firmata in the Arduino IDE contains an outdated version of Firmata. To update Firmata, clone the repo into the location of firmata in the arduino IDE or download the latest [tagged version](https://github.com/firmata/arduino/tags) (stable), rename the folder to "Firmata" and replace the existing Firmata folder in your Ardino application.
4749

4850
**Mac OSX**:
4951

50-
```
51-
rm -r /Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata
52-
git clone [email protected]:firmata/arduino.git /Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata
52+
```bash
53+
$ rm -r /Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata
54+
$ git clone [email protected]:firmata/arduino.git /Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata
5355
```
5456

5557
If you are downloading the latest tagged version of Firmata, rename it to "Firmata" and copy to /Applications/Arduino.app/Contents/Resources/Java/libraries/ overwriting the existing Firmata directory. Right-click (or conrol + click) on the Arduino application and choose "Show Package Contents" and navigate to the libraries directory.
@@ -58,20 +60,43 @@ If you are downloading the latest tagged version of Firmata, rename it to "Firma
5860

5961
Using the Git Shell application installed with [GitHub for Windows](http://windows.github.com/) (set default shell in options to Git Bash) or other command line based git tool:
6062

61-
```
62-
# update the path and arduino version as necessary
63-
rm -r c:/Program\ Files/arduino-1.x/libraries/Firmata
64-
git clone [email protected]:firmata/arduino.git c:/Program\ Files/arduino-1.x/libraries/Firmata
63+
update the path and arduino version as necessary
64+
```bash
65+
$ rm -r c:/Program\ Files/arduino-1.x/libraries/Firmata
66+
$ git clone [email protected]:firmata/arduino.git c:/Program\ Files/arduino-1.x/libraries/Firmata
6567
```
6668

6769
Note: If you use GitHub for Windows, you must clone the firmata/arduino repository using the Git Shell application as described above. You can use the Github for Windows GUI only after you have cloned the repository. Drag the Firmata file into the Github for Windows GUI to track it.
6870

6971
**Linux**:
7072

73+
update the path and arduino version as necessary
74+
```bash
75+
$ rm -r ~/arduino-1.x/libraries/Firmata
76+
$ git clone [email protected]:firmata/arduino.git ~/arduino-1.x/libraries/Firmata
77+
```
78+
79+
##Updating Firmata in the Arduino IDE (>= Arduino 1.5.2)
80+
As of Arduino 1.5.2 and there are separate library directories for the sam and
81+
avr architectures. To update Firmata in Arduino 1.5.2 or higher, follow the
82+
instructions above for pre Arduino 1.5 versions but update the path as follows:
83+
84+
**Mac OSX**:
85+
```
86+
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/libraries/Firmata
87+
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/sam/libraries/Firmata
88+
```
89+
90+
**Windows**:
91+
```
92+
/Program\ Files/arduino-1.5.x/hardware/arduino/avr/libraries/Firmata
93+
/Program\ Files/arduino-1.5.x/hardware/arduino/sam/libraries/Firmata
94+
```
95+
96+
**Linux**
7197
```
72-
# update the path and arduino version as necessary
73-
rm -r ~/arduino-1.x/libraries/Firmata
74-
git clone [email protected]:firmata/arduino.git ~/arduino-1.x/libraries/Firmata
98+
~/arduino-1.5.x/hardware/arduino/avr/libraries/Firmata
99+
~/arduino-1.5.x/hardware/arduino/sam/libraries/Firmata
75100
```
76101

77102
<a name="contributing" />

test/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#Testing Firmata
22

3-
TO DO: overview of firmata testing process.
3+
The Firmata test suite includes unit tests (see the unit directory). Integration
4+
tests may also be added at some point in the future.
5+
6+
If you make changes to Firmata.cpp, run the tests in /test/unit/ to ensure
7+
that your changes have not produced any unexpected errors.

test/unit/firmata_test/firmata_test.ino

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1+
/*
2+
* To run this test suite, you must first install the ArduinoUnit library
3+
* to your Arduino/libraries/ directory.
4+
* You can get ArduinoUnit here: https://github.com/mmurdoch/arduinounit
5+
* Download version 2.0 or greater.
6+
*/
7+
18
#include <ArduinoUnit.h>
29
#include <Firmata.h>
310

4-
TestSuite suite;
5-
611
void setup()
712
{
813
Serial.begin(9600);
914
}
1015

1116
void loop()
1217
{
13-
suite.run();
14-
}
15-
16-
void assertStringsEqual(Test& __test__, const char* expected, const String& actual)
17-
{
18-
size_t expectedLength = strlen(expected);
19-
assertEquals(expectedLength, actual.length());
20-
for (size_t i = 0; i < expectedLength; i++)
21-
{
22-
assertEquals(expected[i], actual[i]);
23-
}
18+
Test::run();
2419
}
2520

21+
// Note: this test required adding a method (Firmata.unsetFirmwareVersion()) to
22+
// Firmata.cpp solely for the purpose of running this test. The method has been
23+
// removed from Firmata.cpp, but keeping the test here as a recored
2624
// test(setFirmwareVersionDoesNotLeakMemory)
2725
// {
2826
// Firmata.setFirmwareVersion(1, 0);
@@ -48,7 +46,7 @@ test(beginPrintsVersion)
4846
FIRMATA_MINOR_VERSION,
4947
0
5048
};
51-
assertStringsEqual(__test__, expected, stream.bytesWritten());
49+
assertEqual(expected, stream.bytesWritten());
5250
}
5351

5452
void processMessage(const byte* message, size_t length)
@@ -84,7 +82,7 @@ test(processWriteDigital_0)
8482
byte message[] = { DIGITAL_MESSAGE, 0, 0 };
8583
processMessage(message, 3);
8684

87-
assertEquals(0, _digitalPortValue);
85+
assertEqual(0, _digitalPortValue);
8886
}
8987

9088
test(processWriteDigital_127)
@@ -95,7 +93,7 @@ test(processWriteDigital_127)
9593
byte message[] = { DIGITAL_MESSAGE, 127, 0 };
9694
processMessage(message, 3);
9795

98-
assertEquals(127, _digitalPortValue);
96+
assertEqual(127, _digitalPortValue);
9997
}
10098

10199
test(processWriteDigital_128)
@@ -106,7 +104,7 @@ test(processWriteDigital_128)
106104
byte message[] = { DIGITAL_MESSAGE, 0, 1 };
107105
processMessage(message, 3);
108106

109-
assertEquals(128, _digitalPortValue);
107+
assertEqual(128, _digitalPortValue);
110108
}
111109

112110
test(processWriteLargestDigitalValue)
@@ -118,7 +116,7 @@ test(processWriteLargestDigitalValue)
118116
processMessage(message, 3);
119117

120118
// Maximum of 14 bits can be set (B0011111111111111)
121-
assertEquals(0x3FFF, _digitalPortValue);
119+
assertEqual(0x3FFF, _digitalPortValue);
122120
}
123121

124122
test(defaultDigitalWritePortIsZero)
@@ -129,7 +127,7 @@ test(defaultDigitalWritePortIsZero)
129127
byte message[] = { DIGITAL_MESSAGE, 0, 0 };
130128
processMessage(message, 3);
131129

132-
assertEquals(0, _digitalPort);
130+
assertEqual(0, _digitalPort);
133131
}
134132

135133
test(specifiedDigitalWritePort)
@@ -140,6 +138,5 @@ test(specifiedDigitalWritePort)
140138
byte message[] = { DIGITAL_MESSAGE + 1, 0, 0 };
141139
processMessage(message, 3);
142140

143-
assertEquals(1, _digitalPort);
141+
assertEqual(1, _digitalPort);
144142
}
145-

test/unit/readme.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#Firmata Unit Tests
22

3-
TO DO: instructions on running unit tests and creating new tests for new
4-
features.
3+
Unit tests are written using the [ArduinoUnit](https://github.com/mmurdoch/arduinounit) library (version 2.0).
4+
5+
Follow the instructions in the [ArduinoUnit readme](https://github.com/mmurdoch/arduinounit/blob/master/readme.md) to install the library.
6+
7+
Compile and upload the test sketch as you would any other sketch. Then open the
8+
Serial Monitor to view the test results.

0 commit comments

Comments
 (0)