CC2420 radio chip records RSSIs as negative numbers in 2's complement format. Since CC2420Packet.getRssi() returns signed int, it doesn't need to do anything else. However, since the read interface of CC2420Control returns unsigned int, it cannot just cast.
Mike On Mar 23, 2010, at 11:21 PM, wx li wrote: > Hi, Mike. > Thanks for your help!! > Do you means that : in ram, the rssi value is stored as a negative number. ( > which CC2420Packet returns) > However, in the register, the rssi value is > stored as a positive number(which CC2420Control returns) > I don't know whether my understanding is correct. > Besides, I'm curious about how the rssi value is stored in the register. > > Thanks > Nathan > > > On Wed, Mar 24, 2010 at 2:17 AM, Chieh-Jan (Mike) Liang <[email protected]> > wrote: > Here is my understanding. The RSSI returned by CC2420 is a negative number. > Since CC2420Control returns an unsigned number, it needs to translate the raw > RSSI to a positive number. On the other hand, CC2420Packet returns a signed > number, so it can just return. > > Mike > > On Mar 23, 2010, at 4:36 AM, wx li wrote: > > > hi,guys. > > I am trying to access the hardware noise floor with tinyos-2.x > > I am confused about the code in Module "CC2420ControlP.nc" > > > > event void RssiResource.granted() { > > uint16_t data; > > call CSN.clr(); > > call RSSI.read(&data); > > call CSN.set(); > > > > call RssiResource.release(); > > data += 0x7f; > > data &= 0x00ff; > > signal ReadRssi.readDone(SUCCESS, data); > > } > > > > Here, i don't know why the var data should be added by 0x7F > > And, in Module "CC2420PacketC.nc" > > > > async command int8_t CC2420Packet.getRssi( message_t* p_msg ) { > > return (call CC2420PacketBody.getMetadata( p_msg ))->rssi; > > } > > > > Here, it just read the rssi value in metadata, and do not plus 0x7f > > I've been searching for the answer for a couple of hours. But without luck > > yet.. > > Thank you for all your help! > > > > Regard, > > Nathan > > 3.23.2010 > > > > _______________________________________________ > > Tinyos-help mailing list > > [email protected] > > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
