[Tinyos-help] how to obtain RSSI with Mica2
Michael Schippling
schip at santafe.edu
Tue Jul 3 15:17:24 PDT 2007
If by "that" you mean casting something to be a pointer: (uint8_t *)
and then dereferencing it: RSSI = *(pointer)
Sure you can do it...on most real computers you'll usually get
a BUSERR or SEGFAULT, but sometimes you'll get lucky...on our
u-controllers it'll probably just generate junk unless it just
happens to point to some valid bit of the tiny memory we have...
I just looked (shall we say, more carefully) at your advice:
>>>>> uint16_t * stren = (uint16_t *) msg->strength;
>>>>> RSSI = stren[0];
and my own mushy-brained-belief is that it's basically doing
the same thing -- treating "strength" as a pointer and then
derefing it using the array syntax. Plus I wasn't paying
attention to sizes and strength is definitely a 16 bit int,
not 8 as the original poster was trying to do.
Anyway, hopefully what I said to do actually worked right...
keep up the good work
MS
Benjamin Madore wrote:
> MS,
> I thought you could do that. I was staring at code all week and my brain had
> turned to mush.
>
> -Ben
>
> On Fri, June 29, 2007 1:16 pm, Michael Schippling said:
>> I think the original problem is this:
>> RSSI=*((uint8_t *)recv_packet->strength);
>> which is treating "strength" as a pointer and de-referencing it. What you
> want is:
>> RSSI = recv_packet->strength;
>> Then do all the arcana of converting to db which is covered in
>> these other answers...
>>
>> As to the funny-ness with ADC get and ready, the underlying
>> radio code calls the ADC0 get right after it receives a messsage. So you
> probably overloaded their ready() with yours.
>> MS
>>
>>
>> Benjamin Madore wrote:
>>> On Fri, June 29, 2007 11:43 am, Bernardo Avila Pires said:
>>>> Wasn't the value in msg->strenght some untransformed one? I remember
> having read that a function should be applied to it in order to obtain
> RSSI.
>>> Only if you want decibels or some other unit. The number given is the
> internal measurement scale, plenty useful for direct comparison.
>>>> 2007/6/29, Benjamin Madore <bcmadore at cs.pitt.edu>:
>>>>> msg->strength is uint16_t
>>>>> You're only getting half the number.
>>>>> Besides,
>>>>> uint16_t * stren = (uint16_t *) msg->strength;
>>>>> RSSI = stren[0];
>>>>> should be easier to read. I think there is an even more elegant way to
> state
>>>>> this, but I don't care enough to find it. Avoid doing multiple things
> on
>>>>> one
>>>>> line until your sure all your bugs are gone. (I.E. Never do multiple
> things
>>>>> on one line.) Let the compiler optimize.
>>>>> Your RSSI should be between 400 and 0. It is interpreted as a negative
> number, with 400 being quiet, and 0 being very loud.
>>>>> You can also wire to ADC.ADC[TOS_ADC_CC_RSSI_PORT] and call
>>>>> "ADC.getData();"
>>>>> which provides the event "ADC.dataReady(uint16_t data);" like you said.
> dataReady is singled every time anyone calls getData. The radio stack
> does
>>>>> this a lot. You have to filter out your calls. I might suggest a lock.
> When you call getData, set a boolean to true, and when you have read
> one
>>>>> value in dataReady, set it to false.
>>>>> -Ben
>>>>> On Fri, June 29, 2007 10:21 am, CASTEL Myriam said:
>>>>>> Hello,
>>>>>> I'm trying to obtain the RSSI value with Mica2 motes.
>>>>>> -I programmed a component which stores the strength of a TOSMsg
>>>>> received:
>>>>>> RSSI=*((uint8_t *)recv_packet->strength);
>>>>>> But this doesn't give reasonnable results. I think this method is only
> for the micaz? Isn't it?
>>>>>> - In the documentation, I saw that the RSSI was given by the channel 0
> in mica2.
>>>>>> I tried to sample channel 0 with in configuration file: MyApp.ADC->
> ADCC.ADC[0];
>>>>>> in module file: event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr
> recv_packet){
>>>>>> call ADC.getData();
>>>>>> return recv_packet;
>>>>>> }
>>>>>> async event result_t ADC.dataReady(uint16_t data) {
>>>>>> atomic pack->xData.datap1.value = data;
>>>>>> post sendMsg();
>>>>>> return SUCCESS;
>>>>>> }
>>>>>> but the problem is that the mote execute ADC.dataReady even if getData
> wasn't called. Maybe I have forgotten some elements as:
>>>>>> call
> ADC.Control.bindPort(TOS_ADC_CC_RSSI_PORT,TOS_ACTUAL_CC_RSSI_PORT)
>>>>>> or other things.
>>>>>> Can you help me to obtain RSSI value (with channel 0 or other)? If you
> have the code to compute RSSI, can you send it to me?
>>>>>> I'm sorry for this question but I'm new and I don't find the answers
> in
>>>>>> the documentation provided by Crossbow.
>>>>>> Thanks
>>>>> --
>>>>> The difference between the right word and the almost right word is really
>>>>> a
>>>>> large matter- it's the difference between a lightning bug and the
> lightning.
>>>>> -Twain
>>>>> _______________________________________________
>>>>> Tinyos-help mailing list
>>>>> Tinyos-help at Millennium.Berkeley.EDU
>>>>> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>>> --
>>>> "The truth shall set you free"
>>>> <a href="http://www.nerdtests.com/nq_ref.html">
>>>> <img src="http://www.nerdtests.com/images/badge/dc875a1ab1aff18f.gif"
> alt="I am nerdier than 99% of all people. Are you a nerd? Click here to
> find out!"></a>
>
>
More information about the Tinyos-help
mailing list