i want to upload a Script to read out a Lightsensor i have bought. The Sensor is a Grove - Sunlightsensor and the libary for it can be found on GitHub.
The Board i am going to use is a WeMos D1 Mini using a ESP8266, but since many Pins are taken i want to use GPIO2 as SDA and 13 as SCL which can be achieved with: Wire.begin(2,13);
But the Pins are not relavant for compiling.
I want to try the example-script found in the libary from the producer:
#include "Si115X.h"
Si115X si1151;
/**
* Setup for configuration
*/
void setup()
{
uint8_t conf[4];
Wire.begin(2,13);
Serial.begin(115200);
if (!si1151.Begin())
Serial.println("Si1151 is not ready!");
else
Serial.println("Si1151 is ready!");
}
/**
* Loops and reads data from registers
*/
void loop()
{
Serial.print("IR: ");
Serial.println(si1151.ReadHalfWord());
Serial.print("VISIBLE: ");
Serial.println(si1151.ReadHalfWord_VISIBLE());
Serial.print("UV: ");
Serial.println(si1151.ReadHalfWord_UV());
delay(100);
}
But i get the following error massage:
c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.cpp: In member function 'int Si115X::read_register(uint8_t, uint8_t, int)':
c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.cpp:42:39: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
42 | Wire.requestFrom(addr, bytesOfData);
| ^
In file included from c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.h:5,
from c:\Users\nikol\Documents\Mechatronik_Projekte\Arduino_Sketches\libraries\Grove_Sunlight_Sensor-Si1151\Si115X.cpp:2:
C:\Users\nikol\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.1\libraries\Wire/Wire.h:73:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int)'
73 | uint8_t requestFrom(int, int);
| ^~~~~~~~~~~
C:\Users\nikol\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.1\libraries\Wire/Wire.h:71:13: note: candidate 2: 'uint8_t TwoWire::requestFrom(uint8_t, uint8_t)'
71 | uint8_t requestFrom(uint8_t, uint8_t);
| ^~~~~~~~~~~
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o: in function `setup':
C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:18: undefined reference to `_ZN6Si115X12ReadHalfWordEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:18: undefined reference to `_ZN6Si115X20ReadHalfWord_VISIBLEEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o:(.text.loop+0x14): undefined reference to `_ZN6Si115X15ReadHalfWord_UVEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o:(.text.loop+0x3a): undefined reference to `_ZN6Si115X12ReadHalfWordEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\arduino-sketch-5BFDDB9EDB939386E5CB1A13D5CC3F69\sketch\Si1151.ino.cpp.o: in function `loop':
C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:27: undefined reference to `_ZN6Si115X20ReadHalfWord_VISIBLEEv'
c:/users/nikol/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\nikol\AppData\Local\Temp\.arduinoIDE-unsaved2023112-24360-28iud3.owxco\Si1151/Si1151.ino:28: undefined reference to `_ZN6Si115X15ReadHalfWord_UVEv'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
I already tried using a different compilerversion (2.7.4) but the same error accured.
I might be wrong and not expirienced but the error output seems that something is messed up in the libary itselfe?
Thanks for any help. If further information is needed i am happy to give it to you.
Related
I currently trying to setup an Async Web Server on the ESP32. But unfortunately I don't get the code to run. I'm usign platform io on windows 10.
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "myAP";
const char* password = "123456789";
AsyncWebServer server(80);
setup() and loop() are empty.
If I try to compile the code these message shows up.
compilation terminated.
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In constructor 'AsyncPrinter::AsyncPrinter(AsyncClient*, size_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:48:11: error: 'panic' was not declared in this scope
panic(); //What should we do?
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In member function 'int AsyncPrinter::connect(IPAddress, uint16_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:71:11: error: 'panic' was not declared in this scope
panic();
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In member function 'size_t AsyncPrinter::_sendBuffer()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:182:11: error: 'panic' was not declared in this scope
panic(); // Connection should be aborted instead
^
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCPbuffer.cpp: In member function 'size_t AsyncTCPbuffer::_handleRxBuffer(uint8_t*, size_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCPbuffer.cpp:469:21: error: 'panic' was not declared in this scope
panic(); //TODO: What action should this be ?
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'bool AsyncClient::operator==(const AsyncClient&)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:331:66: error: 'ip_addr_t {aka struct ip_addr}' has no membec
r named 'addr'
return (_pcb != NULL && other._pcb != NULL && (_pcb->remote_ip.addr == other._pcb->remote_ip.addr) && (_pcb->remote_port == other._pcb->remote_port));
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'void AsyncClient::_dns_found(const ip_addr*)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:707:31: error: 'const struct ip_addr' has no member named 'addr'
connect(IPAddress(ipaddr->addr), _connect_port);
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getRemoteAddress()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:837:26: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
return _pcb->remote_ip.addr;
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getLocalAddress()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:849:25: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
return _pcb->local_ip.addr;
^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'void AsyncServer::begin()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:1122:14: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
local_addr.addr = (uint32_t) _addr;
^
You're using the wrong async TCP library. The one you're using is for the ESP8266, not the ESP32.
Here's its PlatformIO library registry entry:
https://platformio.org/lib/show/305/ESPAsyncTCP
You're seeing errors because it's trying to call functions that are available on the ESP8266 and not the ESP32.
You want the AsyncTCP library:
https://platformio.org/lib/show/1826/AsyncTCP
You should update your platformio.lib file to include this library instead of ESPAsyncTCP. You may also need to remove the build or library directory to get rid of the old library.
had the same issue, downgrading the core of PlatformIO solved for me the issue.
pip install -U "platformio<4.2.0"
In the C file in simplesample_mqtt.c, which connects Arduino to the Azure IoT hub, I need to use the IRsend and IrRemoteESP8266 libraries to send an infrared signal with Azure IoT hub.
#include <IRremoteESP8266.h>
#include <IRsend.h>
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
I don't have any problem when I use this code in my main Ardunio file. But when I use these includes in a C file (implesample_mqtt.c), I get this error from line 3: "unknown type name 'IRsend'".
error full info :
Arduino: 1.8.2 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"
In file included from sketch\simplesample_mqtt.c:29:0:
C:\Program Files (x86)\Arduino\libraries\IRremoteESP8266\src/IRsend.h:29:1: error: unknown type name 'class'
class IRsend {
C:\Program Files (x86)\Arduino\libraries\IRremoteESP8266\src/IRsend.h:29:14: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
class IRsend {
simplesample_mqtt.c:31: error: unknown type name 'IRsend'
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
simplesample_mqtt.c:31: error: expected declaration specifiers or '...' before numeric constant
IRsend irsend(10); // An IR LED is controlled by GPIO pin 4 (D2)
exit status 1
unknown type name 'IRsend'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I solved this problem. The reason for this is because main ardunio is c++ and simplesample_mqtt.c is c code and we have to use c++ code in c code :
i main ardunio file you have to declare function like this :
extern "C" void TurnOn();
void TurnOn()
{
digitalWrite(RELAY_SONOFF, HIGH);
digitalWrite(LED_SONOFF, HIGH);
}
and use this function in c code :
void TurnOn();
EXECUTE_COMMAND_RESULT TurnOn(ContosoAnemometer* device)
{
(void)device;
TurnOn();
(void)printf("Turning fan on.\r\n");
return EXECUTE_COMMAND_SUCCESS;
}
I have installed the ESP8266 SDK and toolchain and try to build the project CDataCollectionDemo which is generated from kaa sandbox. And I get the error like this
/opt/Espressif/esp-rtos-sdk/include/espressif/c_types.h:47:29: error: conflicting types for ‘size_t’
typedef unsigned int size_t;
^
In file included from /opt/Espressif/esp-rtos-sdk/extra_include/string.h:14:0,
from /home/tung/kaa/project/CDataCollectionDemo/targets/esp8266/target.
here is the full output
tung#ubuntu:~/kaa/project/CDataCollectionDemo$ sudo ./build.sh deploy
-- The C compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
==================================
BUILD_TYPE = (Default)
KAA_PLATFORM = posix
KAA_MAX_LOG_LEVEL = 3
==================================
BOOTSTRAP ENABLED
PROFILE ENABLED
USER EXTENSION ENABLED
CONFIGURATION ENABLED
EVENTS ENABLED
LOGGING ENABLED
NOTIFICATION ENABLED
ENCRYPTION ENABLED
KAA WILL BE INSTALLED TO /usr/local
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Could NOT find cppcheck
-- WiFi AP: WiFi SSID
-- WiFi Pass:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tung/kaa/project/CDataCollectionDemo/build
Scanning dependencies of target target_support
[ 1%] Building C object targets/esp8266/CMakeFiles/target_support.dir/target.c.o
In file included from /opt/Espressif/esp-rtos-sdk/extra_include/sys/config.h:4:0,
from /opt/Espressif/esp-rtos-sdk/extra_include/_ansi.h:16,
from /opt/Espressif/esp-rtos-sdk/extra_include/string.h:10,
from /home/tung/kaa/project/CDataCollectionDemo/targets/esp8266/target.c:17:
/opt/Espressif/esp-rtos-sdk/extra_include/machine/ieeefp.h:277:2: error: #error Endianess not declared!!
#error Endianess not declared!!
^
In file included from /opt/Espressif/esp-rtos-sdk/include/espressif/esp_common.h:9:0,
from /opt/Espressif/esp-rtos-sdk/include/freertos/portmacro.h:73,
from /opt/Espressif/esp-rtos-sdk/include/freertos/portable.h:318,
from /opt/Espressif/esp-rtos-sdk/include/freertos/FreeRTOS.h:87,
from /home/tung/kaa/project/CDataCollectionDemo/targets/esp8266/target.c:19:
/opt/Espressif/esp-rtos-sdk/include/espressif/c_types.h:47:29: error: conflicting types for ‘size_t’
typedef unsigned int size_t;
^
In file included from /opt/Espressif/esp-rtos-sdk/extra_include/string.h:14:0,
from /home/tung/kaa/project/CDataCollectionDemo/targets/esp8266/target.c:17:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:212:23: note: previous declaration of ‘size_t’ was here
typedef __SIZE_TYPE__ size_t;
^
In file included from /opt/Espressif/esp-rtos-sdk/include/espressif/esp_common.h:10:0,
from /opt/Espressif/esp-rtos-sdk/include/freertos/portmacro.h:73,
from /opt/Espressif/esp-rtos-sdk/include/freertos/portable.h:318,
from /opt/Espressif/esp-rtos-sdk/include/freertos/FreeRTOS.h:87,
from /home/tung/kaa/project/CDataCollectionDemo/targets/esp8266/target.c:19:
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:10:7: error: conflicting types for ‘strncpy’
char *strncpy(char *dst, const char *src, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:12:5: error: conflicting types for ‘strncmp’
int strncmp(const char *s1, const char *s2, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:13:8: error: conflicting types for ‘strlen’
size_t strlen(const char *s);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:16:7: error: conflicting types for ‘strncat’
char *strncat(char *dst, const char *src, size_t count);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:17:8: error: conflicting types for ‘strspn’
size_t strspn(const char *s, const char *accept);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:18:8: error: conflicting types for ‘strcspn’
size_t strcspn(const char *s, const char *reject);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:26:6: error: conflicting types for ‘bzero’
void bzero(void *s, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:28:7: error: conflicting types for ‘memcpy’
void *memcpy(void *dst, const void *src, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:29:7: error: conflicting types for ‘memset’
void *memset(void *dst, int c, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:30:5: error: conflicting types for ‘memcmp’
int memcmp(const void *m1, const void *m2, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:31:7: error: conflicting types for ‘memmove’
void *memmove(void *dst, const void *src, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:37:5: warning: conflicting types for built-in function ‘snprintf’ [enabled by default]
int snprintf(char *buf, unsigned int count, const char *format, ...);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:41:7: warning: conflicting types for built-in function ‘malloc’ [enabled by default]
void *malloc(size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:43:7: warning: conflicting types for built-in function ‘calloc’ [enabled by default]
void *calloc(size_t c, size_t n);
^
/opt/Espressif/esp-rtos-sdk/include/espressif/esp_libc.h:45:7: warning: conflicting types for built-in function ‘realloc’ [enabled by default]
void *realloc(void *p, size_t n);
^
make[2]: *** [targets/esp8266/CMakeFiles/target_support.dir/target.c.o] Error 1
make[1]: *** [targets/esp8266/CMakeFiles/target_support.dir/all] Error 2
make: *** [all] Error 2
./build.sh: 52: ./build.sh: ./demo_client: not found
Everything I did follow the kaa documentation, except adding the -DKAA_PLATFORM=esp8266 argument to cmake command in build.sh file. Can you tell me what's problem here and how to fix it. Thank you!
Update
I have added some arguments to cmake command as #MrKoin suggested but still get an error
Cmake arguments
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../libs/kaa/toolchains/esp8266.cmake \
-DKAA_PLATFORM=esp8266 \
-DCMAKE_BUILD_TYPE=MinSizeRel \
Output
In file included from /home/tung/kaa/project/CDataCollectionDemo/libs/kaa/thirdparty/mbedtls/aes.c:27:0:
/opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^
compilation terminated.
make[2]: *** [libs/kaa/tools/kaa_encryption/rsa_key_gen/mbedtls/CMakeFiles/mbedtls.dir/aes.c.obj] Error 1
make[1]: *** [libs/kaa/tools/kaa_encryption/rsa_key_gen/mbedtls/CMakeFiles/mbedtls.dir/all] Error 2
make: *** [all] Error 2
It seems like some libraries missing. What should I do now? Thanks!
Looks like you need to specify cmake toolchain file in cmake arguments:
cmake -DCMAKE_TOOLCHAIN_FILE=../libs/kaa/toolchains/esp8266.cmake \
-DKAA_PLATFORM=esp8266 ..
Please, refer documentation for details.
It might be related to step 5 Install ESP8266 RTOS SDK in the tutorial you referenced from the Kaa website.
Did you run the command sed -i 's:#include "c_types.h"://#include "c_types.h":' $ESP_SDK_HOME/include/lwip/arch/cc.h?
I remember I had a similar (or the same) problem and forgot to execute this command. It comments out an #include which conflicts with the declaration of types elsewhere.
You need to edit the build.sh file,
find build() and change the code:
build() {
mkdir -p "$PROJECT_HOME/build"
cd "$PROJECT_HOME/build"
cmake ..\
-DKAA_TARGET=esp8266\
-DCMAKE_TOOLCHAIN_FILE=../libs/kaa/toolchains/esp8266.cmake \
-DBUILD_TESTING=OFF \
-DKAA_PLATFORM=esp8266 \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=MinSizeRel
make
}
I have recently installed MS Visual Studio 2015 with the Arduino plugin "Visual Micro".
Everything works fine, upload a sketch etc. Except when I try to compile my code when I use FreeRTOS. I downloaded the FreeRTOS libary through the Arduino IDE (library manager). Therefore(in MS VS 2015) I could chose to include the library in MS VS 2015. So I included the library in one of my sketches. Below you see my code example. Within the Arduino IDE i can compile the code and upload it to the device, but in MS VS there are some errors.
#include <timers.h>
#include <task.h>
#include <StackMacros.h>
#include <semphr.h>
#include <queue.h>
#include <projdefs.h>
#include <portmacro.h>
#include <portable.h>
#include <mpu_wrappers.h>
#include <list.h>
#include <FreeRTOSVariant.h>
#include <FreeRTOSConfig.h>
#include <event_groups.h>
#include <croutine.h>
#include <Arduino_FreeRTOS.h>
//define Tasks
void TaskBlinkSlow(void *pvParameters);
void TaskBlinkFast(void *pvParameters);
void setup()
{
/* add setup code here */
xTaskCreate(TaskBlinkSlow, "TaskSlow", 128, NULL, 1, NULL);
xTaskCreate(TaskBlinkFast, "TaskFast", 128, NULL, 2, NULL);
pinMode(13, OUTPUT);
}
void loop()
{
//Empty, things are done in tasks!!!
}
void TaskBlinkSlow(void * pvParameters)
{
for (;;) {
for (int i = 0; i < 8; i++) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
void TaskBlinkFast(void * pvParameters)
{
for (;;) {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
}
At the end of this post you will find the short snippet of the compilers error log. Maybe someone already came around the same issue and has a quick fix.
An example debugger breakpoint has been created. To switch the demo
breakpoint off, deselect Visual Micro>Tutorial Mode.
Compiling debug version of 'FreeRTOS' for 'Arduino/Genuino Uno'
FreeRTOS.ino:In file included from timers.h:75:3: error: #error
"include Arduino_FreeRTOS.h must appear in source files before include
timers.h" :#error "include Arduino_FreeRTOS.h must appear in source
files before include timers.h" timers.h:In file included from
FreeRTOS.ino:from task.h:75:3: error: #error "include
Arduino_FreeRTOS.h must appear in source files before include task.h"
:#error "include Arduino_FreeRTOS.h must appear in source files before
include task.h" task.h:In file included from timers.h:from
FreeRTOS.ino:from list.h:99:3: error: #error Arduino_FreeRTOS.h must
be included before list.h :#error Arduino_FreeRTOS.h must be included
before list.h FreeRTOS.ino:In file included from semphr.h:74:3: error:
error "include Arduino_FreeRTOS.h" must appear in source files before "include semphr.h" :#error "include Arduino_FreeRTOS.h" must appear in
source files before "include semphr.h" semphr.h:In file included from
FreeRTOS.ino:from queue.h:75:3: error: #error "include
Arduino_FreeRTOS.h" must appear in source files before "include
queue.h" :#error "include Arduino_FreeRTOS.h" must appear in source
files before "include queue.h" FreeRTOS.ino:In file included from
list.h:99:3: error: #error Arduino_FreeRTOS.h must be included before
list.h :#error Arduino_FreeRTOS.h must be included before list.h
task.h:In file included from timers.h:from FreeRTOS.ino:from
list.h:184:22: error: 'TickType_t' does not name a type
:configLIST_VOLATILE TickType_t xItemValue; *< The value being
listed. In most cases this is used to sort the list in descending
order. * list.h:196:22: error: 'TickType_t' does not name a type
:configLIST_VOLATILE TickType_t xItemValue list.h:208:22: error:
'UBaseType_t' does not name a type :configLIST_VOLATILE UBaseType_t
uxNumberOfItems list.h:386:47: error: expected initializer before
'PRIVILEGED_FUNCTION :void vListInitialise( List_t * const pxList )
PRIVILEGED_FUNCTION list.h:397:55: error: expected initializer before
'PRIVILEGED_FUNCTION :void vListInitialiseItem( ListItem_t * const
pxItem ) PRIVILEGED_FUNCTION list.h:410:77: error: expected
initializer before 'PRIVILEGED_FUNCTION :void vListInsert( List_t *
const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION
list.h:431:80: error: expected initializer before 'PRIVILEGED_FUNCTION
:void vListInsertEnd( List_t * const pxList, ListItem_t * const
pxNewListItem ) PRIVILEGED_FUNCTION list.h:446:1: error: 'UBaseType_t'
does not name a type :UBaseType_t uxListRemove( ListItem_t * const
pxItemToRemove ) PRIVILEGED_FUNCTION timers.h:In file included from
FreeRTOS.ino:from task.h:109:20: error: ISO C++ forbids declaration of
'BaseType_t' with no type [-fpermissive] :typedef BaseType_t
(*TaskHookFunction_t)( void * ) task.h:109:20: error: typedef
'BaseType_t' is initialized (use decltype instead) task.h:109:22:
error: 'TaskHookFunction_t' was not declared in this scope :typedef
BaseType_t (*TaskHookFunction_t)( void * ) timers.h:In file included
from FreeRTOS.ino:from task.h:136:2: error: 'BaseType_t' does not name
a type :BaseType_t xOverflowCount task.h:137:2: error: 'TickType_t'
does not name a type :TickType_t xTimeOnEntering task.h:146:2: error:
'uint32_t' does not name a type :uint32_t ulLengthInBytes
task.h:147:2: error: 'uint32_t' does not name a type :uint32_t
ulParameters task.h:155:2: error: 'TaskFunction_t' does not name a
type :TaskFunction_t pvTaskCode task.h:157:2: error: 'uint16_t' does
not name a type :uint16_t usStackDepth task.h:159:2: error:
'UBaseType_t' does not name a type :UBaseType_t uxPriority
task.h:160:2: error: 'StackType_t' does not name a type :StackType_t
*puxStackBuffer task.h:161:27: error: 'portNUM_CONFIGURABLE_REGIONS' was not declared in this scope :MemoryRegion_t xRegions[
portNUM_CONFIGURABLE_REGIONS ] task.h:170:2: error: 'UBaseType_t' does
not name a type :UBaseType_t xTaskNumber; * A number unique to the
task. * task.h:172:2: error: 'UBaseType_t' does not name a type
:UBaseType_t uxCurrentPriority; * The priority at which the task was
running (may be inherited) when the structure was populated. *
task.h:173:2: error: 'UBaseType_t' does not name a type :UBaseType_t
uxBasePriority; * The priority to which the task will return if the
task's current priority has been inherited to avoid unbounded priority
inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is
defined as 1 in FreeRTOSConfig.h. * timers.h:In file include
If you read the error messages, the issue is explained clearly.
include Arduino_FreeRTOS.h must appear first.
Your example shows it included last.
Put it first and the errors will go away.
Arduino_FreeRTOS.h includes many definitions that are used in other places, hence the need for it to be first.
Unrelated to your question, but using delay() is nasty as it consumes CPU cycles needlessly. Try vTaskDelay() as alternative which defers (or blocks) to the Scheduler to unblock other Tasks or run the idle Task which is the Arduino loop() function.
The loop() function can then put the CPU to sleep, reducing power consumption. See the feilipu.me post on topic for more.
vTaskDelay() counts Ticks, so hence the need to divide by the Tick period in milliseconds. i.e.
Time in ms / portTICK_PERIOD_MS = Ticks
#include <Arduino_FreeRTOS.h>
#include <croutine.h>
#include <event_groups.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSVariant.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <portmacro.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <Stack_Macros.h>
#include <task.h>
#include <timers.h>
void setup()
{
}
void loop()
{
}
Found the issue, the includes where in the wrong order: dont know why;).
You cant only include freeRTOS in MS VS you need to correct the order of the includes by yourself.
Here is the correct order:
#include <Arduino_FreeRTOS.h>
#include <croutine.h>
#include <event_groups.h>
#include <FreeRTOSConfig.h>
#include <FreeRTOSVariant.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <portmacro.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <StackMacros.h>
#include <task.h>
#include <timers.h>
I'm not sure about the Arduino code you are referring to, but normally there is no reason to include FreeRTOSConfig.h directly - instead include FreeRTOS.h first, and that will get the ordering of the port layer files and FreeRTOSConfig.h files correct for you, then include the header files that contain the API functions you want to use.
Im programming an Arduino mega 2560.
And I bought an tft LCD and for that I want to use a SD card so I can put my pictures on it.
I downloaded this library but its giving me errors.
C:\Arduino\libraries\pff\pff.cpp: In function 'FRESULT pf_read(void*, short unsigned int, short unsigned int*)':
C:\Arduino\libraries\pff\pff.cpp:585: error: invalid conversion from 'void*' to 'unsigned char*'
The problem is imo here:
pff.cpp:
FRESULT pf_read (
void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/
WORD btr, /* Number of bytes to read */
WORD* br /* Pointer to number of bytes read */
)
pff.h:
FRESULT pf_read (void*, WORD, WORD*); /* Read data from the open file */
When I make it a .c file, it gives me more errors, like this one:
tft_menu.cpp.o: In function `open_root_dir()':
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:594: undefined reference to `pf_opendir(_DIR_*, char const*)'
tft_menu.cpp.o: In function `mount_sd()':
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:583: undefined reference to `disk_initialize()'
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:585: undefined reference to `pf_mount(_FATFS_*)'
tft_menu.cpp.o: In function `bitmap_show(char*)':
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:472: undefined reference to `pf_open(char const*)'
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:476: undefined reference to `pf_read(void*, unsigned short, unsigned short*)'
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:518: undefined reference to `pf_read(void*, unsigned short, unsigned short*)'
tft_menu.cpp.o: In function `show_bitmap()':
C:\AppData\Local\Temp\build7310099894910129341.tmp/tft_menu.cpp:603: undefined reference to `pf_readdir(_DIR_*, _FILINFO_*)'
so I think it should be compiled as a cpp.
EDIT:
I found out that I have to save is as cpp and in the program I have to write what icktoofay states
After that I got some errors, so I went to the line 585, as stated above and changed
BYTE *rbuff = buff;
into
BYTE rbuff = (unsigned char) buff;
And I found out that I had to add mcc.h to get rid of the errors of the "couldnt find resources".
And now Im getting these errors:
C:\libraries\mmc/mmc.h: In function 'void init_spi()':
C:\libraries\mmc/mmc.h:21: error: 'PORTL' was not declared in this scope
C:\libraries\mmc/mmc.h:21: error: 'PORTL0' was not declared in this scope
C:\libraries\mmc/mmc.h:22: error: 'PORTB' was not declared in this scope
C:\libraries\mmc/mmc.h:22: error: 'PORTB2' was not declared in this scope
C:\libraries\mmc/mmc.h:22: error: 'PORTB1' was not declared in this scope
C:\libraries\mmc/mmc.h:23: error: 'DDRB' was not declared in this scope
C:\libraries\mmc/mmc.h:23: error: 'PORTB0' was not declared in this scope
C:\libraries\mmc/mmc.h:25: error: 'DDRL' was not declared in this scope
C:\libraries\mmc/mmc.h:27: error: 'SPCR' was not declared in this scope
C:\libraries\mmc/mmc.h:27: error: 'SPE' was not declared in this scope
C:\libraries\mmc/mmc.h:27: error: 'MSTR' was not declared in this scope
C:\libraries\mmc/mmc.h:28: error: 'SPSR' was not declared in this scope
C:\libraries\mmc/mmc.h:28: error: 'SPI2X' was not declared in this scope
Ive tried to add #include TFT_ARDUINO_MEGA.h on top of the mcc.h and still no luck
Compile it as a C file, but in the file that uses it, include pff.h like this:
extern "C" {
#include <pff.h>
}