Go Down

Topic: Unos 0.1.1 - Programs on SD Card Now Supported (Read 17823 times) previous topic - next topic

rockwallaby

goodinventer wrote:
Quote
Having a scheduler, though, would simplify more demanding tasks involving time limits.
With the code I have seen thus far in your posts, I'm not sure how it would simplify anything for a programmer needing to have complex or 'demanding' time based event schedules, when, as Robin points out, it is just so easy to use existing functions provided by the compiler such as millis().

I am left wondering after so many suggestions to you that you take some time to learn about a number of concepts, what has your motivation been to continually forge on with what to many of us is seemingly pointless?

I too, would like to suggest to you as ShapeShifter has,
Quote
come up with some interesting projects that are appropriate for a limited embedded processor like the Arduino, and go and have some FUN with it!
As your alias might suggest, why not go and invent something good, good for you, where you alone experience enjoyment from learning and tinkering?

Maybe like so many other people, you too can make your Arduino poke, prod, scrunch, regurgitate data from the real world to push, pull, send, store, speak or light to put that child like grin on your face and laugh with delight at your achievement.

Then, we, too can be then happy for you.

I am tiring of this thread, and will now bail out to do more interesting things, I wish you luck.
____
Paul
Paul - VK7KPA

Robin2

#16
Jan 25, 2015, 11:49 pm Last Edit: Jan 25, 2015, 11:50 pm by Robin2
Somewhat. Having a scheduler, though, would simplify more demanding tasks involving time limits.
If the word "somewhat" refers to your familiarity with using millis() for timing then the VERY FIRST THING for your agenda is to become TOTALLY familiar with it before thinking about a scheduler.

I don't agree that a scheduler would benefit "more demanding tasks". All it will do is use more code and more CPU time to do the same job. Like hiring 2 accountants instead of one.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

goodinventor

On the contrary, I am completely familiar with using millis() in timing. It is simply the strategy used for schedulers in managing tasks that I do not fully understand.

goodinventor

How do I use my timing function that uses millis() for scheduling?

AWOL

Quote
I am completely familiar with using millis() in timing
Quote
How do I use my timing function that uses millis() for scheduling?
Speechless.

goodinventor

I meant how do I schedule different tasks? Is there a link or a book that I can use to get an idea of how multitasking and process scheduling works?

AWOL

Chapter 7, Bovet and Cesati's "Understanding the Linux Kernel"

goodinventor


goodinventor

Here is the new and improved version. It has a simple scheduler, an interrupt handler (could use some work), and a simple interpreter built in.

pYro_65

Quote
int Timer::Time()
{
  // this will be used to access variables of class Timer
  Timer Timer;
No it won't, at least not the ones you are expecting.

This creates a new Timer object, named Timer, it has not had its time_needed or last_time_update values set. Which means your timer uses unknown values, and the ones you did set aren't used.

Consider this sketch, it is equivalent to the problem in your Timer class (run this and see ):
Code: [Select]

struct Foo{
 
  int bar(){
    Foo Foo;
    return Foo.value; 
  }
 
  int value;
};


void setup() {
  Serial.begin( 9600 );
 
  Foo f;
  f.value = 44;
 
  Serial.println( f.bar() );
}

void loop() {}


Inside a class member function, if you want to access the members of the instance that was used to call the function, then you use the 'this' pointer, or simply just the name.

Code: [Select]
unsigned long interval = Timer.time_needed;  //WRONG
unsigned long interval = this->time_needed; //CORRECT
unsigned long interval = time_needed; //CORRECT


You need to slow down and test your code one piece at a time, before trying to bust out an entire OS. This Timer is used in your scheduler, so it is also flawed.
Forum Mod anyone?
https://arduino.land/Moduino/

goodinventor

Is this better?

pYro_65

#26
Feb 15, 2015, 04:14 am Last Edit: Feb 15, 2015, 05:04 am by pYro_65
Is this better?
Have you tested thoroughly?
Have you gout multiple short sketches to test different scenarios?
Are there examples / documentation to show how each feature is used?
Do you expect the user to implement a 9Kb file in their sketch?

I personally do not care, I will not be using your system for anything, anyhow. But if you want others to use it (in the future) you'll have to start testing, asking questions & improving your C++ knowledge. Posting your code and asking whether its better simply shows you didn't test before hand, and didn't test afterwards.

A better approach would be to create a GitHub account, and add your project as a repository. Then here you can link to the project and post short snippets of errors, questions and things you're unsure about. (after you have tested it)


What do you expect the advantage of this is:
Code: [Select]
void executeInterpreterCommand(int myCommand)
{
  switch (myCommand)
  {
    case 0: // nop()
      nop();
      break;


You'll use more than one cycle getting to the nop() call.
Forum Mod anyone?
https://arduino.land/Moduino/

goodinventor

pYro_65,

I did test it. However, I asked you to look at it in order to detect any potential problems that I did not catch. I'm thinking of eventually just using assembly instructions as the language in my interpreter instead of the simple C++ instructions.

pYro_65

I'm thinking of eventually just using assembly instructions as the language in my interpreter instead of the simple C++ instructions.
sei(), cli(), nop() won't be any different. They already are implemented using a single asm instruction.

You are also missing the point, regardless of how you insert a nop, its only a single cycle. There is no logical use for it as the interpreter uses more than 1 cycle to interpret the command for a nop. Something that could delay a minimum number of cycles would be better.

However, I asked you to look at it in order to detect any potential problems that I did not catch.
Build better tests. It doesn't look like your scheduler does anything...
Forum Mod anyone?
https://arduino.land/Moduino/

ShapeShifter

There is no logical use for it as the interpreter uses much MUCH MUCH more than 1 cycle to interpret the command for a nop.
There, I fixed it for you.  8)

_____________


goodinventor: Even if the whole interpreter were written in assembly language, the amount of time actually spent executing the NOP is negligible compared to the amount of time it takes to read in and translate the line of "code." This renders the instruction pointless.

Go Up