+ rf_asksin_task(void)
+ {
+@@ -77,18 +108,51 @@
+ uint8_t dec[MAX_ASKSIN_MSG];
+ uint8_t rssi;
+ uint8_t l;
++ uint8_t rxfifo_cnt;
++ uint16_t timeout;
+
+ if(!asksin_on)
+ return;
+
+- // see if a CRC OK pkt has been arrived
+- if (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) {
++ // see if there is data to be read
++ while (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) {
++ rxfifo_cnt = read_cc1100_rxbytes();
+
++ if (rxfifo_cnt & 0x80) // Overflow
++ break;
++
++ rxfifo_cnt &= 0x7f;
++
+ enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len
++ rxfifo_cnt--;
+
+- if (enc[0]>=MAX_ASKSIN_MSG)
+- enc[0] = MAX_ASKSIN_MSG-1;
+-
++ if (enc[0] >= MAX_ASKSIN_MSG) {
++ // Something went horribly wrong, out of sync?
++ rf_asksin_reset_rx();
++ return;
++ }
++
++ if ((enc[0] + 2) > rxfifo_cnt) {
++ timeout = RX_TIMEOUT_MS * ((enc[0] + 2) - rxfifo_cnt);
++ while (timeout-- && ((enc[0] + 2) > rxfifo_cnt)) { // Wait for more data
++ my_delay_ms(1);
++ rxfifo_cnt = read_cc1100_rxbytes();
++
++ if (rxfifo_cnt & 0x80) { // Overflow
++ rf_asksin_reset_rx();
++ return;
++ }
++
++ rxfifo_cnt &= 0x7f;
++ }
++
++ if (!timeout) {
++ // Not enough data received, out of sync?
++ rf_asksin_reset_rx();
++ return;
++ }
++ }
++
+ CC1100_ASSERT;
+ cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO );
+
+@@ -97,14 +161,19 @@