I think I've got the answer. If you look at the following code from ChannelMonC.nc
1 TOSH_SIGNAL(SIG_OUTPUT_COMPARE2
) {
2 uint8_t bit = TOSH_READ_RFM_RXD_PIN();
3 atomic { // Unnecessary, but nesC doesn't understand SIGNAL
4 //fire the bit arrived event and send up the value.
5 if (CM_state == IDLE_STATE) {
6 CM_search[0] <<= 1;
7 CM_search[0] = CM_search[0] | (bit & 0x1);
8 if(CM_waiting != -1){
9 CM_waiting --;
10 if(CM_waiting == 1){
11 if ((CM_search[0] & 0xfff) == 0) { // see if it's 12 consecutive 0's
12 CM_waiting = -1;
13 signal ChannelMon.idleDetect();
14 }else{
15 CM_waiting = (call Random.rand() & 0x1f) + 30;
16 }
17 }
18 }
19 if (( CM_search[0] & 0x777) == 0x707){ // preamble
20 CM_state = START_SYMBOL_SEARCH;
21 CM_search[0] = CM_search[1] = 0;
22 CM_startSymBits = 30;
23 }
24 }else if( CM_state == START_SYMBOL_SEARCH){
25 unsigned int current = CM_search[CM_lastBit];
26 CM_startSymBits--;
27 if (CM_startSymBits == 0){
28 CM_state = IDLE_STATE;
29 }
30 if (CM_state != IDLE_STATE) {
31 current <<= 1;
32 current &= 0x1ff; // start symbol is 9 bits
33 if(bit) current |= 0x1; // start symbol is 9 bits
34 if (current == 0x135) {
35 cbi(TIMSK, OCIE2);
36 CM_state = IDLE_STATE;
37 signal ChannelMon.startSymDetect();
38 }
39 if (CM_state != IDLE_STATE) {
40 CM_search[CM_lastBit] = current;
41 CM_lastBit ^= 1;
42 }
43 }
44 }
45 }
46 return;
47 }
The test of 12 consecutive 0's (line 11) is in the state of IDLE_STATE (line 5), but when it's really starting to receive data, it should be in the state of START_SYMBOL_SEARCH (line 24). So even when someone is sending a lot of 0's, the receiving node is in the state of START_SYMBOL_SEARCH, so the test of 12 consecutive 0's (line 11) will never be executed.
Cheers,
Haibin
2 uint8_t bit = TOSH_READ_RFM_RXD_PIN();
3 atomic { // Unnecessary, but nesC doesn't understand SIGNAL
4 //fire the bit arrived event and send up the value.
5 if (CM_state == IDLE_STATE) {
6 CM_search[0] <<= 1;
7 CM_search[0] = CM_search[0] | (bit & 0x1);
8 if(CM_waiting != -1){
9 CM_waiting --;
10 if(CM_waiting == 1){
11 if ((CM_search[0] & 0xfff) == 0) { // see if it's 12 consecutive 0's
12 CM_waiting = -1;
13 signal ChannelMon.idleDetect();
14 }else{
15 CM_waiting = (call Random.rand() & 0x1f) + 30;
16 }
17 }
18 }
19 if (( CM_search[0] & 0x777) == 0x707){ // preamble
20 CM_state = START_SYMBOL_SEARCH;
21 CM_search[0] = CM_search[1] = 0;
22 CM_startSymBits = 30;
23 }
24 }else if( CM_state == START_SYMBOL_SEARCH){
25 unsigned int current = CM_search[CM_lastBit];
26 CM_startSymBits--;
27 if (CM_startSymBits == 0){
28 CM_state = IDLE_STATE;
29 }
30 if (CM_state != IDLE_STATE) {
31 current <<= 1;
32 current &= 0x1ff; // start symbol is 9 bits
33 if(bit) current |= 0x1; // start symbol is 9 bits
34 if (current == 0x135) {
35 cbi(TIMSK, OCIE2);
36 CM_state = IDLE_STATE;
37 signal ChannelMon.startSymDetect();
38 }
39 if (CM_state != IDLE_STATE) {
40 CM_search[CM_lastBit] = current;
41 CM_lastBit ^= 1;
42 }
43 }
44 }
45 }
46 return;
47 }
The test of 12 consecutive 0's (line 11) is in the state of IDLE_STATE (line 5), but when it's really starting to receive data, it should be in the state of START_SYMBOL_SEARCH (line 24). So even when someone is sending a lot of 0's, the receiving node is in the state of START_SYMBOL_SEARCH, so the test of 12 consecutive 0's (line 11) will never be executed.
Cheers,
Haibin
On 6/7/06, Liu Haibin <[EMAIL PROTECTED]> wrote:
Hi,
I have a question on mica/ChannelMonC.nc, the implementation of the CSMA/CA on mica. The code below shows that
uint8_t bit = TOSH_READ_RFM_RXD_PIN();
CM_search[0] <<= 1;
CM_search[0] = CM_search[0] | (bit & 0x1);
if ((CM_search[0] & 0xfff) == 0) { // 12 clock ticks
CM_waiting = -1;
signal ChannelMon.idleDetect();
}
after a random delay, it checks if during the past 12 clock ticks a single 1 bit is received. If not, then it signals that channel is idle. But my question is if some node is transmitting a long sequence of 0s, then the idleness is falsely detected. Why is it so?
Regards,Haibin
_______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
