Hi folks,
I’m a newbie to Platformio, with a lot of experience in the Arduino IDE, which isn’t saying much. I’ve been running into this problem with platformio and the Arduino Yun. I run Linux Min 17.3, and all the avr libraries are installed, including libc. The Yun calls functions from Bridge.h, which in the Arduino 1.6.8 install, resides in $HOMEDIR/bin/arduino-1.6.8/libraries. In the Platformio install, in my .platformio directory tree is as follows.
~/.platformio/packages/framework-arduinoavr/libraries $ ls -l
total 104
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Bridge
drwxrwx--- 4 klaks klaks 4096 Apr 28 10:51 __cores__
drwxrwx--- 4 klaks klaks 4096 Apr 28 10:51 EEPROM
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Esplora
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Ethernet
drwxrwx--- 6 klaks klaks 4096 May 19 12:50 Firmata
drwxrwx--- 5 klaks klaks 4096 Apr 28 10:51 GSM
drwxrwx--- 3 klaks klaks 4096 May 19 12:50 HID
drwxrwx--- 3 klaks klaks 4096 May 19 12:50 Keyboard
drwxrwx--- 4 klaks klaks 4096 Apr 28 10:51 LiquidCrystal
drwxrwx--- 3 klaks klaks 4096 May 19 12:50 Mouse
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Robot_Control
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 RobotIRremote
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Robot_Motor
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Scheduler
drwxrwx--- 4 klaks klaks 4096 Apr 28 10:51 SD
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Servo
drwxrwx--- 4 klaks klaks 4096 Apr 28 10:51 SoftwareSerial
drwxrwx--- 3 klaks klaks 4096 May 19 12:50 SpacebrewYun
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 SPI
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Stepper
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Temboo
drwxrwx--- 5 klaks klaks 4096 May 19 12:50 TFT
drwxrwx--- 4 klaks klaks 4096 Apr 28 10:51 USBHost
drwxrwx--- 5 klaks klaks 4096 Apr 28 10:51 WiFi
drwxrwx--- 4 klaks klaks 4096 May 19 12:50 Wire
This is identical to my arduino-1.6.8 install, which is:
~/bin/arduino-1.6.8/libraries $ ls -l
total 72
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Bridge
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Esplora
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Ethernet
drwxr-xr-x 6 klaks klaks 4096 Apr 23 22:29 Firmata
drwxr-xr-x 5 klaks klaks 4096 Apr 23 22:29 GSM
drwxr-xr-x 3 klaks klaks 4096 Apr 23 22:29 Keyboard
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 LiquidCrystal
drwxr-xr-x 3 klaks klaks 4096 Apr 23 22:29 Mouse
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Robot_Control
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 RobotIRremote
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Robot_Motor
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 SD
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Servo
drwxr-xr-x 3 klaks klaks 4096 Apr 23 22:29 SpacebrewYun
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Stepper
drwxr-xr-x 4 klaks klaks 4096 Apr 23 22:29 Temboo
drwxr-xr-x 5 klaks klaks 4096 Apr 23 22:29 TFT
drwxr-xr-x 5 klaks klaks 4096 Apr 23 22:29 WiFi
klaks@helix ~/bin/arduino-1.6.8/libraries $
And is in directory trees in both the Arduino-1.6.8 and the Platformio directory’s reveal the same tree.
Here’s the Arduino 1.6.8 tree
klaks@helix ~/bin/arduino-1.6.8/libraries/Bridge/src $ ls -l
total 96
-rw-r--r-- 1 klaks klaks 3858 Mar 8 11:07 BridgeClient.cpp
-rw-r--r-- 1 klaks klaks 2014 Mar 8 11:07 BridgeClient.h
-rw-r--r-- 1 klaks klaks 7166 Mar 8 11:07 Bridge.cpp
-rw-r--r-- 1 klaks klaks 3791 Mar 8 11:07 Bridge.h
-rw-r--r-- 1 klaks klaks 1632 Mar 8 11:07 BridgeServer.cpp
-rw-r--r-- 1 klaks klaks 1419 Mar 8 11:07 BridgeServer.h
-rw-r--r-- 1 klaks klaks 4532 Mar 8 11:07 BridgeUdp.cpp
-rw-r--r-- 1 klaks klaks 2092 Mar 8 11:07 BridgeUdp.h
-rw-r--r-- 1 klaks klaks 3318 Mar 8 11:07 Console.cpp
-rw-r--r-- 1 klaks klaks 1795 Mar 8 11:07 Console.h
-rw-r--r-- 1 klaks klaks 6189 Mar 8 11:07 FileIO.cpp
-rw-r--r-- 1 klaks klaks 3384 Mar 8 11:07 FileIO.h
-rw-r--r-- 1 klaks klaks 4485 Mar 8 11:07 HttpClient.cpp
-rw-r--r-- 1 klaks klaks 2066 Mar 8 11:07 HttpClient.h
-rw-r--r-- 1 klaks klaks 1838 Mar 8 11:07 Mailbox.cpp
-rw-r--r-- 1 klaks klaks 1705 Mar 8 11:07 Mailbox.h
-rw-r--r-- 1 klaks klaks 3213 Mar 8 11:07 Process.cpp
-rw-r--r-- 1 klaks klaks 1942 Mar 8 11:07 Process.h
-rw-r--r-- 1 klaks klaks 986 Mar 8 11:07 YunClient.h
-rw-r--r-- 1 klaks klaks 986 Mar 8 11:07 YunServer.h
klaks@helix ~/bin/arduino-1.6.8/libraries/Bridge/src $
```
And here's the platformio tree
```
klaks@helix ~/.platformio/packages/framework-arduinoavr/libraries/Bridge/src $ ls -l
total 96
-rwxrwx--- 1 klaks klaks 3858 Mar 8 10:07 BridgeClient.cpp
-rwxrwx--- 1 klaks klaks 2014 Mar 8 10:07 BridgeClient.h
-rwxrwx--- 1 klaks klaks 7166 Mar 8 10:07 Bridge.cpp
-rwxrwx--- 2 klaks klaks 3791 Mar 8 10:07 Bridge.h
-rwxrwx--- 1 klaks klaks 1632 Mar 8 10:07 BridgeServer.cpp
-rwxrwx--- 1 klaks klaks 1419 Mar 8 10:07 BridgeServer.h
-rwxrwx--- 1 klaks klaks 4532 Mar 8 10:07 BridgeUdp.cpp
-rwxrwx--- 1 klaks klaks 2092 Mar 8 10:07 BridgeUdp.h
-rwxrwx--- 1 klaks klaks 3318 Mar 8 10:07 Console.cpp
-rwxrwx--- 2 klaks klaks 1795 Mar 8 10:07 Console.h
-rwxrwx--- 1 klaks klaks 6189 Mar 8 10:07 FileIO.cpp
-rwxrwx--- 1 klaks klaks 3384 Mar 8 10:07 FileIO.h
-rwxrwx--- 1 klaks klaks 4485 Mar 8 10:07 HttpClient.cpp
-rwxrwx--- 1 klaks klaks 2066 Mar 8 10:07 HttpClient.h
-rwxrwx--- 1 klaks klaks 1838 Mar 8 10:07 Mailbox.cpp
-rwxrwx--- 1 klaks klaks 1705 Mar 8 10:07 Mailbox.h
-rwxrwx--- 1 klaks klaks 3213 Mar 8 10:07 Process.cpp
-rwxrwx--- 2 klaks klaks 1942 Mar 8 10:07 Process.h
-rwxrwx--- 1 klaks klaks 986 Mar 8 10:07 YunClient.h
-rwxrwx--- 1 klaks klaks 986 Mar 8 10:07 YunServer.h
klaks@helix ~/.platformio/packages/framework-arduinoavr/libraries/Bridge/src $
```
You can see Bridge.h is in both directories which are searched under the Arduino IDE. When I run this program for the Yun, which calls for Bridge.h:
```cpp
/* The console program allows the user to see that their keyboard inputs and screen outputs
* when in ssh mode lights up digital LED pin 13
* To make this work, first in the arduino IDE, select Tools --> Port --> Arduino Yun
* Then, in a terminal, type in 'ssh root@yourYunsName.local 'telnet localhost 6571'
* Hit enter
* It should come with the printout "You're connected to the Console!!!!"
* In the void loop section, if the incoming byte is H, it'll light up pin 13, and if it's
* L it'll turn off pin 13
*/
#include <Arduino.h>
/* Seems that platformio requires this library which I think comes from
* arduino1.6.8/hardware/arduino/avr/cores/arduino in the Arduino director
* and on the platformio install directory, .platformio/packages/framework-arduinoavr/cores/arduino
* indicating that both the ArduinoIDE and the platformio program are able to access
* their cores/arduino directories
*/
/* Console.h is required to begin serial communications.
* Bridge is required to talk across the Yun's microcontroller and the embedded linux system on the yun
* Both files are located in the Arduino IDE in arduino1.6.8/libraries/Bridge, and in the platformio system,
* in .platformio/packages/framework-arduinoavr/libraries/Bridge
* So far, it's not getting compiled and linked in the platformio system
*/
#include <Console.h>
#include <Bridge.h>
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Bridge.begin();
Console.begin();
while (!Console){
; // wait for Console port to connect.
}
Console.println("You're connected to the Console!!!!");
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Console.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Console.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
delay(100);
}
```
Which has this platformio.ini file,
```ini
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.
# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload
[env:yun]
platform = atmelavr
framework = arduino
board = yun
```
I get this.
```
klaks@helix ~/Programming/AVR/Arduino/Yun/YunConsole $ ls -l
total 12
drwxr-xr-x 2 klaks klaks 4096 May 20 11:23 lib
-rw-r--r-- 1 klaks klaks 490 May 20 11:33 platformio.ini
drwxr-xr-x 2 klaks klaks 4096 May 20 11:31 src
klaks@helix ~/Programming/AVR/Arduino/Yun/YunConsole $ pio run
[Fri May 20 11:35:05 2016] Processing yun (platform: atmelavr, board: yun, framework: arduino)
------------------------------------------------------------------------------------------------------------------------------
avr-gcc -o .pioenvs/yun/src/main.o -c -std=gnu11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN -DUSB_VID=0x2341 -DUSB_PID=0x0041 "-DUSB_PRODUCT=\"Arduino Yun\"" -DUSB_MANUFACTURER=\"Arduino\" -DARDUINO=10608 -DPLATFORMIO=020901 -I.pioenvs/yun/FrameworkArduino -I.pioenvs/yun/FrameworkArduinoVariant -I.pioenvs/yun/Bridge src/main.c
avr-ar rcs .pioenvs/yun/libFrameworkArduinoVariant.a
avr-ranlib .pioenvs/yun/libFrameworkArduinoVariant.a
avr-g++ -o .pioenvs/yun/FrameworkArduino/CDC.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN -DUSB_VID=0x2341 -DUSB_PID=0x0041 "-DUSB_PRODUCT=\"Arduino Yun\"" -DUSB_MANUFACTURER=\"Arduino\" -DARDUINO=10608 -I.pioenvs/yun/FrameworkArduino -I.pioenvs/yun/FrameworkArduinoVariant .pioenvs/yun/FrameworkArduino/CDC.cpp
avr-g++ -o .pioenvs/yun/FrameworkArduino/HardwareSerial.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN -DUSB_VID=0x2341 -DUSB_PID=0x0041 "-DUSB_PRODUCT=\"Arduino Yun\"" -DUSB_MANUFACTURER=\"Arduino\" -DARDUINO=10608 -I.pioenvs/yun/FrameworkArduino -I.pioenvs/yun/FrameworkArduinoVariant .pioenvs/yun/FrameworkArduino/HardwareSerial.cpp
avr-g++ -o .pioenvs/yun/FrameworkArduino/HardwareSerial0.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO_AVR_YUN -DUSB_VID=0x2341 -DUSB_PID=0x0041 "-DUSB_PRODUCT=\"Arduino Yun\"" -DUSB_MANUFACTURER=\"Arduino\" -DARDUINO=10608 -I.pioenvs/yun/FrameworkArduino -I.pioenvs/yun/FrameworkArduinoVariant .pioenvs/yun/FrameworkArduino/HardwareSerial0.cpp
In file included from .pioenvs/yun/FrameworkArduino/Print.h:27:0,
from .pioenvs/yun/FrameworkArduino/Stream.h:26,
from .pioenvs/yun/Bridge/Bridge.h:27,
from .pioenvs/yun/Bridge/Console.h:22,
from src/main.c:27:
.pioenvs/yun/FrameworkArduino/Printable.h:25:1: error: unknown type name 'class'
class Print;
^
.pioenvs/yun/FrameworkArduino/Printable.h:33:1: error: unknown type name 'class'
class Printable
^
.pioenvs/yun/FrameworkArduino/Printable.h:34:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from .pioenvs/yun/FrameworkArduino/Stream.h:26:0,
from .pioenvs/yun/Bridge/Bridge.h:27,
from .pioenvs/yun/Bridge/Console.h:22,
from src/main.c:27:
.pioenvs/yun/FrameworkArduino/Print.h:34:1: error: unknown type name 'class'
class Print
^
.pioenvs/yun/FrameworkArduino/Print.h:35:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
In file included from .pioenvs/yun/Bridge/Bridge.h:27:0,
from .pioenvs/yun/Bridge/Console.h:22,
from src/main.c:27:
.pioenvs/yun/FrameworkArduino/Stream.h:49:1: error: unknown type name 'class'
class Stream : public Print
^
.pioenvs/yun/FrameworkArduino/Stream.h:49:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
class Stream : public Print
^
In file included from .pioenvs/yun/Bridge/Console.h:22:0,
from src/main.c:27:
.pioenvs/yun/Bridge/Bridge.h:29:1: error: unknown type name 'class'
class BridgeClass {
^
.pioenvs/yun/Bridge/Bridge.h:29:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
class BridgeClass {
^
.pioenvs/yun/Bridge/Bridge.h:96:1: error: unknown type name 'class'
class SerialBridgeClass : public BridgeClass {
^
.pioenvs/yun/Bridge/Bridge.h:96:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
class SerialBridgeClass : public BridgeClass {
^
.pioenvs/yun/Bridge/Bridge.h:112:1: error: unknown type name 'SerialBridgeClass'
extern SerialBridgeClass Bridge;
^
.pioenvs/yun/Bridge/Bridge.h:120:52: error: expected ';', ',' or ')' before '=' token
extern void checkForRemoteSketchUpdate(uint8_t pin = 7);
^
In file included from .pioenvs/yun/Bridge/Bridge.h:125:0,
from .pioenvs/yun/Bridge/Console.h:22,
from src/main.c:27:
.pioenvs/yun/Bridge/Process.h:24:1: error: unknown type name 'class'
class Process : public Stream {
^
.pioenvs/yun/Bridge/Process.h:24:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
class Process : public Stream {
^
In file included from src/main.c:27:0:
.pioenvs/yun/Bridge/Console.h:24:1: error: unknown type name 'class'
class ConsoleClass : public Stream {
^
.pioenvs/yun/Bridge/Console.h:24:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
class ConsoleClass : public Stream {
^
.pioenvs/yun/Bridge/Console.h:69:1: error: unknown type name 'ConsoleClass'
extern ConsoleClass Console;
^
src/main.c: In function 'setup':
src/main.c:35:9: error: request for member 'begin' in something not a structure or union
Bridge.begin();
^
src/main.c:36:10: error: request for member 'begin' in something not a structure or union
Console.begin();
^
src/main.c:41:10: error: request for member 'println' in something not a structure or union
Console.println("You're connected to the Console!!!!");
^
src/main.c: In function 'loop':
src/main.c:48:14: error: request for member 'available' in something not a structure or union
if (Console.available() > 0) {
^
src/main.c:50:27: error: request for member 'read' in something not a structure or union
incomingByte = Console.read();
^
scons: *** [.pioenvs/yun/src/main.o] Error 1
================================================ [ ERROR ] Took 2.43 seconds ================================================
klaks@helix ~/Programming/AVR/Arduino/Yun/YunConsole $
```
It compiles fine on the ArduinoIDE. Is there a way to get platformio to access the libraries via the platformio.ini file, or from what I've read so far, is this a bug that's stlll being worked on? I would think that since those libraries are installed with the standard Arduino package, it should also be seen in the platformio package as well. That said, I have run into a few situations on the ArduinoIDE where a few programs also couldn't see Bridge.h or Console.h, and as a hack, I had to copy those library files into the same project directory. I'm not a fan of that hack. This is not consistent, and in the case of this program, it compiles just fine on the Arduino IDE.
I also have a ton of ~/sketchbook/libraries, which I'm really keen on using, but I can't seem to include in platformio. And a lot of them are not listed in the platformio library manager, and I do need to use them.
Please advise.