       if ( ( iq_spistat & 0xC0 ) == 0x40 )
       {                                   // data ready in bufferCOM of TR module
         Clear_IQRF_SPI_TxBuf();
-        iq_DLEN = iq_spistat & 0x3F;    // clear bit 7,6 - rest is length
+        iq_DLEN = iq_spistat & 0x3F;      // clear bit 7,6 - rest is length
+		if ( iq_spistat == 0x40 ) iq_DLEN = 64;
         iq_PTYPE = iq_DLEN;
         IQRF_SPI_TxBuf[0] = TR_CMD_WR_RD;
         IQRF_SPI_TxBuf[1] = iq_PTYPE;

byte IQRF_SPI_RxBuf[IQRF_SPI_BUFFER_SIZE];
byte IQRF_SPI_Busy, iq_DLEN, iq_PTYPE, iq_spistat, IQRF_SPI_Task_Message;
byte tmp_cnt, iq_pac_len, Check_Status_Timer;
// pins used for the connection with the module
// the other you need are controlled by the SPI library):
const int chipSelectPin = 10;

/* 
 * Copyright 2015 MICRORISC s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
Example for SPI communication ARDUINO <> IQRF module
Arduino = SPI master
