[Tinyos-help] Conversion of Telos B RSSI

Paul David Kavan pkavan1 at bigred.unl.edu
Fri Jun 2 09:55:01 PDT 2006


To All:

Thanks to those who helped me get the RSSI sent over the serial port.  
I am using the Telos B motes and doing some RSSI experiments. I am in  
the process of modifying the serial forwarder some so that it will  
convert the RSSI value I receive over the serial port to the actual  
RSSI value. In the sflisten.c file, I have added the following code  
to do this conversion before displaying it on the monitor:

const unsigned char *packet = read_sf_packet(fd, &len);
		
		/*Perform 2's complement conversion and add offset (-45 dBm)*/
		if (packet[10] < 128) //Positive Number
			adj_rssi = packet[10];
		if (packet[10] > 127) //Negative number
		{
			adj_rssi = -1*((packet[10] - 1)^(0xFF))-45;
		}
		
		if (!packet)
			exit(0);
		
		/*Display various information from the packet to monitor*/
		printf("Node ID: ");
		printf("%02x ", packet[12]);
		printf("RAW RSSI: ");
		printf("%02x ", packet[10]);
		printf("Adjusted RSSI: ");
		printf("%d ", adj_rssi);
		putchar('\n');
		fflush(stdout);
		free((void *)packet);


The way I understand it, the raw RSSI is an 8-bit unsigned integer.  
So, I have to do the two's complement conversion and add the offset.  
Then I simply parse out what I want from the packet and print it  
along with the converted RSSI to the screen. Does anyone see an  
obvious flaw in my conversion or a more compact way to do the  
conversion--aside from changing the if/if to and if/else. (I was  
coding very late last night lol)

Many thanks again for the help.

Paul

*****************************************
Paul David Kavan
pkavan1 at bigred.unl.edu
329 Walter Scott Engineering Center
University of Nebraska
402-472-2764
*****************************************




More information about the Tinyos-help mailing list