Hello, I have problem with libraries. I can't get work the Serial work. The same I get when I try another library.
Code :
void setup(void)
{
// start serial port
Serial.begin(9600);
}
void loop(void)
{
}
pioenvs/arduino_pro5v/src/main.c: In function 'setup':
.pioenvs/arduino_pro5v/src/main.c:6:3: error: 'Serial' undeclared (first use in this function)
Serial.begin(9600);
^
.pioenvs/arduino_pro5v/src/main.c:6:3: note: each undeclared identifier is reported only once for each function it appears in
scons: *** [.pioenvs/arduino_pro5v/src/main.o] Error 1
Or if I install OneWire lib and only include it to empty project I get this.
CODE :
void setup(void)
{
// start serial port
//Serial.begin(9600);
}
void loop(void)
{
}
Error:
ystrem@ystrem-PC:~/test$ platformio run
Processing arduino_pro5v environment:
avr-gcc -o .pioenvs/arduino_pro5v/src/main.o -c -g -Os -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=158 -DARDUINO_AVR_PRO -I.pioenvs/arduino_pro5v/FrameworkArduino -I.pioenvs/arduino_pro5v/FrameworkArduinoVariant -I.pioenvs/arduino_pro5v/OneWire_ID1 .pioenvs/arduino_pro5v/src/main.c
/usr/local/lib/python2.7/dist-packages/pkg_resources.py:2425: RuntimeWarning: 'xdiagnose (3.6.3build2)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
RuntimeWarning,
/usr/local/lib/python2.7/dist-packages/pkg_resources.py:2425: RuntimeWarning: 'python-debian (0.1.21-nmu2ubuntu2)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
RuntimeWarning,
In file included from .pioenvs/arduino_pro5v/src/main.c:2:0:
.pioenvs/arduino_pro5v/OneWire_ID1/OneWire.h:112:1: error: unknown type name 'class'
class OneWire
^
.pioenvs/arduino_pro5v/OneWire_ID1/OneWire.h:113:1: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
{
^
scons: *** [.pioenvs/arduino_pro5v/src/main.o] Error 1
Hello,
Which is extension of your file? main.c or main.ino?
main.c, you should include arduino header file:#include <Arduino.h>
main.ino, then PlatformIO will automatically include arduino header files.It help to change from main.c > main.cpp or main.ino. Now is working. Is possible to upload code by usbasp ? If I set proper env upload_port ?
It help to change from main.c > main.cpp or main.ino. Now is working.
Thanks for reporting :+1:
Is possible to upload code by usbasp ? If I set proper env upload_port ?
I hope, that you can upload it. Can you test it and report me? Thanks a lot!
It's not possible.
Stop stop... Why not?
usbasp protocol?platformio.ini?Try:
[env:some_env]
platform = atmelavr
framework = arduino
upload_protocol = usbasp
I tried it and it looks good.
``` [env:pro8MHzatmega328]
platform = atmelavr
framework = arduino
upload_protocol = usbasp -B5
board = pro8MHzatmega328
avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e950f
avrdude: reading input file ".pioenvs/pro8MHzatmega328/firmware.hex"
avrdude: writing flash (1068 bytes):
avrdude: 1068 bytes of flash written
avrdude: safemode: Fuses OK (H:05, E:DA, L:E2)
avrdude done. Thank you.
```
@ystrem thanks a lot for your platformio.ini and report. I've just added it to platformio.ini examples (number 5).
Have a nice weekend! :+1:
Most helpful comment
Hello,
Which is extension of your file?
main.cormain.ino?main.c, you should includearduinoheader file:main.ino, then PlatformIO will automatically includearduinoheader files.