Skip to content

Commit 29f1672

Browse files
authored
Merge pull request #223 from ianfixes/2020-11-19_library_space_coercion
Fix regression in handling of spaces in dependent library names
2 parents 7c12203 + 94a2df0 commit 29f1672

File tree

11 files changed

+113
-4
lines changed

11 files changed

+113
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1818
- Support for mock EEPROM (but only if board supports it)
1919
- Add stubs for `Client.h`, `IPAddress.h`, `Printable.h`, `Server.h`, and `Udp.h`
2020
- `Wire` now has a mock support for the master role
21+
- Sample project for `BusIO` to show problem finding header file
2122

2223
### Changed
2324
- Move repository from https://github.com/ianfixes/arduino_ci to https://github.com/Arduino-CI/arduino_ci

SampleProjects/BusIO/.arduino-ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
unittest:
2+
platforms:
3+
- mega2560
4+
libraries:
5+
- "Adafruit BusIO"
6+
# - "Adafruit_BusIO" <= This works if you have the library pre-installed
7+
8+
compile:
9+
platforms:
10+
- mega2560
11+
libraries:
12+
- "Adafruit BusIO"

SampleProjects/BusIO/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.bundle

SampleProjects/BusIO/Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'arduino_ci', path: '../../'

SampleProjects/BusIO/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# BusIO
2+
3+
This is an example of a library that depends on Adafruit BusIO.
4+
It is provided to help reproduce #192.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <Adafruit_SPIDevice.h>
2+
3+
#define SPIDEVICE_CS 10
4+
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS);
5+
6+
7+
void setup() {
8+
while (!Serial) { delay(10); }
9+
Serial.begin(115200);
10+
Serial.println("SPI device read and write test");
11+
12+
if (!spi_dev.begin()) {
13+
Serial.println("Could not initialize SPI device");
14+
while (1);
15+
}
16+
17+
uint8_t buffer[32];
18+
19+
// Try to read 32 bytes
20+
spi_dev.read(buffer, 32);
21+
Serial.print("Read: ");
22+
for (uint8_t i=0; i<32; i++) {
23+
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
24+
}
25+
Serial.println();
26+
27+
// read a register by writing first, then reading
28+
buffer[0] = 0x8F; // we'll reuse the same buffer
29+
spi_dev.write_then_read(buffer, 1, buffer, 2, false);
30+
Serial.print("Write then Read: ");
31+
for (uint8_t i=0; i<2; i++) {
32+
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
33+
}
34+
Serial.println();
35+
}
36+
37+
void loop() {
38+
39+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=BusIO
2+
version=0.1.0
3+
author=James Foster <[email protected]>
4+
maintainer=James Foster <[email protected]>
5+
sentence=Sample BusIO library to validate import of Adafruit BusIO
6+
paragraph=Sample BusIO library to validate import of Adafruit BusIO
7+
category=Other
8+
url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/BusIO
9+
architectures=avr,esp8266
10+
includes=BusIO.h

SampleProjects/BusIO/src/BusIO.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <Adafruit_SPIDevice.h>
2+
#include <Arduino.h>
3+
4+
class BusIO {
5+
public:
6+
BusIO() {}
7+
~BusIO() {}
8+
int answer() { return 42; }
9+
};

SampleProjects/BusIO/test/busio.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
bundle config --local path vendor/bundle
3+
bundle install
4+
bundle exec arduino_ci.rb --skip-examples-compilation
5+
*/
6+
7+
#include <Arduino.h>
8+
#include <ArduinoUnitTests.h>
9+
#include <BusIO.h>
10+
11+
unittest(busio_answer) {
12+
// token test
13+
BusIO busIO;
14+
assertEqual(42, busIO.answer());
15+
}
16+
17+
unittest_main()

cpp/arduino/Wire.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class TwoWire : public ObservableDataStream {
116116
// https://www.arduino.cc/en/Reference/WireRequestFrom
117117
// Used by the master to request bytes from a slave device. The bytes may then
118118
// be retrieved with the available() and read() functions.
119-
uint8_t requestFrom(uint8_t address, size_t quantity, bool stop) {
119+
uint8_t requestFrom(uint8_t address, uint8_t quantity, uint32_t _iaddress, uint8_t _isize, uint8_t stop) {
120120
assert(_didBegin);
121121
assert(address > 0 && address < SLAVE_COUNT);
122122
assert(quantity <= BUFFER_LENGTH);
@@ -131,11 +131,20 @@ class TwoWire : public ObservableDataStream {
131131
return 0;
132132
}
133133
}
134+
135+
uint8_t requestFrom(uint8_t address, uint8_t quantity, uint8_t stop) {
136+
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint32_t)0, (uint8_t)0, (uint8_t)stop);
137+
}
138+
139+
uint8_t requestFrom(uint8_t address, uint8_t quantity) {
140+
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
141+
}
142+
134143
uint8_t requestFrom(int address, int quantity) {
135-
return requestFrom((uint8_t)address, (size_t)quantity, true);
144+
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
136145
}
137146
uint8_t requestFrom(int address, int quantity, int stop) {
138-
return requestFrom((uint8_t)address, (size_t)quantity, (bool)stop);
147+
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)stop);
139148
}
140149

141150
// https://www.arduino.cc/en/Reference/WireWrite

lib/arduino_ci/cpp_library.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,12 @@ def arduino_library_src_dirs(aux_libraries)
317317
# Pull in all possible places that headers could live, according to the spec:
318318
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification
319319

320-
aux_libraries.map { |d| self.class.new(@arduino_lib_dir + d, @arduino_lib_dir, @exclude_dirs).header_dirs }.flatten.uniq
320+
aux_libraries.map do |d|
321+
# library manager coerces spaces in package names to underscores
322+
# see https://github.com/ianfixes/arduino_ci/issues/132#issuecomment-518857059
323+
legal_dir = d.tr(" ", "_")
324+
self.class.new(@arduino_lib_dir + legal_dir, @arduino_lib_dir, @exclude_dirs).header_dirs
325+
end.flatten.uniq
321326
end
322327

323328
# GCC command line arguments for including aux libraries

0 commit comments

Comments
 (0)