heliosproj / helios Goto Github PK
View Code? Open in Web Editor NEWA community delivered, open source embedded operating system project.
Home Page: http://www.heliosproj.org
License: GNU General Public License v2.0
A community delivered, open source embedded operating system project.
Home Page: http://www.heliosproj.org
License: GNU General Public License v2.0
Sorry, I dind't went through all the code lines, but I have a question regarding coop scheduling.
In:
if (task->state == TaskStateRunning && task->totalRuntime < leastRuntime) {
leastRuntime = task->totalRuntime;
runningTask = task;
you are searching for the task with the least runtime.
In:
if (runningTask) {
taskStartTime = NOW();
(*runningTask->callback)(runningTask->id);
runningTask->lastRuntime = NOW() - taskStartTime;
runningTask->totalRuntime += runningTask->lastRuntime;
}
you write the totalRuntime runningTask->totalRuntime += runningTask->lastRuntime;.
What happens, if the totalRuntime has an overflow?
And all other coop tasks are just before an overflow.
Then this task has the least runtime and will always selected in
if (task->state == TaskStateRunning && task->totalRuntime < leastRuntime) {
leastRuntime = task->totalRuntime;
runningTask = task;
}
Is that correct? I haven't found a correction in the code for that issue.
Hi, are you planning on supporting Teensyduino / Teensy 4.x boards? What is blocking support, currently?
This architecture is currently unsupported by HeliOS.
Would be nice if we can include it multiple times without breaking stuff :)
In order to do so
#pragma once
should be inserted at top of Helios_Arduino.h :)
I'm trying to compile the notification example given in the documentation but am getting the error: "exit status 1 using typedef-name 'xTaskGetInfoResult' after 'struct'". My code is below but all looks correct, can anyone tell me where I'm going wrong? Compiling for an Arduino Nano with IDE 1.8.15.
#include <HeliOS_Arduino.h>
//Our first task checks the state of the mp3 player
void taskA(int id_) {
/*
Obtain the task id of task "B" using its friendly name
since it should not be assumed that task "B" will always
have a task id of 2.
Then check the status of the MP3 player
pass a 4-byte notification containing the player state to the playAudio task
*/
xTaskNotify(xTaskGetId("TASKB"), 4, "test");
} //end player state function
/*
Create the second task "B"
*/
void taskB(int id_) {
/*
Obtain the notification bytes and value from the xTaskGetInfoResult
structure by first making a call to the xTaskGetInfo() function call
using the task's id stored in id_.
*/
struct xTaskGetInfoResult* res = xTaskGetInfo(id_);
/* Because xTaskInfo() can return a null pointer, always check
that the structure's pointer is not null before accessing
its members.
*/
if (res) {
/*
res->notificationBytes contains the notification bytes
res->notificationValue contains the notification value
*/
}
/* Always call xMemFree() to free the managed memory allocated by
xTaskGetInfo();
*/
xMemFree(res);
}
void setup() {
/*
xHeliOSSetup() must be the first function call
made to initialize HeliOS and its data structures
*/
xHeliOSSetup();
/*
Declare and initialize an int to temporarily hold the
task id.
*/
int id = 0;
/*
Pass the task friendly name and function to xTaskAdd()
to add the task to HeliOS. xTaskAdd() will return a
task id greater than zero if the task is added unsuccessfully.
*/
id = xTaskAdd("TASKA", &taskA);
/*
Pass the task id of the task to set its state from stopped
to running.
*/
xTaskSart(id);
/*
Pass the task friendly name and function to xTaskAdd()
to add the task to HeliOS. xTaskAdd() will return a
task id greater than zero if the task is added unsuccessfully.
*/
id = xTaskAdd("TASKB", &taskB);
/*
Pass the task id of the task to set its state from stopped
to waiting.
*/
xTaskWait(id);
}
void loop() {
/*
Pass control to the the HeliOS scheduler. xHeliOSLoop() should
be the only code inside the microcontroller project's
main loop.
*/
xHeliOSLoop();
}
Hi guys:
I am trying to make a canbus thermocouple module with HeliOS ; the working flow as follow:
step1: power up and run init scripts for init
step2: create two task 1)get temperature 2)write canbus data and send out
wait for 750ms and make sure MAX6675 get the correct temperature data ,IN the meanwhile canbus data will NOT send out
step3: Task1:get temperature will run every 750ms and write the data in a float struct .And then notify task2 to send data out
I tested example-- WaitNotify.ino ,it work well . so I write my pgm base on WaitNotify.ino,here is source files
The main issue is xTaskNotifyTake(task_) can not attached ,not working
Task1 send out notifications :
void taskThermo_Get(xTask task_, xTaskParm parm_)
{
/* Get the task handle for the task that will receive the
direct-to-task notification. */
xTask WriteCANBUSTask = xTaskGetHandleByName("WRITECANBUS");
temperature_data.BT_AvgTemp=30.12;
temperature_data.ET_CurTemp=28.66;
Serial.print("task thermo_get");
Serial.print(" ") ;
Serial.print(temperature_data.BT_AvgTemp);
Serial.print(" ") ;
Serial.print(temperature_data.ET_CurTemp);
Serial.println(" ");
if (WriteCANBUSTask){
//Serial.println("geted task_writecanbus handler");
/* Send the direct-to-task notification of "HELLO"
which is five bytes. */
Serial.println("task WriteCANBUSTask send noti "); --------> it's work
xTaskNotifyGive(WriteCANBUSTask,2, "OK");
}
}
task2 :Receiver notifications
void taskCanbus_Write(xTask task_, xTaskParm parm_)
{
String notif_str = "";
Serial.print("before notif_str");
Serial.println(notif_str);
xTaskNotification notif = xTaskNotifyTake(task_); ------>here ,not working .
notif_str = notif->notificationValue;------>here ,not working .
Serial.print("after notif_str");
Serial.println(notif_str);------->print out nothing...which is suppose is 'OK'
if ( notif ){. -------> here is not working neither
notif_str = notif->notificationValue;-------> here is not working neither
Serial.println(notif_str);-------> here is not working neither
xMemFree(notif);-------> here is not working neither
}
The rest of codes is the same as example ino file but the task name....
create task as below:
xTask GetThermoTask = xTaskCreate("GET_THERMO", taskThermo_Get,NULL);
xTask WriteCANBUSTask = xTaskCreate("WRITECANBUS", taskCanbus_Write, NULL);
and then set task in waiting mode :
xTaskWait(GetThermoTask);
xTaskWait(WriteCANBUSTask);
and set sending notify task in running mode which loop in 1s.
xTaskChangePeriod(GetThermoTask, 1000); //1000ms
Thank you for you guys answering!!!
Best wishes!!!
Hi!
I had a question: is it possible to pass parameters to a task you're creating?
So for example have two buttons but with a single task definition?
void taskButton(xTaskId id_, const uint8_t port)
which then is called with something like:
int p = 1; id = xTaskAdd("TASKSW1", &taskSW, p)
Hi guys:
I am learning how to use Queue of HeliOS , my code is not working ,I am not sure my codes is correct.Please do me a favor to explain how to use the function Queue in HeliOS .Thanks
here is my code :
main.cpp.zip
I create tasks, task1 and task2 are just sending message to queue ,and taskprint will read the message
and print it out . It's very simple .
Question 1 :So should I suppose to create a xQueue Queue1 = xQueueCreate(8) ?
Question2: How can I get the handler of Queue in Task?
void Task1(xTask task_, xTaskParm parm_) {
char userID="1";
xQueue Queue1; -------> for Queue1 handler Am I correct ? if I omit this line ,compiler will error : Queue1 is not declared.
if (xQueueIsQueueFull(Queue1) == false ){
xQueueSend(Queue1,
1,
"1" );
Serial.println("TASK1 sended");
} else {
Serial.println("QueueMsg is full");
}
}
Thanks you again!!!!
Best wishes!!!
I'm trying to compile a HeliOS program for Arduino Nano RP2040 Connect (RP2040 processor from Raspberry Pi Pico), it says:
"This architecture is currently unsupported by HeliOS. If building for Linux or Microsoft Windows, make sure to un-comment OTHER_ARCH_LINUX or OTHER_ARCH_WINDOWS in HeliOS.h."
#error "This architecture is currently unsupported by HeliOS. If building for Linux or Microsoft Windows, make sure to un-comment OTHER_ARCH_LINUX or OTHER_ARCH_WINDOWS in HeliOS.h."
Could you please add support for this architecture?
Thanks!
Hi guys:
i am trying to compile the following code in vscode+platfromIO :
code.zip
Not success, here is the output
PLATFORM: Espressif 8266 (4.1.0) > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
Hi!
I loaded the example code in the arduino ide for blink and it didn't do anything.
I then loaded the basic example code for blink and it worked without problems.
I didn't change anything in the example - should i have?
I am using an arduino nano and i know HeliOS is about the limit for it, might that be a problem?
I have no experience with OS on microcontrollers and previously did everything "by hand".
I think that could be a problem:
If you have for example 15 timer tasks.
Ten of them runs every 10ms for example and five of them runs every 200ms. That five are at the end of the task list.
It could be that this five tasks will never run, because the scheduler always make a TaskListRewind(), start from the front of the list and limit the waitingTask[waiting] to 8.
Because of that limit and the reset of the list it could be, that the scheduler will never reach the 200ms tasks because the 10ms task want alway to run.
Hi Guys :
I am learning how to make a multi-tasks project with HeliOS 0.3.3 ,I make the code as following:
heliOS_learning.zip
which is base on HeliOS example "Coop" .I am trying to run 3 tasks in this program
1:blink the LED (base on example "Blink")
2: two task-nobody (just delay(XXX) and print a letter out to serial port
Here is the task function:
void taskShort_main(xTask task_, xTaskParm parm_) {
int ledState = DEREF_TASKPARM(int, parm_);
Serial.print("led 1 ");Serial.println(ledState);
if (ledState) {
digitalWrite(LED_BUILTIN, HIGH);
Serial.print("led 2 ");Serial.println(ledState);
ledState = 0;
Serial.print("led 3 ");Serial.println(ledState);
} else {
digitalWrite(LED_BUILTIN, LOW);
ledState = 1;
Serial.print("led 4 ");Serial.println(ledState);
}
DEREF_TASKPARM(int, parm_) = ledState;
Serial.print("led 5 ");Serial.println(ledState);
return;
}
And serial print out :
08:38:03.355 -> L
08:38:03.966 -> M
08:38:03.966 -> led 1 0 timeloop1 in-value =0 ,init value ,OK
08:38:03.966 -> led 4 1 timeloop1 change ledstate ,working good
08:38:03.966 -> led 5 1
08:38:04.342 -> L
08:38:04.953 -> M
08:38:05.375 -> L
08:38:05.375 -> led 1 0 timeloop2 in-value =0?,suppose to be 1 ,working not OK now
08:38:05.375 -> led 4 1 timeloop2
08:38:05.375 -> led 5 1
The var Ledstate do changed in Task "taskShort_main" and pass-thought out to DEREF_TASKPARM(int, parm_) (LED 1 in-value = 0 , LED4 out-value = 1 ),but in the next task Schedule Led1 read in value still is 0 ,suppose to be LED1 = 1 .
so , I make the same coding in example "Blink" , as following :
And serial print out :
08:46:44.589 -> led 1 0 timeloop1 in-value =0 ,init value ,OK
08:46:44.589 -> led 4 1 timeloop1 change ledstate ,working good
08:46:45.625 -> led 1 1 timeloop2 in-value =1 ,from lastloop led4 out-value ,working good
08:46:45.625 -> led 2 1 timeloop2
08:46:45.625 -> led 3 0 timeloop2 change ledstata, output value .
08:46:46.602 -> led 1 0
08:46:46.602 -> led 4 1
08:46:47.653 -> led 1 1
08:46:47.653 -> led 2 1
08:46:47.653 -> led 3 0
the coding is work....
I have tried Arduino Nano , LGT8F328P Nano , both "blink" program running OK , "Coop+Blink" not OK ,
I also tried D1 mini ,but seems HeliOS 0.3.3 not working good . I can not locate where is "ARDUINO_ARCH_ESP8266" in HeliOS.h.
I am not sure which parts is not OK now ......
Would you Please help me to check it out !!!!
Thanks all guys and best wishes !!!
The time value in HeliOS is defined as unsigned long, which most likely will be 32 Bit on typical embedded platforms.
With a time resolution of one microsecond it will "wrap around" (start over from zero...) after ~4295 seconds which is not much longer than one hour. To have a practical use of HeliOS the effects of timer overflow have to be mitigated. Not sure if this is handled in the code , I quick review shows this line in HeliOS.c:
if (NOW() - waitingTask[i]->timerStartTime > waitingTask[i]->timerInterval)
This will at least work also in overflow case, because all values are unsigned. But I'm not sure if all other cases handle wrap around well. At least users should be warned in the documentation that it will happen quite frequently.
Another possibility would be to ensure that the time values are 64 Bits, but this may be very expensive on 8 Bit AVRs (not even sure if avr-gcc supports 64 Bit integers...).
A general question is if relying on standard C "unsigned long" is an issue with portability, because "long" can be theoretically anything. Most portable software systems either define either their own integer types (like "u32", "u64") or include stdint.h
At least you should define a type for such a very critical value like time (e.g. "t_helios_time") with the possibility to adapt it for different ports.
This would also allow e.g. to run HeliOS in x86_64 Linux userland (where long is 64 Bits) but still emulate the behavior of a 32 Bit MCU platform.
Default size of the OS's heap block (array static Byte_t heap[HEAP_RAW_SIZE]
in mem.c
) is IMHO a way too big for most usage scenarios. With the default values of CONFIG_HEAP_SIZE_IN_BLOCKS
= 512 and CONFIG_HEAP_BLOCK_SIZE
= 32 it takes 16 kB of RAM memory which is ridiculous number for most popular AVR-based Arduino boards like Uno, Mini, Micro, Leonardo with around 2 kB of SRAM. Even Arduino Mega has only 8 kB. For the ESP8266 boards, like Wemos D1 and clones, it eats half of RAM.
My proposal is to move these configs into defines.h
section with architecture specific options. Then for example ARDUINO_ARCH_AVR
should set defaults to no more than 128 B, current value of 16 kB may be usable only on architectures like ARDUINO_ARCH_SAM
, ARDUINO_ARCH_SAMD
, ESP32
ond other bigger ones with RAM counted in hundreds of kB or more.
HeliOS source files conflict with Arduino files under Windows because filenames are the same. Under Linux they are not the same (capital S versus lowercase s). This leads to a lot of errors in compiling under Windows.
Same result in Windows as in Linux.
The latest 0.4.1.
OS [Windows, macOS, Linux]: Windows
OS Version [Windows 10, Ventura, Ubuntu 22.04]: 7 and 10
IDE [Arduino IDE, PlatformIO, STM32CubeIDE, Keil]: Platform IO
IDE Version: 1.70.3 and the latest (18.x)
Board/MCU Mfg [Arduino, PJRC, ST Micro]: Arduino MEGA 2560 pro
Board/MCU Model [UNO, Teensy 4.1, NUCLEO-F429ZI]:
Many. Please, take a look at following link for more details and a solution:
https://community.platformio.org/t/strange-issue-with-compiling-under-linux-fine-fails-badly-in-windows/38572/2
Hi:
Here is my case:
I am trying to make a canbus thermocouple module with HeliOS ; the working flow as follow:
step1: power up and run init scripts for init
step2: create two task 1)get temperature 2)write canbus data and send out
wait for 750ms and make sure MAX6675 get the correct temperature data ,IN the meanwhile canbus data will NOT send out
step3: Task1:get temperature will run every 750ms and write the data in a float struct , notify task2 send out data
Task2:canbus data will send out data .
After I read thought examples pgm :Blink.ino and coop.ino .I don't quiet to understand the difference between xTaskResume() and xTaskWait()
In Blink.ino ,after create and check the task is OK .
xTaskWait(blink); -------->Is that means task in suspended mode ,not running
xTaskChangePeriod(blink, 1000); ------>that means wait for 1s , as a timer ,like function delay() of arduino ?
In coop.ino,after create and check the task is OK .
xTaskResume(shortTask); -------->Is that means task run immediately?
For further study,How to use MUTEX (in freeRTOS ) to lock the data?
Thank you for you guys answering!!!
Best wishes!!!
Hi!
First of all, congratulations for your nice project HeliOS. I liked your project and I'd like to contribute it for porting HeliOS to PIC18 devices of Microchip and maybe for STM microcontrollers in the future. My contributions would be in bare metal code form to interface your OS with the low level built-in hardware like timers, UARTs etc. I have looked through the guides but haven't seen any contributing guide. Can you provide a porting guide where you describe the systems interfaces briefly unless you have one, then please provide the link here so I can make use of it.
A brief guide would be very time saving, you know, we are kind of busy and time limited because of the full time work hours.
Encountered a strange problem which I cannot find a solution. Linking problem with multiple files that link fine when using FreeRTOS but not with HeliOS.
Made a simple test to verify this issue as well.
What works:
What does not work:
.pio/build/megaatmega2560/src/main.cpp.o (symbol from plugin): In function
display':
(.text+0x0): multiple definition of xByte2String(unsigned int, unsigned char*)' .pio/build/megaatmega2560/src/dummy.cpp.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status *** [.pio/build/megaatmega2560/firmware.elf] Error 1
I have been using this local.h approach for a long time successfully e.g. with FreeRTOS but for some reason HeliOS doesn't like this at all (or linker doesn't like with HeliOS).
local.h:
`#ifndef local_h
#define local_h
#include <Arduino.h>
#include <HeliOS.h>
#endif
`
dummy.h:
`#include "local.h"
extern void TaskDummy(xTask task_, xTaskParm parm_);`
dummy.c:
`#include "local.h"
void TaskDummy(xTask task_, xTaskParm parm_)
{
// nothing
}`
main.c (beginning of the file):
#include "local.h" #include <SPI.h> #include <Adafruit_GFX.h> #include <Arduino_ST7789_Fast.h> #include "dummy.h"
There comes usual setup() and loop() functions. In setup tasks are registered etc.
Expectation is that the code would link normally with HeliOS.
heliosproj/HeliOS@^0.4.1
OS [Windows, macOS, Linux]: Linux
OS Version [Windows 10, Ventura, Ubuntu 22.04]: OpenSUSE Tumbleweed
IDE [Arduino IDE, PlatformIO, STM32CubeIDE, Keil]: PlatformIO
IDE Version: 1.85.2
Board/MCU Mfg [Arduino, PJRC, ST Micro]: Arduino MEGA 2560 Pro
.pio/build/megaatmega2560/src/main.cpp.o (symbol from plugin): In function
display':
(.text+0x0): multiple definition of xByte2String(unsigned int, unsigned char*)' .pio/build/megaatmega2560/src/dummy.cpp.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status *** [.pio/build/megaatmega2560/firmware.elf] Error 1
Hi all!
I'm trying this RTOS to write the software for a digital guitar effect pedal but I ran across some issues (other than the docs not being up-to-date) with regards to a dynamically timed task...
First, I have a timed task that runs every 10ms which reads a pot value (between 0 and 1023) and calculates a delay tempo from it. This sets the timer of the next task accordingly.
long delay_time_us = long(map(delay_time, 0, 1023, 53, 626)) * 1000;
xTaskSetTimer(xTaskGetId("TASKTEMPO"), delay_time_us);
This "TASKTEMPO" is a very simple task that toggles a LED:
void taskTempo(xTaskId id_) {
if (smode == SMODE_TEMPO)
analogWrite(pin_rgb_g, 127 * tempo_blink);
tempo_blink = !tempo_blink;
}
If I only have those two tasks, it works fine. However, when I add a couple more tasks, things start to get a little different. The timing seems still alright but often the task completely skips... Meaning that the LED blinks irregularly... Based on the concept of cooperative scheduling I would assume that the priority is high (as the taskTempo is very short) but it doesn't seem to be the case... Can I somehow assign priorities to tasks or is there a different solution to the issue?
Hi!
First of all, congratulations for your nice project HeliOS. I liked your project and I'd like to contribute it for porting HeliOS to PIC18 devices of Microchip and maybe for STM microcontrollers in the future. My contributions would be in bare metal code form to interface your OS with the low level built-in hardware like timers, UARTs etc. I have looked through the guides but haven't seen any contributing guide. Can you provide a porting guide where you describe the systems interfaces briefly unless you have one, then please provide the link here so I can make use of it.
A brief guide would be very time saving, you know, we are kind of busy and time limited because of the full time work hours.
ID require you to search through the list to find corresponding task. I propose to replace ID with pointer to Task struct which will remove unnecessary lookup.
If you want to prevent user from messing with internals, I also propose to declare structs in separate header and typedef them as void in public header. This way from user point it's only a void pointer and he cannot change internal stuff whereas HeliOS functions will be able to do so.
I get follwowing result on UNO:
ACBACBACBL
ACBACBACBL
ACBACBACBL
ACBACBACBL
ACBACBACBL
ACBACBACBL
ACBACBACBL
ACBACBACBL
while using following code:
`/*
/*
/*
/*
for (int32_t i = 0; i < 1000; i++)
a *= 3.14f;
Serial.print("A");
}
void taskShortB(int32_t id_) {
float a = 0.0f;
for (int32_t i = 0; i < 10000; i++)
a *= 3.14f;
Serial.print("B");
}
void taskShortC(int32_t id_) {
float a = 0.0f;
for (int32_t i = 0; i < 40000; i++)
a *= 3.14f;
Serial.print("C");
}
/*
for (int32_t i = 0; i < 40000; i++)
a *= 3.14f;
Serial.println("L");
}
void setup() {
/*
Serial.begin(9600);
/*
/*
/*
Call xTaskStart() to start taskShort() by passing
xTaskStart() the id of the task to start.
*/
xTaskStart(id);
id = xTaskAdd("TASKSHORTB", &taskShortB);
xTaskStart(id);
id = xTaskAdd("TASKSHORTA", &taskShortC);
xTaskStart(id);
/*
/*
Serial.println("START");
}
void loop() {
/*
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.