Sign in

username:

password:



Not a member?

Search rabbit-semi



Search tips

Subscribe to rabbit-semi



Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | Rabbit-Semi | avoiding simultaneous use of modem


Advertise Here

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.

avoiding simultaneous use of modem - dani...@hotmail.com - May 1 13:50:38 2009

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 )


Re: avoiding simultaneous use of modem - Scott Henion - May 1 14:07:03 2009

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 )

Re: avoiding simultaneous use of modem - Jon - May 3 9:53:14 2009

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 )