Skip to content

Commit 621b4ec

Browse files
authored
Merge pull request #1027 from kegilbert/remove-migration-example3
Remove migration guide example that no longer fails
2 parents 6e79609 + 7981835 commit 621b4ec

File tree

1 file changed

+0
-176
lines changed

1 file changed

+0
-176
lines changed

docs/tutorials/migrate-from-mbed-os-2-to-5.md

Lines changed: 0 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -165,182 +165,6 @@ int main() {
165165

166166
Now, the program successfully compiles.
167167

168-
#### Example component 3 - library fails to compile
169-
170-
Repositories used in this example:
171-
172-
- Component: [CN0357 - Toxic gas measurement](https://os.mbed.com/components/CN0357-Toxic-gas-measurement/).
173-
- Hello World repo: [CN0357-helloworld](https://os.mbed.com/teams/AnalogDevices/code/CN0357-helloworld/).
174-
175-
Compile configuration used in this example:
176-
177-
- Platform: [FRDM-K64F](https://os.mbed.com/platforms/FRDM-K64F/).
178-
- Toolchain: [GCC ARM](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads).
179-
180-
In the command-line, run:
181-
182-
```
183-
mbed import http://mbed.org/teams/AnalogDevices/code/CN0357-helloworld/
184-
cd CN0357-helloworld
185-
mbed remove mbed
186-
mbed add mbed-os
187-
mbed compile -m k64f -t gcc_arm
188-
```
189-
190-
##### Compilation errors
191-
192-
After you have cloned the repository to your computer and deployed the latest version of Mbed OS, check whether any compilation errors exist.
193-
194-
Here is the output produced from `mbed compile`:
195-
196-
```
197-
Building project CN0357-helloworld (K64F, GCC_ARM)
198-
Scan: .
199-
Scan: mbed
200-
Scan: env
201-
Scan: FEATURE_LWIP
202-
Scan: FEATURE_STORAGE
203-
Compile [ 0.3%]: AD5270.cpp
204-
[Error] AD5270.h@91,25: 'SPI_CS' was not declared in this scope
205-
[Error] AD5270.h@91,80: 'SPI_MOSI' was not declared in this scope
206-
[Error] AD5270.h@91,105: 'SPI_MISO' was not declared in this scope
207-
[Error] AD5270.h@91,129: 'SPI_SCK' was not declared in this scope
208-
[ERROR] In file included from ./CN0357/AD5270/AD5270.cpp:50:0:
209-
./CN0357/AD5270/AD5270.h:91:25: error: 'SPI_CS' was not declared in this scope
210-
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
211-
^~~~~~
212-
./CN0357/AD5270/AD5270.h:91:80: error: 'SPI_MOSI' was not declared in this scope
213-
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
214-
^~~~~~~~
215-
./CN0357/AD5270/AD5270.h:91:105: error: 'SPI_MISO' was not declared in this scope
216-
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
217-
^~~~~~~~
218-
In file included from ./CN0357/AD5270/AD5270.cpp:50:0:
219-
./CN0357/AD5270/AD5270.h:91:129: error: 'SPI_SCK' was not declared in this scope
220-
AD5270(PinName CS = SPI_CS, float max_resistance = 20000.0, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
221-
^~~~~~~
222-
223-
[mbed] ERROR: "/usr/local/opt/python/bin/python2.7" returned error code 1.
224-
[mbed] ERROR: Command "/usr/local/opt/python/bin/python2.7 -u /Users/jenplu01/Repos/CN0357-helloworld/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/k64f/gcc_arm" in "/Users/jenplu01/Repos/CN0357-helloworld"
225-
---
226-
```
227-
228-
The errors relating to "was not declared in this scope" are library-specific errors. To fix this, go into the `./CN0357/AD5270/AD5270.h` header file and remove the constructor's default arguments. Line 91 of the `AD5270.h` header file now looks like this:
229-
230-
```
231-
AD5270(PinName CS, float max_resistance, PinName MOSI, PinName MISO, PinName SCK);
232-
```
233-
234-
Run `mbed compile` again:
235-
236-
```
237-
Building project CN0357-helloworld (K64F, GCC_ARM)
238-
Scan: .
239-
Scan: mbed
240-
Scan: env
241-
Scan: FEATURE_LWIP
242-
Scan: FEATURE_STORAGE
243-
Compile [ 2.5%]: main.cpp
244-
[Error] AD7790.h@114,51: 'SPI_CS' was not declared in this scope
245-
[Error] AD7790.h@114,74: 'SPI_MOSI' was not declared in this scope
246-
[Error] AD7790.h@114,99: 'SPI_MISO' was not declared in this scope
247-
[Error] AD7790.h@114,123: 'SPI_SCK' was not declared in this scope
248-
[Error] CN0357.h@77,73: 'SPI_MOSI' was not declared in this scope
249-
[Error] CN0357.h@77,98: 'SPI_MISO' was not declared in this scope
250-
[Error] CN0357.h@77,122: 'SPI_SCK' was not declared in this scope
251-
[Error] main.cpp@111,12: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 3, which is not yet defined
252-
[Error] main.cpp@111,0: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 4, which is not yet defined
253-
[Error] main.cpp@111,0: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 5, which is not yet defined
254-
[ERROR] In file included from ./CN0357/CN0357.h:52:0,
255-
from ./main.cpp:48:
256-
./CN0357/AD7790/AD7790.h:114:51: error: 'SPI_CS' was not declared in this scope
257-
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
258-
^~~~~~
259-
./CN0357/AD7790/AD7790.h:114:74: error: 'SPI_MOSI' was not declared in this scope
260-
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
261-
^~~~~~~~
262-
./CN0357/AD7790/AD7790.h:114:99: error: 'SPI_MISO' was not declared in this scope
263-
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
264-
^~~~~~~~
265-
./CN0357/AD7790/AD7790.h:114:123: error: 'SPI_SCK' was not declared in this scope
266-
AD7790( float reference_voltage, PinName CS = SPI_CS, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
267-
^~~~~~~
268-
In file included from ./main.cpp:48:0:
269-
./CN0357/CN0357.h:77:73: error: 'SPI_MOSI' was not declared in this scope
270-
CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
271-
^~~~~~~~
272-
./CN0357/CN0357.h:77:98: error: 'SPI_MISO' was not declared in this scope
273-
CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
274-
^~~~~~~~
275-
./CN0357/CN0357.h:77:122: error: 'SPI_SCK' was not declared in this scope
276-
CN0357(PinName CSAD7790 = D8, PinName CSAD5270 = D6, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
277-
^~~~~~~
278-
./main.cpp: In function 'int main()':
279-
./main.cpp:111:12: error: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 3, which is not yet defined
280-
CN0357 cn0357;
281-
^~~~~~
282-
./main.cpp:111:12: error: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 4, which is not yet defined
283-
./main.cpp:111:12: error: call to 'CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)' uses the default argument for parameter 5, which is not yet defined
284-
285-
[mbed] ERROR: "/usr/local/opt/python/bin/python2.7" returned error code 1.
286-
[mbed] ERROR: Command "/usr/local/opt/python/bin/python2.7 -u /Users/jenplu01/Repos/temp/CN0357-helloworld/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/k64f/gcc_arm" in "/Users/jenplu01/Repos/temp/CN0357-helloworld"
287-
---
288-
```
289-
290-
Notice that the `./CN0357/AD7790/AD7790.h` and `./CN0357/CN0357.h` header files also have similar "was not declared in this scope" errors. You need to remove the constructor's default arguments again in both files.
291-
292-
Line 114 of the `AD7790.h` header file now looks like this:
293-
294-
```
295-
AD7790(float reference_voltage, PinName CS, PinName MOSI, PinName MISO, PinName SCK);
296-
```
297-
298-
Line 77 of the `CN0357.h` header file now looks like this:
299-
300-
```
301-
CN0357(PinName CSAD7790, PinName CSAD5270, PinName MOSI, PinName MISO, PinName SCK);
302-
```
303-
304-
Run `mbed compile` once again. You now have the following errors:
305-
306-
```
307-
Building project CN0357-helloworld (K64F, GCC_ARM)
308-
Scan: .
309-
Scan: mbed
310-
Scan: env
311-
Scan: FEATURE_LWIP
312-
Scan: FEATURE_STORAGE
313-
Compile [ 5.1%]: Ticker.cpp
314-
Compile [ 5.4%]: Timeout.cpp
315-
Compile [ 5.6%]: main.cpp
316-
[Error] main.cpp@111,12: no matching function for call to 'CN0357::CN0357()'
317-
[ERROR] ./main.cpp: In function 'int main()':
318-
./main.cpp:111:12: error: no matching function for call to 'CN0357::CN0357()'
319-
CN0357 cn0357;
320-
^~~~~~
321-
In file included from ./main.cpp:48:0:
322-
./CN0357/CN0357.h:77:5: note: candidate: CN0357::CN0357(PinName, PinName, PinName, PinName, PinName)
323-
CN0357(PinName CSAD7790, PinName CSAD5270, PinName MOSI, PinName MISO, PinName SCK);
324-
^~~~~~
325-
./CN0357/CN0357.h:77:5: note: candidate expects 5 arguments, 0 provided
326-
./CN0357/CN0357.h:58:7: note: candidate: CN0357::CN0357(const CN0357&)
327-
class CN0357
328-
^~~~~~
329-
./CN0357/CN0357.h:58:7: note: candidate expects 1 argument, 0 provided
330-
331-
[mbed] ERROR: "/usr/local/opt/python/bin/python2.7" returned error code 1.
332-
[mbed] ERROR: Command "/usr/local/opt/python/bin/python2.7 -u /Users/jenplu01/Repos/temp/CN0357-helloworld/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/k64f/gcc_arm" in "/Users/jenplu01/Repos/temp/CN0357-helloworld"
333-
---
334-
```
335-
336-
These errors are now due to the CN0357 variable in `main.cpp` no longer having sufficient arguments. Go into `main.cpp`, and modify the initialization of the `CN0357 cn0357;` variable on line 111 to include the K64F's pin names. Line 111 now looks like this:
337-
338-
```
339-
CN0357 cn0357(D8, D6, D11, D12, D13); // CSAD7790, CSAD5270, MOSI, MISO, SCK
340-
```
341-
342-
Now, the program successfully compiles.
343-
344168
### Runtime errors
345169

346170
Although the program or library now compiles successfully, runtime errors may still be present. Please visit the [compile-time errors tutorial](compile-time-errors.html#runtime-errors-and-lights-of-the-dead) for further debugging tips about common errors.

0 commit comments

Comments
 (0)