This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions,
flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.
waitfordone - ratz...@yahoo.com - May 6 9:22:33 2008
Hello everyone.
I have a function that looks like this:
costate
{
waitfordone {a = cof_Task1;}
if (a < 1)
//some code
else
//another code
}
The Dynamic C User Manual sais the following: "When all the cofunctions
and firsttime functions listed in the wfd statement are complete (or one of them aborts),
execution proceeds to the statement following wfd. Otherwise a jump is made to the ending
brace of the costatement or cofunction where the wfd statement appears"
Does anyone know what OTHERWISE reffer to? Because when I debug my program, after
waitfordone, it doesn't enter the if satement and goes directly to the end of the
costatement and i don't know why.
Then you very much
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: waitfordone - jjbaumert - May 6 9:36:50 2008
I edited your code below. I believe you need the parentheticals to
make the program work.
In your code when you "yield" within the cof_Task1() cofunction, the
program will pick up after the closing brace "}" of the costatement.
The next time you enter the costatement, the program will pick up in
the cof_Task1() cofunction.
Typically a costatement is called in a loop as follows:
for(;;) {
costate {
// state machine #1
}
costate {
// state machine #2
}
costate {
// state machine #3
}
}
In the example above the three state machines run in "parallel."
After you return from the cofunction, program execution will continue
in the costatement at the "if" statement. After a costatement or
cofunction reaches the end of the statements, the next time you enter
the costatement you will start at the top.
Be careful to only have cof_Task1() active (yielding) within a single
costatement or cofunction within your program or you will get runtime
errors.
The costatement and cofunction constructs are a bit strange when you
first look at them, but thare are an easy way to build a state
machine.
Joel
--- In r...@yahoogroups.com, ratzoni_18@... wrote:
>
> Hello everyone.
>
> I have a function that looks like this:
>
> costate
> {
> waitfordone {a = cof_Task1();}
> if (a < 1)
> //some code
> else
> //another code
>
> }
> The Dynamic C User Manual sais the following: "When all the
cofunctions
> and firsttime functions listed in the wfd statement are complete
(or one of them aborts), execution proceeds to the statement
following wfd. Otherwise a jump is made to the ending brace of the
costatement or cofunction where the wfd statement appears"
>
> Does anyone know what OTHERWISE reffer to? Because when I debug my
program, after waitfordone, it doesn't enter the if satement and goes
directly to the end of the costatement and i don't know why.
> Then you very much
>
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: waitfordone - cjf10244 - May 6 9:39:28 2008
Allow me clarify with an example:
//Make an example function like:
scofunc int XPTO(void)
{
//Some code
return result;
}
In the main function use the following:
main()
int a;
costate
{
wfd a = XPTO();
if (a < 1)
//some code
else
//another code
}
When debuging, the if statement will only be checked when the
function XPTO return something. Otherwise it will continue to check
other costates or code that you have in the main program.
Hope it helps,
Carlos
--- In r...@yahoogroups.com, ratzoni_18@... wrote:
>
> Hello everyone.
>
> I have a function that looks like this:
>
> costate
> {
> waitfordone {a = cof_Task1;}
> if (a < 1)
> //some code
> else
> //another code
>
> }
> The Dynamic C User Manual sais the following: "When all the
cofunctions
> and firsttime functions listed in the wfd statement are complete
(or one of them aborts), execution proceeds to the statement
following wfd. Otherwise a jump is made to the ending brace of the
costatement or cofunction where the wfd statement appears"
>
> Does anyone know what OTHERWISE reffer to? Because when I debug my
program, after waitfordone, it doesn't enter the if satement and goes
directly to the end of the costatement and i don't know why.
> Then you very much
>
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: waitfordone - oana chenaru - May 6 11:38:33 2008
Thank you very much for your help. I realy understood how that works.
I had that code in a modbus application that isn't working, and it seems the main problem
is it doesn't receive any message.
Again, thank you very much
----- Original Message ----
From: "r...@yahoo.com"
To: r...@yahoogroups.com
Sent: Tuesday, May 6, 2008 4:15:31 PM
Subject: [rabbit-semi] waitfordone
Hello everyone.
I have a function that looks like this:
costate
{
waitfordone {a = cof_Task1;}
if (a < 1)
//some code
else
//another code
}
The Dynamic C User Manual sais the following: "When all the cofunctions
and firsttime functions listed in the wfd statement are complete (or one of them aborts),
execution proceeds to the statement following wfd. Otherwise a jump is made to the ending
brace of the costatement or cofunction where the wfd statement appears"
Does anyone know what OTHERWISE reffer to? Because when I debug my program, after
waitfordone, it doesn't enter the if satement and goes directly to the end of the
costatement and i don't know why.
Then you very much
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )