I last visited this topic about 4-6 months ago in the old forum. It took a little while to get clarification, but at the time Dick Swan posted a very detailed response (one of the reasons I'd like to see the old forum migrated across or accessible) explaining that events were not correctly implemented in the RCX firmware. While Robolab and NQC had implemented some sort of work around which made them appear to work with events, Dick was proposing the idea that the fault in the firmware should be corrected. At the time there were other priorities, and Dick felt the complexity of the task was very high (And, he offered me the job if I'd like to fix it. Ha Ha Ha)

Now, it took me a little while to get the structure and syntax correct at the time and I've since lost my original code. Rather than go through the same scenario again I was wondering:

1) Has the old problem with events been resolved with the RCX?
2) Is it something that is likely to be looked at or is it outside the scope of RobotC? If it is likely to be fixed what time frame is realistic?
3) Do events work with the NXT?
4) If they do can someone post a simple example using correct syntax or my old example (from old forum) if it is still correct?

Thanks
James

Wed Feb 28, 2007 9:29 pm

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 616

I don't remember what I posted. NXT implementaito nis same as RCX. It has events working.

As I recall, I think you wanted more generaic "OS" type of events. What is implemented is capabilities like "wait until either timeout of some kind of synchronization event / semaphore".

Refresh my memory please.

Thu Mar 08, 2007 10:10 pm

JamesD

Novice

Joined: Sun Feb 04, 2007 12:48 amPosts: 69Location: Australia

Hi Dick,

Thanks for your response.

I don't have much more info than I posted above. Given the situation I was hoping maybe Vu Nguyen has access to the old forum and could copy some of the old messages to this new post. Alternatively, I found some old code I was playing around with. This doesn't compile in the new version but I'm pretty sure it did under the old Beta versions of RobotC.

Before anyone writes back to explain that there is simpler code to follow a line please note this is an attempt to understand and implement events.

Also I'm struggling to find any info about events. They don't seem to be listed in the templates section.

Thanks
James

Sun Mar 11, 2007 6:34 am

JamesD

Novice

Joined: Sun Feb 04, 2007 12:48 amPosts: 69Location: Australia

Hi Vu,

Any chance of digging out the old post to give Dick a more informed picture of what I'm asking?

Thanks
James

Sat Mar 17, 2007 2:18 am

JamesD

Novice

Joined: Sun Feb 04, 2007 12:48 amPosts: 69Location: Australia

Bummer,

It looks like this one was missed in Dick's last visit.

If one of the developers sees this, and it is not too late, can a working example of events be included in the sample files in the next release. (The syntax and structure eludes me) A simple one such as a program that simply drives fwd until a light sensor sees a black line would be great.

Or simply post an example here

Thanks
James

Mon Mar 26, 2007 8:31 am

vnguyen

Site Admin

Joined: Wed Jan 24, 2007 10:44 amPosts: 442Location: Pittsburgh, PA

I sent out set of links to him to have him respond, I hope I didn't miss this one on the email. I'll email him this link right now, sorry for the delay!

_________________Vu NguyenSoftware Training Development Team | WebmasterNeed more support? Email ROBOTC Support at support@robotc.net to put in a support ticket

This code is not what you intended. It will look forever setting up event monitoring, executing two "motor" instructions in the wait section and then exiting the event monitoring. Almost half the time will be spent in the loop outside of the "monitor" block.

I'm sure what was intended was to put long delay inside the event monitoring "section". The delay will be aborted when a event happens and the code will fall into the 'catch' clause.So the modified code is:

Note to Developers: Can you unlock the Exception Report dialog box so the above details can be cut & pasted rather than re-typed. It would be better for me and you as people will be more likely to post their error descriptions.

Please note it appears to setup events in the events debugger window. I'm unsure whether it configures correctly though as no samples have been posted yet. Hint. Hint

Thanks
James

Thu May 17, 2007 6:02 am

SuntzuMaster

Rookie

Joined: Sun Apr 15, 2007 8:33 amPosts: 40Location: USA

Hi,

Just to let you know that I got the same error, I think that the calibrate function is the culprit!

cu.

jm.

_________________SuntzuMaster- a French gentlemen in USA.

Sun May 20, 2007 4:04 pm

SuntzuMaster

Rookie

Joined: Sun Apr 15, 2007 8:33 amPosts: 40Location: USA

