I don't think the following processing is correct. Since the rssi_raw  
is already a signed 16-bit integer, you should just do:

rssi_raw = rssi_raw - 45

Zhiyi

 >>    if (rssi_raw > 0x80)
 >>      rssi_raw = rssi_raw - 256 - 45;
 >>    else
 >>      rssi_raw = rssi_raw - 45;



Yes, I now,
If you check this test applications:
apps/tests/cc2420/RssiToSerial/
apps/tutorials/RssiDemo/

The raw value is a 8 bit in fact.
But when you try to convert it, you get an value with 8 bits with
signal. Then you need one more bit, so we use 16bit.
That why I and everybody use a cast to 16bit, this way never lose data.

You still can translate the rssi outside the node's code. It's up to  
you.

Miguel Silva

2009/8/17 Matteo Dany <[email protected]>:
 > Ok, you translate the rssi inside the program installed on mote.
 >
 > But, why you cast a 16 bit the rssi? The function getRssi return a 8
 > bit with platform tmote.
 >
 > Thanks
 >
 > 2009/8/17 Miguel Torres <[email protected]>:
 >> Hi Matteo Dany,
 >>
 >> You only need to make this. For CC2420 and RF230.
 >>
 >> #if defined(PLATFORM_TELOSB) || defined(PLATFORM_TMOTE)
 >>  int16_t getRssi(message_t *msg){
 >>    int16_t rssi_raw = (int16_t) call CC2420Packet.getRssi(msg);
 >>    if (rssi_raw > 0x80)
 >>      rssi_raw = rssi_raw - 256 - 45;
 >>    else
 >>      rssi_raw = rssi_raw - 45;
 >>    return (int16_t) rssi_raw;
 >>  }
 >> #elif defined(PLATFORM_IRIS)
 >>  int16_t getRssi(message_t *msg){
 >>    if(call PacketField.isSet(msg))
 >>      return (int16_t) call PacketField.get(msg);
 >>    else
 >>      return 0xFFFF;
 >>  }
 >> #else
 >>  #error Radio chip not supported! Currently only works for motes  
with
 >> CC2420 or RF230 radios.
 >> #endif
 >>
 >> Best regards,
 >> Miguel Silva
 >>
 >> ---------- Mensagem reencaminhada ----------
 >> From: Mehmet Akif Antepli <[email protected]>
 >> To: Matteo Dany <[email protected]>
 >> Date: Sun, 16 Aug 2009 02:50:11 -0700
 >> Subject: Re: [Tinyos-help] Help- Rssi and field group id
 >> Yes, that's correct.
 >>
 >> On Sun, Aug 16, 2009 at 2:43 AM, Matteo Dany  
<[email protected]> wrote:
 >>
 >>    Thanks,
 >>
 >>    I should understand, I read the rssi from a serial packet  with  
an
 >>    program write in C.
 >>    I put the rssi in a char and subtract -45.
 >>    It's right?
 >>
 >>    Thanks
 >>
 >>    2009/8/16 Mehmet Akif Antepli <[email protected]>:
 >>    > Hi Matteo,
 >>    > You should interpret rssi reading as signed 8 bit value in 2's
 >> complement
 >>    > form.
 >>    > (From Page 64 of 87: CC2420 datasheet)
 >>    > "RSSI (0x13) - RSSI and CCA Status and Control Register" part
 >>    > On Sun, Aug 16, 2009 at 1:09 AM, Matteo Dany
 >> <[email protected]> wrote:
 >>    >>
 >>    >> Hi guys,
 >>    >>
 >>    >> I have a tmote sky and I search to read a Rssi, but I have  
little
 >>    >> problem with convert Rssi .
 >>    >> I read correctly the Rssi from radio message and the value  
appears in
 >>    >> a range  0, 255. But how convert the value in dbm?
 >>    >> I search in google and I read the CC2420 datasheet, they  
suggest to
 >>    >> subtract -45 to the value found.
 >>    >> When I found 255 - 45 = 210 dbm? I read in the datasheet  
that the
 >>    >> range is from 0 to -100 dbm.
 >>    >> Where I wrong?
 >>    >>
 >>    >>
 >>    >> Thank you very much
 >>    >>
 >>    >> Matt
 >>    >> _______________________________________________
 >>    >> Tinyos-help mailing list
 >>    >> [email protected]
 >>    >>
 >> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
 >>    >
 >>    >
 >>    >
 >>    > --
 >>    > Mehmet Akif Antepli
 >>    > Grad. Student
 >>    > Dept. of EEE
 >>    > Middle East Technical University
 >>    >
 >>
 >> --
 >> Miguel Torres Silva
 >>
 >



-- 
Miguel Torres Silva


_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to