【问题标题】:"compiling error" FreeRTOS Arduino Library with Visual Studio 2015 and Visual Micro plugin“编译错误”带有 Visual Studio 2015 和 Visual Micro 插件的 FreeRTOS Arduino 库
【发布时间】:2016-07-12 16:19:20
【问题描述】:

我最近安装了带有 Arduino 插件“Visual Micro”的 MS Visual Studio 2015。 一切正常,上传草图等。除非我在使用 FreeRTOS 时尝试编译我的代码。我通过 Arduino IDE(库管理器)下载了 FreeRTOS 库。因此(在 MS VS 2015 中)我可以选择将库包含在 MS VS 2015 中。所以我将库包含在我的一个草图中。下面你会看到我的代码示例。在 Arduino IDE 中我可以编译代码并将其上传到设备,但在 MS VS 中会出现一些错误。

#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);
    }
}

在这篇文章的最后,您会找到编译器错误日志的简短 sn-p。也许有人已经解决了同样的问题并快速解决了问题。

已创建示例调试器断点。切换演示 断点关闭,取消选择 Visual Micro>Tutorial Mode。

为“Arduino/Genuino Uno”编译“FreeRTOS”调试版本 FreeRTOS.ino:在 timers.h:75:3 中包含的文件中:错误:#error “包含 Arduino_FreeRTOS.h 必须在包含之前出现在源文件中 timers.h" :#error "include Arduino_FreeRTOS.h 必须出现在源代码中 包含 timers.h 之前的文件” timers.h:在包含的文件中 FreeRTOS.ino:from task.h:75:3: 错误: #error "include Arduino_FreeRTOS.h 必须在包含 task.h 之前出现在源文件中” :#error "include Arduino_FreeRTOS.h 必须出现在源文件中之前 包括 task.h" task.h:在包含在 timers.h:from 的文件中 FreeRTOS.ino:from list.h:99:3: error: #error Arduino_FreeRTOS.h 必须 在 list.h 之前包含:#error Arduino_FreeRTOS.h 必须包含在内 在 list.h FreeRTOS.ino 之前:在 semphr.h:74:3 中包含的文件中:错误:

错误“include Arduino_FreeRTOS.h”必须出现在“include semphr.h”之前的源文件中:#error“include Arduino_FreeRTOS.h”必须出现在

"include semphr.h" semphr.h 之前的源文件:在包含的文件中 FreeRTOS.ino:from queue.h:75:3: error: #error "include Arduino_FreeRTOS.h" 必须出现在源文件中的 "include queue.h" :#error "include Arduino_FreeRTOS.h" 必须出现在源代码中 “include queue.h” FreeRTOS.ino 之前的文件:在包含的文件中 list.h:99:3: error: #error Arduino_FreeRTOS.h 必须包含在之前 list.h :#error Arduino_FreeRTOS.h 必须包含在 list.h 之前 task.h:在 timers.h 中包含的文件中:来自 FreeRTOS.ino:来自 list.h:184:22:错误:“TickType_t”没有命名类型 :configLIST_VOLATILE TickType_t xItemValue; *

【问题讨论】:

  • 我可以建议您将飞利浦的答案标记为解决方案吗?或者你的,我猜,如果你觉得那更清楚?

标签: arduino freertos


【解决方案1】:
#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() 
{

}

【讨论】:

  • 虽然您的代码可能会为问题提供解决方案,但请说明这是如何解决问题的,而不仅仅是放置代码。
【解决方案2】:

我不确定您所指的 Arduino 代码,但通常没有理由直接包含 FreeRTOSConfig.h - 而是首先包含 FreeRTOS.h,这将获得端口层文件和 FreeRTOSConfig 的排序.h 文件为您正确,然后包含包含您要使用的 API 函数的头文件。

【讨论】:

  • 在 Arduino IDE 中,在库的 src 目录中找到的所有 .h 文件在包含时都会添加到草图中。这有点乱。唯一的强制性包含是 Arduino_FreeRTOS.h。只有在使用这些功能时才需要其他包含。
【解决方案3】:

如果您阅读了错误消息,就会清楚地解释问题。

必须首先包含 Arduino_FreeRTOS.h。

您的示例显示它包含在最后。 把它放在第一位,错误就会消失。

Arduino_FreeRTOS.h 包含许多在其他地方使用的定义,因此需要将其放在首位。

与您的问题无关,但使用 delay() 很讨厌,因为它不必要地消耗 CPU 周期。尝试使用 vTaskDelay() 作为替代方案,它推迟(或阻止)调度程序以解除阻止其他任务或运行空闲任务,即 Arduino loop() 函数。

loop() 函数可以让 CPU 进入睡眠状态,从而降低功耗。有关更多信息,请参阅 feilipu.me 帖子。

vTaskDelay() 计算 Ticks,因此需要除以 Tick 周期(以毫秒为单位)。 IE。 以毫秒为单位的时间/portTICK_PERIOD_MS = 滴答声

【讨论】:

    【解决方案4】:

    发现问题,包括错误的顺序:不知道为什么;)。 您不能只在 MS VS 中包含 freeRTOS,您需要自己更正包含的顺序。

    这是正确的顺序:

    #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>
    

    【讨论】:

      猜你喜欢
      • 2016-08-30
      • 1970-01-01
      • 2020-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-25
      相关资源
      最近更新 更多