I would like to hilight the fact that I love ROBOTC, but I think that as soon as one wants to start a real large or very technical piece of S/W then the documentation is not appropriate anymore... I have wrote s/w on different platforms from pc to mainframe and the documentation was always outstanding even in 1984/85 when I was using the very first BORLAND TURBO/PASCAL/ASSEMBLER/C... their documentation was always excellent. I think that a true technical documentation and a true language reference are more than missing... I think also that some formal information about H/W and S/W relationships could be welcome. The current post is just a symptome about that documentation issue...

I think that it is still possible to look inside all the ROBOTC header files to try to discover what functions are hidden but I do not think that is appropriate at all.

hope that one day ROBOTC.NET will provide that level of documentation that could save hours of guess work.

thanks in advance.

jm.

_________________SuntzuMaster- a French gentlemen in USA.

Tue May 22, 2007 8:32 am

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 616

"CalibrateEvent" is non-functional. It was initially implemented for legacy purposes with the original RCX firmware code. When I looked at the RCX implementation, I'm pretty confident that it is broken/non-functional and never got around to writing a working version for the RCX.

With the increased power of the NXT, it would not be that difficult to write your own calibrate function if you're not happy with the default values.

Here's a sample program that I recently wrote to illustrate the event handling capabilities.

Code:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Sample Program to Demonstrate Events//// Short little program to demonstrate use of Events./////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//// You can monitor up to 16 events; they're numbered from 0 to 15. This program will monitor two of them. A couple of// convenient declarations for the two events used in this sample program.//const byte kUserEvent1 = 1;const byte kTimerEvent2 = 2;

//// A couple of variables to keep track of how many times each event is triggered.//int nUserEvents = 0;int nTimerEvents = 0;

void waitTest(int nDuration){ // // There was a (incorrect) bug report that said event monitorings didn't work when a subroutine was running when // the event occured. This function is called while we're monitoring events and we find that everything works fine. // wait1Msec(nDuration); return;}

void testEvents(){ ClearAllEvents();

// // Need to define the two events. // // Event 'kUserEvent1' will be user defined. That means it is set by software with a "SignalEvent" call. // // Event 'kTimerEvent2' will be defined when the value of "timer 1" enters the high region. The timer events are // use 100-msec ticks. Setting the value of "eventUpper[kTimerEvent2] = 10;" will define the upper threshold at 1,000 // msec (or 1 second) so the event will be triggered whenever the timer crosses the threshold greater than value 1000. // SetEvent(kUserEvent1, EST_USER_EVENT_0, eventTypePressed); SetEvent(kTimerEvent2, EST_TIMER_1, eventTypeEnterHigh); eventUpper[kTimerEvent2] = 10; // 10 ticks of 100-msec each

while (true) { time1[T1] = 0; monitor (EVENT_MASK(kUserEvent1) | EVENT_MASK(kTimerEvent2)) { while (true) { waitTest(2000); PlaySound(soundBlip); SignalEvent(kUserEvent1); // This code never gets executed because we wait longer than the 1 second duration // that triggers the 'kTimerEvent2'. If reduced the wait time below 1 second we'd // find that the "SignalEvent" is happening and that 'kUserEvent1' will be triggered. } } // // You can define one or more "catch" clauses. This is very much like the "try ... catch" sequence found in C++. // // A catch clause can specify a mask for the events that it will catch. Typically this is the bit mask for a single // event but it could be a bit map specifying multiple events. // // 'catch" clauses are evaluated in sequential order until one matches the bit map of events that have happened. //

catch { // This will "catch" all remaining events. In this case, there will be no events to captr } }

PlaySound(soundDownwardTones); wait1Msec(5000);}

task main(){ // // There was a (incorrect) bug report that said event monitorings didn't work when it were defined in a subroutine. // We'll test this here and find that it works fine. // testEvents(); return;}

//// Above sample events were very simple. Mor typically you might define an event based on the value of one of the sensors. You// could use "eventTypeEnterHigh", ":eventTypeEnterLow" or "eventTypeEnterNormal" to indicate whether the event is triggered// because we entered high, low or normal (i.e. between low and high) values. For example, in line following you could use this// to indicate whether the robot is "on the line" or to the "dark" or "light" side of the line. For a sensor event, simple use the// value "EST_SENSOR_X" (X = 0, 1, or 2) to define based on a sensor value.//// Note for legacy reasons and compatibility with RCX and NXT you can only define events for first three sensors. You cannot define// an event for the fourth NXT sensor.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum