Cheers Daniel,
If I may, I would just like to show you what I have so far for the ISR code for the serial interrupt.
my channel that I am using to store the received command is called RX_chars. The function below gets attached to the serial object - pc in main().
The function is not working as expected however as it seems to send a signal for a single received command. Followed by the program crashing. I know the program stops functioning as I have a LED toggling as one of the processes. This stops occurring.
#ifndef SERIAL_H
#define SERIAL_H
#include <processes.h>
Serial pc(USBTX, USBRX); // tx, rx
void signal_serial() //signal RTOS event that RXinterrupt has been asserted
{
char temp = 0;
OS::TISRW ISR;
while(pc.readable())
{
temp = pc.getc();
if(temp !='\n')
RX_chars.push(temp);
else if(temp == '\n')
{
RX_chars.push('\0');
RX_flag.Signal();
}
}
}
#endif
I think I am doing something wrong in my interrupt ISR as shown above.
For clarity, I have included the program which, when it is finished will parse the command and deal with it.
#pragma once
#ifndef COMMAND_HANDLER_H
#define COMMAND_HANDLER_H
#include
template<> OS_PROCESS void Command_handler::Exec() //serial stream handling process
{
char RX_Command[100] = "";
for(;;)
{
RX_flag.Wait(); //suspend and wait for a command
RX_chars.read(RX_Command, RX_chars.get_count());
RX_chars.flush(); //flush the channel
pc.printf("Command received was: %s \n", RX_Command);
}
}
#endif
Thanks again.
Greg
I know there were FreeRTOS ports done before but they used an external compiler and I personally find FreeRTOS big and confusing. I looked around and found something called scmRTOS. It makes quite heavy use of C++ OOP and templates so I was a bit skeptical at first, but looks like it's used quite sensibly - to make most of the OS configuration resolve at compile-time. No RTTI or exceptions are used, and the generated code looks quite compact.
There was a port for Cortex-M3 (STM32, but chip-specific bits were nicely isolated), so I could make it compile with the online compiler pretty quickly. And it does seem to work - I have three processes running which communicate using "event flags" (binary semaphores) and happily toggle the leds. The docs are somewhat Runglish-y, but at least the are some available!
Check it out: scmRTOS_test
If you want to use the code for your own program, don't forget to change at least the process count in scmRTOS_config.h.
I'm still learning the code myself but if you have any questions, ask away - I can at least cross-check with the Russian docs.