To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 758
757  |  759
Subject: 
Re: newbie questions...
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 12 Sep 2000 02:27:41 GMT
Viewed: 
2091 times
  
In article <slrn8rp5sq.vs4.stelian@ontario.alcove-int>,
stelian@alcove.fr (Stelian Pop) wrote:

On Sat, 9 Sep 2000 05:30:24 GMT,
Dave Baum <dbaum@spambgoneenteract.com> wrote:

The above looks good, but I haven't tried it so there could be a subtle
problem.  Using ActiveEvents() is pretty awkward at present because you
need to know the task number of the running task (task main is 0).
With
the latest firmware (firm0328.lgo) you can use ActiveEvents(10) to
always get active events for the current task.

Ok, so the 'if ( ActiveEvents(10) & EVENT_MASK(0) )' is the
correct syntax to check if event 0 was triggered ?


yes

I'll probably add more
sophisticated catch code to NQC in the future that takes advantage of
ActiveEvents(10).

Or a function that returns the current task number ?


That's pretty tough to implement.  Code in the tasks is easy...the task
number is a constant.  Same for subs that are only called from one task.
Inline functions are also easy...provided they are called from one of
the above.

The problem case is when generating code for a sub that's called from
multiple tasks.  The only way I could think of solving this problem
would be to dedicate one of the locals to storing the task number.  Each
task, upon startup, would write its number to its copy of the local.  A
sub could then read the local to determine which task it is being called
from.

But...this doesn't help.  Even if you could get the task number into a
variable, there wouldn't be any way to call ActiveEvents() with the
variable as an argument...it must have a constant argument (due to the
way the bytecodes are setup).  Basically, the bytecodes don't provide
any sort of indirection when asking for active events.

I had considered adding a special keyword that at compile time would
evaluate to the task number (and be constant at compile time).  This
would've led to something like:

if (ActiveEvents(__task) & EVENT_MASK(0))

However, the code would've been illegal in subs called from multiple
tasks, so I wanted a more general solution.  I traded a couple of emails
about this with someone at Lego, and ActiveEvents(10) was the result(1).
I just haven't been working on NQC since firmware 3.2.8 was releaed, so
no special APIs or catch syntax has been added.

Dave

(1) they really do listen!

--
reply to: dbaum at enteract dot com



Message has 1 Reply:
  Re: newbie questions...
 
(...) Thanks. (...) I see... Anyway, there shouldn't be a great need to monitor the same event in different tasks, so it's not that important... Let's give LEGO the time to add this in the firmware then :) (...) Great! Stelian. (24 years ago, 12-Sep-00, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: newbie questions...
 
(...) Ok, so the 'if ( ActiveEvents(10) & EVENT_MASK(0) )' is the correct syntax to check if event 0 was triggered ? (...) Or a function that returns the current task number ? Thanks for your advices and keep up the good work ! Stelian. (24 years ago, 11-Sep-00, to lugnet.robotics.rcx.nqc)

5 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR