hello guys, here is my concern, i have 2 costates :
CoFTP: upload a file to ftp server
CoChecSMS: check for sms messages and process them
now i want the coFTP to have a delay of 30min
and the CoCheckSms a delay of 5 min.
what im trying to do is a routine that ensures me that those
2 costates wont be using the modem at the same time. here is my attempt.
do you think this is correct?
**************************************************************
modem_busy = 0;
while(1){
costate {
waitfor(DelaySec(300) && modem_busy = 0);
modem_busy = 1;
coBegin(CoCheckSMS);
}
costate{
waitfor(DelaySec(1800) && modem_busy = 0);
modem_busy = 1;
coBegin(CoFTP);
}
costate CoFTP{
//processing...
modem_busy = 0;
}
costate CoCheckSMS{
//processing...
modem_busy = 0;
}
}
*************************************************
(ignore typos)
------------------------------------
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
d...@hotmail.com wrote:
> hello guys, here is my concern, i have 2 costates :
> CoFTP: upload a file to ftp server
> CoChecSMS: check for sms messages and process them
>
> now i want the coFTP to have a delay of 30min
> and the CoCheckSms a delay of 5 min.
> what im trying to do is a routine that ensures me that those
> 2 costates wont be using the modem at the same time. here is my attempt.
> do you think this is correct?
>
> **************************************************************
> modem_busy = 0;
>
> while(1){
>
> costate {
> waitfor(DelaySec(300) && modem_busy = 0);
> modem_busy = 1;
> coBegin(CoCheckSMS);
> }
>
> costate{
> waitfor(DelaySec(1800) && modem_busy = 0);
> modem_busy = 1;
> coBegin(CoFTP);
>
> }
> costate CoFTP{
> //processing...
> modem_busy = 0;
> }
> costate CoCheckSMS{
> //processing...
> modem_busy = 0;
> }
>
> }
> *************************************************
> (ignore typos)
>
Ugh, I hate the costate begin/stop methods. Mainly because it is so odd
and i am the one that usually ends up porting it to something more
standard. I see this stuff used a lot and it usually ends up a mess a
what normally would be one "task" is scattered in several costates.
Why not just a something simple:
cofunc CoCheckSMS(...)
{
}
cofunc CoFTP(...)
{
}
while(1){
costate {
waitfor(DelaySec(300) && modem_busy = 0);
modem_busy = 1;
wfd CoCheckSMS();
modem_busy = 0;
}
costate{
waitfor(DelaySec(1800) && modem_busy = 0);
modem_busy = 1;
wfd CoFTP();
modem_busy = 0;
}
}
Will be much easier to follow and debug.
--
------------------------------------------
| Scott G. Henion| s...@shdesigns.org |
| Consultant | Stone Mountain, GA |
| SHDesigns http://www.shdesigns.org |
------------------------------------------
today's fortune
[the family is planning a vacation]
Peter Griffin: We could always go to purgatory like we did last year. [flashback]
Lois Griffin: This isn't bad. It's not good, but it's not bad.
Brian Griffin: So so.
Peter Griffin: More or less.
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
I must be missing something about the goal that is to be achieved. If only one of the two
functions is to run at any point in time, why are we discussing cofunctions, which are
intended to divide time between the two processes?
Perhaps we can simply write a function to see if the RTC minute has changed, and use
conventional functions?
while(1)
{
if(newminute())
if(timer1++>=5)
{
CheckSMS();
timer1=0;
}
if(timer2++>=30)
{
UpdateFTP();
timer1=0;
}
}
just a suggestion...
Jon
--- In r...@yahoogroups.com, Scott Henion
wrote:
>
> danielperales1@... wrote:
> > hello guys, here is my concern, i have 2 costates :
> > CoFTP: upload a file to ftp server
> > CoChecSMS: check for sms messages and process them
> >
> > now i want the coFTP to have a delay of 30min
> > and the CoCheckSms a delay of 5 min.
> > what im trying to do is a routine that ensures me that those
> > 2 costates wont be using the modem at the same time. here is my attempt.
> > do you think this is correct?
> >
> > **************************************************************
> > modem_busy = 0;
> >
> > while(1){
> >
> > costate {
> > waitfor(DelaySec(300) && modem_busy = 0);
> > modem_busy = 1;
> > coBegin(CoCheckSMS);
> > }
> >
> > costate{
> > waitfor(DelaySec(1800) && modem_busy = 0);
> > modem_busy = 1;
> > coBegin(CoFTP);
> >
> > }
> >
> >
> > costate CoFTP{
> > //processing...
> > modem_busy = 0;
> > }
> >
> >
> > costate CoCheckSMS{
> > //processing...
> > modem_busy = 0;
> > }
> >
> > }
> > *************************************************
> > (ignore typos)
> >
>
> Ugh, I hate the costate begin/stop methods. Mainly because it is so odd
> and i am the one that usually ends up porting it to something more
> standard. I see this stuff used a lot and it usually ends up a mess a
> what normally would be one "task" is scattered in several costates.
>
> Why not just a something simple:
>
> cofunc CoCheckSMS(...)
> {
> }
>
> cofunc CoFTP(...)
> {
> }
> while(1){
>
> costate {
> waitfor(DelaySec(300) && modem_busy = 0);
> modem_busy = 1;
> wfd CoCheckSMS();
> modem_busy = 0;
> }
>
> costate{
> waitfor(DelaySec(1800) && modem_busy = 0);
> modem_busy = 1;
> wfd CoFTP();
> modem_busy = 0;
> }
>
> }
>
> Will be much easier to follow and debug.
>
> --
> ------------------------------------------
> | Scott G. Henion| shenion@... |
> | Consultant | Stone Mountain, GA |
> | SHDesigns http://www.shdesigns.org |
> ------------------------------------------
>
> today's fortune
> [the family is planning a vacation]
> Peter Griffin: We could always go to purgatory like we did last year. [flashback]
> Lois Griffin: This isn't bad. It's not good, but it's not bad.
> Brian Griffin: So so.
> Peter Griffin: More or less.
>
------------------------------------

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