]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/rf230/RF230LayerP.nc
more LPL debugging
[tinyos-2.x.git] / tos / chips / rf230 / RF230LayerP.nc
index 4e2337bf545bfc379fc86ef08f28aa1eafc5f5eb..9788d59aff36d081801f0de554aeeed4fb8afff5 100644 (file)
@@ -472,24 +472,22 @@ implementation
                 */
                if( (length & RF230_TRX_STATUS_MASK) != RF230_BUSY_TX )
                {
-#ifdef RF230_DEBUG
-                       if( call DiagMsg.record() )
-                       {
-                               call DiagMsg.str("assert tx");
-                               call DiagMsg.uint16(call RadioAlarm.getNow());
-                               call DiagMsg.hex8(readRegister(RF230_TRX_STATUS));
-                               call DiagMsg.hex8(readRegister(RF230_TRX_STATE));
-                               call DiagMsg.hex8(radioIrq);
-                               call DiagMsg.uint8(state);
-                               call DiagMsg.uint8(cmd);
-                               call DiagMsg.send();
-                       }
-#endif
                        ASSERT( (length & RF230_TRX_STATUS_MASK) == RF230_PLL_ON );
+
+                       call PacketTimeStamp.clear(msg);
                        return FAIL;
                }
 
-               call PacketTimeStamp.set(msg, time);
+#ifdef RF230_DEBUG_MESSAGES
+               if( call DiagMsg.record() )
+               {
+                       call DiagMsg.str("tx");
+                       call DiagMsg.uint16(time);
+                       call DiagMsg.uint8(length);
+                       call DiagMsg.hex8s(data, length - 2);
+                       call DiagMsg.send();
+               }
+#endif
 
                // wait for the TRX_END interrupt
                state = STATE_BUSY_TX_2_RX_ON;
@@ -499,6 +497,7 @@ implementation
        }
 
        default tasklet_async event void RadioSend.sendDone(error_t error) { }
+       default tasklet_async event void RadioSend.ready() { }
 
 /*----------------- CCA -----------------*/
 
@@ -578,6 +577,21 @@ implementation
 
                call SELN.set();
                state = STATE_RX_ON;
+
+#ifdef RF230_DEBUG_MESSAGES
+               if( call DiagMsg.record() )
+               {
+                       length = call RF230Config.getLength(rxMsg);
+                       call DiagMsg.str("rx");
+                       call DiagMsg.uint16(call PacketTimeStamp.isSet(rxMsg) ? call PacketTimeStamp.get(rxMsg) : 0);
+                       call DiagMsg.uint16(call RadioAlarm.getNow());
+                       call DiagMsg.uint8(length);
+                       call DiagMsg.uint8(crc != 0);
+                       call DiagMsg.hex8s(call RF230Config.getPayload(rxMsg), length - 2);
+                       call DiagMsg.send();
+               }
+#endif
+               
                cmd = CMD_NONE;
 
                // signal only if it has passed the CRC check
@@ -644,7 +658,22 @@ implementation
                                        ASSERT( state == STATE_BUSY_TX_2_RX_ON );
                                }
                                else
-                                       ASSERT(FALSE);
+                               {
+#ifdef RF230_DEBUG
+//                                     ASSERT(FALSE);
+                                       if( call DiagMsg.record() )
+                                       {
+                                               call DiagMsg.str("assert pll");
+                                               call DiagMsg.uint16(call RadioAlarm.getNow());
+                                               call DiagMsg.hex8(readRegister(RF230_TRX_STATUS));
+                                               call DiagMsg.hex8(readRegister(RF230_TRX_STATE));
+                                               call DiagMsg.hex8(irq);
+                                               call DiagMsg.uint8(state);
+                                               call DiagMsg.uint8(cmd);
+                                               call DiagMsg.send();
+                                       }
+#endif
+                               }
                        }
 
                        if( irq & RF230_IRQ_RX_START )
@@ -728,7 +757,22 @@ implementation
                                        cmd = CMD_DOWNLOAD;
                                }
                                else
-                                       ASSERT(FALSE);
+                               {
+#ifdef RF230_DEBUG
+//                                     ASSERT(FALSE);
+                                       if( call DiagMsg.record() )
+                                       {
+                                               call DiagMsg.str("assert trx");
+                                               call DiagMsg.uint16(call RadioAlarm.getNow());
+                                               call DiagMsg.hex8(readRegister(RF230_TRX_STATUS));
+                                               call DiagMsg.hex8(readRegister(RF230_TRX_STATE));
+                                               call DiagMsg.hex8(irq);
+                                               call DiagMsg.uint8(state);
+                                               call DiagMsg.uint8(cmd);
+                                               call DiagMsg.send();
+                                       }
+#endif
+                               }
                        }
                }
        }