Title: xCreateTaskStatic error: was not declared in this scope · feilipu/Arduino_FreeRTOS_Library · Discussion #127 · GitHub
Open Graph Title: xCreateTaskStatic error: was not declared in this scope · feilipu/Arduino_FreeRTOS_Library · Discussion #127
X Title: xCreateTaskStatic error: was not declared in this scope · feilipu/Arduino_FreeRTOS_Library · Discussion #127
Description: xCreateTaskStatic error: was not declared in this scope
Open Graph Description: I am having the mentioned error message: src/main.cpp: In function 'void setup()': src/main.cpp:55:22: error: 'xTaskCreateStatic' was not declared in this scope xTaskHandleBlink = xTaskCreateStatic...
X Description: I am having the mentioned error message: src/main.cpp: In function 'void setup()': src/main.cpp:55:22: error: 'xTaskCreateStatic' was not declared in this scope xTaskHandleBlink = x...
Opengraph URL: https://github.com/feilipu/Arduino_FreeRTOS_Library/discussions/127
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"xCreateTaskStatic error: was not declared in this scope","text":"\u003cp dir=\"auto\"\u003eI am having the mentioned error message:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"src/main.cpp: In function 'void setup()':\nsrc/main.cpp:55:22: error: 'xTaskCreateStatic' was not declared in this scope\n xTaskHandleBlink = xTaskCreateStatic(task_blink, \u0026quot;Blink\u0026quot;, STACK_DEPTH_BLINK, NULL, PRIORITY_BLINK,xStackSizeBlink, \u0026amp;xTCBBlink);\n ^~~~~~~~~~~~~~~~~\nsrc/main.cpp:55:22: note: suggested alternative: 'xTaskCreate'\n xTaskHandleBlink = xTaskCreateStatic(task_blink, \u0026quot;Blink\u0026quot;, STACK_DEPTH_BLINK, NULL, PRIORITY_BLINK,xStackSizeBlink, \u0026amp;xTCBBlink);\n ^~~~~~~~~~~~~~~~~\n xTaskCreate\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode class=\"notranslate\"\u003esrc/main.cpp: In function 'void setup()':\nsrc/main.cpp:55:22: error: 'xTaskCreateStatic' was not declared in this scope\n xTaskHandleBlink = xTaskCreateStatic(task_blink, \"Blink\", STACK_DEPTH_BLINK, NULL, PRIORITY_BLINK,xStackSizeBlink, \u0026amp;xTCBBlink);\n ^~~~~~~~~~~~~~~~~\nsrc/main.cpp:55:22: note: suggested alternative: 'xTaskCreate'\n xTaskHandleBlink = xTaskCreateStatic(task_blink, \"Blink\", STACK_DEPTH_BLINK, NULL, PRIORITY_BLINK,xStackSizeBlink, \u0026amp;xTCBBlink);\n ^~~~~~~~~~~~~~~~~\n xTaskCreate\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf I adjust the code for using \u003ccode class=\"notranslate\"\u003exCreateTask\u003c/code\u003e, then everything works.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eAn excerpt of my code is as follows:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"#include \u0026quot;Arduino.h\u0026quot;\n#include \u0026quot;HardwareSerial.h\u0026quot;\n#include \u0026lt;Arduino_FreeRTOS.h\u0026gt;\n#include \u0026quot;FreeRTOSConfig.h\u0026quot;\n\n// Task: Blink\nvoid task_blink(void *pVParameters);\n// TCB is the part of memory that keeps the task state\nstatic StaticTask_t xTCBBlink;\nstatic StackType_t xStackSizeBlink[128];\n\n// Task: AnalogRead\nvoid task_analog_read(void *pVParameters);\nstatic StaticTask_t xTCBAnalogRead;\nstatic StackType_t xStackSizeAnalogRead[128];\n\n// Aux functions\nvoid set_pid_gains(float * /*Kp*/, float * /*Ki*/, float * /*Kd*/);\nvoid get_serial_message(union Message * /*message*/);\n\n// the setup function runs once when you press reset or power the board\nvoid setup() {\n\n // initialize serial communication at 9600 bits per second:\n const unsigned int BAUDRATE = 9600;\n Serial.begin(BAUDRATE);\n\n while (!Serial) {\n ; // wait for serial port to connect. Needed for native USB, on LEONARDO,\n // MICRO, YUN, and other 32u4 based boards.\n }\n\n // Now set up two tasks to run independently.\n // Blink\n const int STACK_DEPTH_BLINK = 128;\n const int PRIORITY_BLINK = 2; \n TaskHandle_t xTaskHandleBlink = NULL;\n xTaskHandleBlink = xTaskCreateStatic(task_blink, \u0026quot;Blink\u0026quot;, STACK_DEPTH_BLINK, NULL, PRIORITY_BLINK,xStackSizeBlink, \u0026amp;xTCBBlink);\n\n // AnalogRead\n const int STACK_DEPTH_ANALOG_READ = 128;\n const int PRIORITY_ANALOG_READ = 2; \n TaskHandle_t xTaskHandleAnalogRead = NULL;\n xTaskHandleAnalogRead = xTaskCreateStatic(task_analog_read, \u0026quot;AnalogRead\u0026quot;, STACK_DEPTH_ANALOG_READ, NULL,\n PRIORITY_ANALOG_READ,xStackSizeAnalogRead, \u0026amp;xTCBAnalogRead);\n}\n\nvoid loop() {}\n\n// Tasks and functions implementation follows\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode class=\"notranslate\"\u003e#include \"Arduino.h\"\n#include \"HardwareSerial.h\"\n#include \u0026lt;Arduino_FreeRTOS.h\u0026gt;\n#include \"FreeRTOSConfig.h\"\n\n// Task: Blink\nvoid task_blink(void *pVParameters);\n// TCB is the part of memory that keeps the task state\nstatic StaticTask_t xTCBBlink;\nstatic StackType_t xStackSizeBlink[128];\n\n// Task: AnalogRead\nvoid task_analog_read(void *pVParameters);\nstatic StaticTask_t xTCBAnalogRead;\nstatic StackType_t xStackSizeAnalogRead[128];\n\n// Aux functions\nvoid set_pid_gains(float * /*Kp*/, float * /*Ki*/, float * /*Kd*/);\nvoid get_serial_message(union Message * /*message*/);\n\n// the setup function runs once when you press reset or power the board\nvoid setup() {\n\n // initialize serial communication at 9600 bits per second:\n const unsigned int BAUDRATE = 9600;\n Serial.begin(BAUDRATE);\n\n while (!Serial) {\n ; // wait for serial port to connect. Needed for native USB, on LEONARDO,\n // MICRO, YUN, and other 32u4 based boards.\n }\n\n // Now set up two tasks to run independently.\n // Blink\n const int STACK_DEPTH_BLINK = 128;\n const int PRIORITY_BLINK = 2; \n TaskHandle_t xTaskHandleBlink = NULL;\n xTaskHandleBlink = xTaskCreateStatic(task_blink, \"Blink\", STACK_DEPTH_BLINK, NULL, PRIORITY_BLINK,xStackSizeBlink, \u0026amp;xTCBBlink);\n\n // AnalogRead\n const int STACK_DEPTH_ANALOG_READ = 128;\n const int PRIORITY_ANALOG_READ = 2; \n TaskHandle_t xTaskHandleAnalogRead = NULL;\n xTaskHandleAnalogRead = xTaskCreateStatic(task_analog_read, \"AnalogRead\", STACK_DEPTH_ANALOG_READ, NULL,\n PRIORITY_ANALOG_READ,xStackSizeAnalogRead, \u0026amp;xTCBAnalogRead);\n}\n\nvoid loop() {}\n\n// Tasks and functions implementation follows\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eand my FreeRTOSConfig.h is the following:\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"#define configSUPPORT_STATIC_ALLOCATION 1\n#define configSUPPORT_DYNAMIC_ALLOCATION 0\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode class=\"notranslate\"\u003e#define configSUPPORT_STATIC_ALLOCATION 1\n#define configSUPPORT_DYNAMIC_ALLOCATION 0\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eI have my \u003ccode class=\"notranslate\"\u003emain.cpp\u003c/code\u003e in \u003ccode class=\"notranslate\"\u003e./src\u003c/code\u003e and the \u003ccode class=\"notranslate\"\u003eFreeRTOSConfig.h\u003c/code\u003e in \u003ccode class=\"notranslate\"\u003e./include\u003c/code\u003e.\u003cbr\u003e\nIt would be nice to have some examples that use \u003ccode class=\"notranslate\"\u003e*Static\u003c/code\u003e features. :)\u003c/p\u003e","upvoteCount":1,"answerCount":4,"acceptedAnswer":{"@type":"Answer","text":"\u003cblockquote\u003e\n\u003cblockquote\u003e\n\u003cp dir=\"auto\"\u003eYes, but not quite the answer I was going to suggest.\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003c/blockquote\u003e\n\u003cblockquote\u003e\n\u003cp dir=\"auto\"\u003eAh OK! What would that be your answer then?\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp dir=\"auto\"\u003eThe \u003ccode class=\"notranslate\"\u003eFreeRTOSConfig.h\u003c/code\u003e file is found in the \u003ca href=\"https://github.com/feilipu/Arduino_FreeRTOS_Library/blob/master/src/FreeRTOSConfig.h\"\u003elibrary source directory\u003c/a\u003e and, as the Arduino IDE compiles its libraries first and your sketch last, that library configuration file is used (and others are not).\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp dir=\"auto\"\u003eDefault \u003cstrong\u003eArduino\u003c/strong\u003e FreeRTOS has dynamic memory allocation to be as more general as possible to cover more boards and to prevent too much hassle for the user.\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp dir=\"auto\"\u003eYes. The assumption for Arduino is that the user is an artist or hobbyist or tinkerer or student who just wants to get something done, without necessarily knowing the details. Hence the original \u003ccode class=\"notranslate\"\u003esetup()\u003c/code\u003e and \u003ccode class=\"notranslate\"\u003eloop()\u003c/code\u003e functions being all you needed to get things going. IMHO, more recently people use Arduino for more professional uses, perhaps at their own risk. As this library covers multiple hardware options, I used the memory management based on the \u003ccode class=\"notranslate\"\u003eavrlibc\u003c/code\u003e \u003ca href=\"https://github.com/feilipu/Arduino_FreeRTOS_Library/blob/master/src/heap_3.c#L63\"\u003e\u003ccode class=\"notranslate\"\u003emalloc()\u003c/code\u003e\u003c/a\u003e function.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp dir=\"auto\"\u003eBut once a board is fixed it could be a good idea to use *Static - even if the heap management seems very good in freertos?\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp dir=\"auto\"\u003eYes, the best idea is to use static allocation of memory wherever possible. FreeRTOS has \u003ca href=\"https://www.freertos.org/a00111.html\" rel=\"nofollow\"\u003egreat heap management and monitoring options\u003c/a\u003e based off static memory. \u003ccode class=\"notranslate\"\u003eheap1.c\u003c/code\u003e allows allocation, but can't free memory. \u003ccode class=\"notranslate\"\u003eheap2.c\u003c/code\u003e allows reallocation, but can't coalesce memory freed (fragmentation). \u003ccode class=\"notranslate\"\u003eheap4.c\u003c/code\u003ehelps to avoid fragmentation if you application needs to allocate and free memory often.\u003c/p\u003e","upvoteCount":1,"url":"https://github.com/feilipu/Arduino_FreeRTOS_Library/discussions/127#discussioncomment-8020171"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:3fc48940-6e6f-7c4a-f210-0875bb68d3ab |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | AD1C:17973D:F25E61:14A728B:6A61A928 |
| html-safe-nonce | 1a894b163668279752e70aabbdfd3c466cc8ba3344eada74ee773c3048f01f50 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDFDOjE3OTczRDpGMjVFNjE6MTRBNzI4Qjo2QTYxQTkyOCIsInZpc2l0b3JfaWQiOiI3OTg4MzE0OTUzODUzNTQ0NzQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8db6d21558af5f6e37cd35c2365b712efa1df74d236fad27501b427dca3cbc1f |
| hovercard-subject-tag | discussion:6029776 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/feilipu/Arduino_FreeRTOS_Library/127/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/8fc5090a13f3eba9fe1e70272a7aa99b15752b584ead4f1b52c039dc2c7fd817/feilipu/Arduino_FreeRTOS_Library/discussions/127 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8fc5090a13f3eba9fe1e70272a7aa99b15752b584ead4f1b52c039dc2c7fd817/feilipu/Arduino_FreeRTOS_Library/discussions/127 |
| og:image:alt | I am having the mentioned error message: src/main.cpp: In function 'void setup()': src/main.cpp:55:22: error: 'xTaskCreateStatic' was not declared in this scope xTaskHandleBlink = xTaskCreateStatic... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6f4633bcf01c1ad14b73fd07dd39ac31d61f3d3c2578ee08ec1792b7b351eeb9 |
| turbo-cache-control | no-preview |
| go-import | github.com/feilipu/Arduino_FreeRTOS_Library git https://github.com/feilipu/Arduino_FreeRTOS_Library.git |
| octolytics-dimension-user_id | 3955592 |
| octolytics-dimension-user_login | feilipu |
| octolytics-dimension-repository_id | 46898167 |
| octolytics-dimension-repository_nwo | feilipu/Arduino_FreeRTOS_Library |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 46898167 |
| octolytics-dimension-repository_network_root_nwo | feilipu/Arduino_FreeRTOS_Library |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ac296ae7f21856f1f92adbad22f870b6fbb4b907 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width