Another Problem with Program

Hello,

Attached is the code for the program. I get this error, though.

Process.cpp:17: error: expected initializer before 'Process'

What do I do to fix this error?

Unos_0_1_2.ino (410 Bytes)

Process.h (1.31 KB)

Process.cpp (541 Bytes)

Scheduler.h (1.09 KB)

Scheduler.cpp (1.68 KB)

Timer.h (1.07 KB)

Timer.cpp (1020 Bytes)

Process Process;

Are you just messing with us here? The variable can't have the same name as the type. In what world would that even begin to make sense?

Looking at line 17 of your process.cpp file (as that's the line and filename mentioned in the error) I find

Process Process;

Since Process is the name of the class You need to use an alternative name for the instance. Either rename your Process class, or rename the instance.

Just as you can't have a variable called int or byte, once you have a class called Process, you can't have a variable called Process either.

class Process
{
  public:
    // variables
    boolean TASK_RUNNING; // states whether a task is running or not
    boolean TASK_INTERRUPTIBLE; // states whether a task is interruptible or not
    boolean TASK_UNINTERRUPTIBLE; // states whether a task is uninterruptible or not
    boolean TASK_STOPPED; // states whether a task is stopped or not
    boolean TASK_TRACED; // states whether a task is stopped by a debugger
    boolean EXIT_ZOMBIE; // states whether a task is terminated but the parent process has not yet
                         // issued a system call to return information about the dead process or not
    boolean EXIT_DEAD; // states whether a task is terminated and removed or not
    int POWER_SAVE_MODE; // power-save mode
    int STANDBY_MODE; // standby mode
    int POWER_DOWN_MODE; // power down mode
    
    // functions
    void Initialize();
    int SendProcessSleepMessage();
}

Missing something really really important after that last closing brace.

Thank you. It compiles fine now.

void Scheduler::HandleExpiredTasks()
{
  if (Task.TASK_TIME_LENGTH > 1000)
  {
    Task.NUMBER_OF_TASKS--;
    if (Task.NUMBER_OF_TASKS == 0)
    {
      Task.TASK_RUNNING = false;
    }
  }
}

You're also usingthis constant TASK_RUNNING that isn't defined anywhere in the whole program.

I have it now in Process.h.

OK, do one more thing before you post this code again. Take all of those variable names that are in all-caps and fix them so that they aren't in all-caps anymore. They should all start with a lower case letter. You_can_use_underscores or youCanUseCamelCase. But you can't use all-caps.

Is this okay?

Unos_0_1_2.ino (474 Bytes)

Process.h (1.31 KB)

Process.cpp (511 Bytes)

Scheduler.h (1.09 KB)

Scheduler.cpp (1.68 KB)

Timer.h (1.07 KB)

Timer.cpp (1020 Bytes)

Delta_G:
You_can_use_underscores or youCanUseCamelCase. But you can't use all-caps.

"can't" ? Really??? When was that law passed?

Capitalization is a convention, not a hard requirement. And there are tons of different coding conventions, some of which no doubt would disagree with you on this point. That doesn't make them wrong, just different. Even Kernighan and Ritchie state: "Traditional C practice is to use lower case for variable names, and all upper case for symbolic constants." That's a suggestion, not a mandate. The compiler doesn't care one bit. A good programmer will follow some convention, but it need not be the same one you follow.

Regards,
Ray L.

That's a suggestion, not a mandate

If K&R (peace be upon them) wrote that, then that's the closest we have to Holy Writ.

I have continued by adding interrupt handlers. (Note that they are not complete yet; I just want to see if the program can detect them.) But I get errors like this.

Unos_0_1_2.ino:109: first defined here

What is the problem here and how should I fix it?

Process.cpp (511 Bytes)

Process.h (1.31 KB)

Scheduler.cpp (1.68 KB)

Scheduler.h (1.09 KB)

Timer.cpp (1020 Bytes)

Timer.h (1.07 KB)

Unos_0_1_2.ino (4.45 KB)

ISR(INT1_vect, ISR_BLOCK)
{
  Serial.println(F("An interrupt has occurred."));
  Serial.println(F("Interrupt ID: INT1 (External Interrupt Request 1)"));
}

Really?

Line 109ISR(TIMER0_OVF_vect, ISR_BLOCK)I wonder who else might have dibs on this . . .

AWOL:
If K&R (peace be upon them) wrote that, then that's the closest we have to Holy Writ.

If that were true, they would have rolled the convention into the language, and made the compiler enforce it....

Regards,
Ray L.

But that's the whole "free-will" vs. "faith" argument.

Who are we mere mortals, to argue with the Eternal Biumvirate?

Well, what is the problem with the code?

OK, taking reply #12 point by point:

  1. you shouldn't do (some would say "can't") serial I/O in an ISR.

  2. there can only be one ISR per interrupt vector.

But all the listed vectors are different. Or do you mean that there can be only one ISR (not multiple definitions)?

Can you give me an example of multiple ISR's in one program?

Have a look at Serial handling in the cores directory.