Hello everyone,
Wow great to see an RTOS port for the arduino! I've used uC/OS-II but haven't toyed much with FreeRTOS.
Anyhow I've downloaded the 0.2 Alpha version have the samples working (FYI - the main.cxx wasn't included and I had to use 0.1 Alpha version - not certain if there were any changes though but it works). However there may be a potential bug with Serial or Print.
Board: Duemilanove Atmel ATmega328
ArduinoL IDE 0017
float myFloat = 23.23;
int myInt = 43;
Serial.print("Hello World.."); // works
Serial.println("Hello World Again.."); // works
Serial.println(myFloat); // prints the first digit and hangs "print" does the same
Serial.println(myInt); // prints the first digit and hangs "print" does the same
After comparing Print.cpp and Print.h files from Arduino core to DuinOS there were differences. Once I copied the Arduino core Print.cpp and Print.h files over it DuinOS was able to print ints via serial port but floats are failing e.g. one char prints and hangs the system.
Also, is there a way to check which environment the project is compiled from using a ifdef check? I wouldn't mind porting some libraries for DuinOS but wanted to know if they can be transparent between platforms.
code sample for clarification
#if ___DuinOS___ //
#define LONG_PULSE delay(100)
#else
#define LONG_PULSE delayMicroseconds(1)
#endif
Update:
Downloaded Arduino IDE 0018.
Tried the same cases (includes replacing files) and neither int or float are able to print using Serial.print.
Sketch file...
/*
DuinOS MoreComplexBlinkingSoundSerial
Blinks two LEDs and play sound.
The circuit:
* 1 LED connected from digital pin 14 (8)
* 2 LED connected from digital pin 15 (9)
* Speaker connected from digital pin 16 (10)
Created 2010.06.30 (yyyy.mm.dd)
by Michael Grigorev aka CHERTS
*/
#include <Streaming.h> // Include the Streaming library
#define ledPinRed 2
#define ledPinGreen 3
#define SoundPin 6
#define greenDelay 200
#define redDelay 400
#define outDelay 5000
declareTaskLoop(OutputSHT);
declareTaskLoop(redLED);
declareTaskLoop(greenLED);
declareTaskLoop(PlaySound);
taskLoop(OutputSHT)
{
Serial << "Hello" << endl; // yippy Streaming library works...provided a float or int isn't concatenated
Serial.print("Val: ");
//Serial.print(23.33); // *** hangs here if un-commented
//Serial.print(" ");
//Serial.print(23); // *** hangs here is un-commented
Serial.println(" something...");
delay(outDelay);
}
taskLoop(redLED)
{
digitalWrite(ledPinRed, HIGH);
delay(redDelay);
digitalWrite(ledPinRed, LOW);
delay(redDelay);
}
taskLoop(greenLED)
{
digitalWrite(ledPinGreen, HIGH);
delay(greenDelay);
digitalWrite(ledPinGreen, LOW);
delay(greenDelay);
}
taskLoop(PlaySound)
{
tone(SoundPin, 1245, 480);
delay(480);
tone(SoundPin, 932, 240);
delay(240);
tone(SoundPin, 1245, 960);
delay(120);
tone(SoundPin, 831, 240);
delay(240);
tone(SoundPin, 932, 480);
delay(480);
tone(SoundPin, 622, 720);
delay(240);
tone(SoundPin, 784, 120);
delay(120);
tone(SoundPin, 932, 120);
delay(120);
tone(SoundPin, 1245, 240);
delay(240);
tone(SoundPin, 932, 240);
delay(240);
tone(SoundPin, 1397, 240);
delay(240);
tone(SoundPin, 1245, 960);
delay(120);
tone(SoundPin, 1109, 360);
delay(360);
tone(SoundPin, 1047, 120);
delay(120);
tone(SoundPin, 932, 120);
delay(120);
tone(SoundPin, 831, 360);
delay(360);
tone(SoundPin, 932, 960);
suspend();
}
// The setup() method runs once, when the sketch starts
void setup()
{
//
Serial.begin(9600);
// Initialize the digital pins as outputs:
pinMode(ledPinRed, OUTPUT);
pinMode(ledPinGreen, OUTPUT);
createTaskLoop(OutputSHT, LOW_PRIORITY);
createTaskLoop(redLED, NORMAL_PRIORITY);
createTaskLoop(greenLED, NORMAL_PRIORITY);
createTaskLoop(PlaySound, NORMAL_PRIORITY);
//This initializes the main loop's with a different priority (default is LOW_PRIORITY):
//initMainLoopPriority(NORMAL_PRIORITY);
}
// This is the main loop() method, wich runs over and over again,
// as long as the Arduino has power. Is a LOW_PRIORITY taskLoop:
void loop()
{
// Stop the task of redLED in 10 seconds
delay(10000);
suspendTask(redLED);
// Start the task of redLED in 10 seconds
delay(10000);
resumeTask(redLED);
//
delay(30000);
resumeTask(PlaySound); // play Micheal's funky intro again
}
Thanks
Eric