The error is on this line (I think):

     double ran0(long &idum)

where the syntax should be:

     double ran0(long *idum)

if you mean you are passing a pointer to a double value.


But I think ints are 16 bits and doubles and floats
are both 4 bytes so your calculations will probably
not be what you want.

MS


Lakshmi Pradeep wrote:
> 
> Hi ,
>                  Thanks for your reply.I am attaching that code below . 
> Could you please check it for me ?         BlinkM is a code for checking 
> a random number generation .Function ran0 returns a random number 
> between 0.0  and 1.0.   This function works in C.
> I am working with moteworks platform,mib520 programming board ,micaz 
> motes . I got this error on executing this code in nesC. 
> 
> BlinkM.nc:29 syntax error before  '&'.
> make: *** [exe0]  Error1
> 
> If generated value(val) is less than 1.0 the red led must toggle.
> Is the all bitwise operators used below works with nesC? Please give me 
> a reply.
> 
> ....................................................................................Code..........................
> module BlinkM {
>   provides {
>     interface StdControl;
>   }
>   uses {
>     interface Timer;
>     interface Leds;
>   }
> }
> implementation {
> 
>     long val,tn;
>     long idum=21;
>     long p=0.5;
>    
>    
>     command result_t StdControl.init() {
>     call Leds.init();
>     return SUCCESS;
>   }
> command result_t StdControl.start() {
>     // Start a repeating timer that fires every 1000ms
>     return call Timer.start(TIMER_REPEAT, 1000);
>   }
> command result_t StdControl.stop() {
>     return call Timer.stop();
>   }
> 
> double ran0(long &idum)
> {
>     const int a=16807,m=2147483647,q=127773;
>     const int r=2836,MASK=123459876;
>     const double am=1./m;
>     long k;
>     double ans;
> 
>     idum^=MASK;
>     k=(idum)/q;
>     idum=a*(idum-k*q)-r*k;
> 
>     if(idum<0)
>         idum+=m;
>     ans=am*(idum);
>     idum^=MASK;
>     return ans;
> }
> 
> event result_t Timer.fired()
>   {
>     double i=1.0;
>         val=ran0(idum);
>     tn=p/(1-p*(val/(1/p)));
>     if(val<i)
>     call Leds.redToggle();
>    
>     return SUCCESS;
>   }
>  
> }
> 
> Thanks
> Lakshmi
> 
> ----- Original Message ----
> From: Michael Schippling <[EMAIL PROTECTED]>
> To: Lakshmi Pradeep <[EMAIL PROTECTED]>
> Cc: tinyos-help@millennium.berkeley.edu
> Sent: Wednesday, May 28, 2008 1:16:39 AM
> Subject: Re: [Tinyos-help] (no subject)
> 
> All that should work just like good old C...
> Do you have specific problems that we can argue about?
> MS
> 
> 
> Lakshmi Pradeep wrote:
>  > Hi
>  >              I have some doubts regarding the use of pointers in
>  > nesC.Can we use a simple C function like    double rand(long &idum)  in
>  > nesC? What are bitwise operators used in nesC? Please reply.
>  > Thanks
>  > Lakshmi
>  >
>  >
>  > ------------------------------------------------------------------------
>  >
>  > _______________________________________________
>  > Tinyos-help mailing list
>  > Tinyos-help@millennium.berkeley.edu 
> <mailto:Tinyos-help@millennium.berkeley.edu>
>  > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> 
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to