"编译错误"使用Visual Studio 2015和Visual Micro插件

时间:2016-03-24 22:19:21

标签: arduino freertos

我最近使用Arduino插件安装了MS Visual Studio 2015" Visual Micro"。 一切正常,上传草图等。除非我在使用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);
    }
}

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

  

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

     

编译&#39; FreeRTOS&#39;的调试版本为Arduino / Genuino Uno&#39;   FreeRTOS.ino:timers.h中包含的文件:75:3:错误:#error   &#34;包含Arduino_FreeRTOS.h必须在包含之前出现在源文件中   timers.h中&#34; :#error&#34;包括Arduino_FreeRTOS.h必须出现在源代码中   包含timers.h&#34;之前的文件timers.h:包含在的文件中   FreeRTOS.ino:来自task.h:75:3:错误:#error&#34; include   在包含task.h之前,Arduino_FreeRTOS.h必须出现在源文件中。#34;   :#error&#34;包含Arduino_FreeRTOS.h之前必须出现在源文件中   包括task.h&#34; task.h:在timers.h中包含的文件中:from   FreeRTOS.ino:来自list.h:99:3:错误:#error Arduino_FreeRTOS.h必须   列在list.h之前:#error必须包含Arduino_FreeRTOS.h   在list.h之前FreeRTOS.ino:semphr.h中包含的文件:74:3:错误:

     

错误&#34;包括Arduino_FreeRTOS.h&#34;必须在&#34;包括semphr.h&#34;之前出现在源文件中。 :#error&#34;包括Arduino_FreeRTOS.h&#34;必须出现在

中      

之前的源文件&#34;包括semphr.h&#34; semphr.h:包含在的文件中   FreeRTOS.ino:来自queue.h:75:3:错误:#error&#34; include   Arduino_FreeRTOS.h&#34;必须在&#34; include之前出现在源文件中   queue.h&#34; :#error&#34;包括Arduino_FreeRTOS.h&#34;必须出现在源代码中   &#34;之前的文件包括queue.h&#34; FreeRTOS.ino:包含在文件中   list.h:99:3:错误:#error之前必须包含Arduino_FreeRTOS.h   list.h:#error必须在list.h之前包含Arduino_FreeRTOS.h   task.h:在timers.h中包含的文件中:来自FreeRTOS.ino:from   list.h:184:22:错误:&#39; TickType_t&#39;没有命名类型   :configLIST_VOLATILE TickType_t xItemValue; * LT;价值是   上市。在大多数情况下,这用于按降序对列表进行排序   订购。 * list.h:196:22:错误:&#39; TickType_t&#39;没有命名类型   :configLIST_VOLATILE TickType_t xItemValue list.h:208:22:错误:   &#39; UBaseType_t&#39;没有命名类型:configLIST_VOLATILE UBaseType_t   uxNumberOfItems list.h:386:47:错误:之前的预期初始化程序   &#39; PRIVILEGED_FUNCTION:void vListInitialise(List_t * const pxList)   PRIVILEGED_FUNCTION list.h:397:55:错误:之前的预期初始化程序   &#39; PRIVILEGED_FUNCTION:void vListInitialiseItem(ListItem_t * const   pxItem)PRIVILEGED_FUNCTION list.h:410:77:错误:预期   初始化程序之前&#39; PRIVILEGED_FUNCTION:void vListInsert(List_t *   const pxList,ListItem_t * const pxNewListItem)PRIVILEGED_FUNCTION   list.h:431:80:错误:在&PRIVHEGED_FUNCTION之前的预期初始化程序   :void vListInsertEnd(List_t * const pxList,ListItem_t * const   pxNewListItem)PRIVILEGED_FUNCTION list.h:446:1:错误:&#39; UBaseType_t&#39;   没有命名类型:UBaseType_t uxListRemove(ListItem_t * const   pxItemToRemove)PRIVILEGED_FUNCTION timers.h:包含在的文件中   FreeRTOS.ino:来自task.h:109:20:错误:ISO C ++禁止声明   &#39; BaseType_t&#39;没有类型[-fpermissive]:typedef BaseType_t   (* TaskHookFunction_t)(void *)task.h:109:20:错误:typedef   &#39; BaseType_t&#39;初始化(使用decltype)task.h:109:22:   错误:&#39; TaskHookFunction_t&#39;未在此范围内声明:typedef   BaseType_t(* TaskHookFunction_t)(void *)timers.h:包含在文件中   来自FreeRTOS.ino:来自task.h:136:2:错误:&#39; BaseType_t&#39;没有名字   类型:BaseType_t xOverflowCount task.h:137:2:错误:&#39; TickType_t&#39;   没有命名类型:TickType_t xTimeOnEntering task.h:146:2:错误:   &#39; uint32_t的&#39;没有命名类型:uint32_t ulLengthInBytes   task.h:147:2:错误:&#39; uint32_t&#39;没有命名类型:uint32_t   ulParameters task.h:155:2:错误:&#39; TaskFunction_t&#39;没有命名   类型:TaskFunction_t pvTaskCode task.h:157:2:错误:&#39; uint16_t&#39;不   不要命名类型:uint16_t usStackDepth task.h:159:2:错误:   &#39; UBaseType_t&#39;没有命名类型:UBaseType_t uxPriority   task.h:160:2:错误:&#39; StackType_t&#39;没有命名类型:StackType_t   * puxStackBuffer task.h:161:27:错误:&#39; portNUM_CONFIGURABLE_REGIONS&#39;未在此范围内声明:MemoryRegion_t xRegions [   portNUM_CONFIGURABLE_REGIONS] task.h:170:2:错误:&#39; UBaseType_t&#39;不   不要命名类型:UBaseType_t xTaskNumber; *一个独特的数字   任务。 * task.h:172:2:错误:&#39; UBaseType_t&#39;没有命名类型   :UBaseType_t uxCurrentPriority; *任务的优先级   填充结构时运行(可以继承)。 *   task.h:173:2:错误:&#39; UBaseType_t&#39;没有命名类型:UBaseType_t   uxBasePriority; *如果是,任务将返回的优先级   任务的当前优先级已被继承,以避免无限制的优先级   获取互斥锁时的反转。仅在configUSE_MUTEXES为有效时才有效   在FreeRTOSConfig.h中定义为1。 * timers.h:在文件包含

4 个答案:

答案 0 :(得分:2)

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

包括Arduino_FreeRTOS.h必须首先出现。

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

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

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

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

vTaskDelay()计算Ticks,因此需要除以Tick周期(以毫秒为单位)。即 时间以ms / portTICK_PERIOD_MS = Ticks

答案 1 :(得分: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 :(得分:0)

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

这是正确的顺序:

max(last_updated_dt)

答案 3 :(得分:0)

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