Index: Scanner/Sources/EipApm_Functions.c =================================================================== --- Scanner/Sources/EipApm_Functions.c (revision 111205) +++ Scanner/Sources/EipApm_Functions.c (working copy) @@ -285,9 +285,7 @@ uint32_t ulCnt = 0; ALIGN4_HIL_BUSSCAN_REQ_T* ptBusScanReq = (ALIGN4_HIL_BUSSCAN_REQ_T*) ptHdr; ALIGN4_HIL_BUSSCAN_CNF_T* ptBusScanCnf = (ALIGN4_HIL_BUSSCAN_CNF_T*) ptHdr; - uint8_t *pabDeviceList = &ptBusScanCnf->tData.abDeviceList[0]; /* We can detect up to 64 x 8 = 512 devices in the network */ - ptBusScanCnf->tHead.ulSta = Eip_BusScan_BusScanReq( ptLocRsc->hBusScan, ptBusScanReq->tData.ulAction, &ptBusScanCnf->tData.ulMaxProgress, @@ -294,25 +292,28 @@ &ptBusScanCnf->tData.ulActProgress, &ulNumOfDevices ); - if (ulNumOfDevices > 512) + if (ulNumOfDevices > sizeof(ptBusScanCnf->tData.abDeviceList)*8) { - ulNumOfDevices = 512; + ulNumOfDevices = sizeof(ptBusScanCnf->tData.abDeviceList)/8; } - memset(pabDeviceList, 0, 64); - if( SUCCESS_HIL_OK == ptHdr->ulSta ) { + uint8_t *pabDeviceList = &ptBusScanCnf->tData.abDeviceList[0]; + + /* 4 bytes (32 slaves) default size plus what we additionally need */ + ptHdr->ulLen = HIL_BUSSCAN_CNF_SIZE + 4; + if (ulNumOfDevices > 32) + { + ptHdr->ulLen += (ulNumOfDevices - 32 + 7) / 8; /* need further bytes, one for each 8 slaves */ + } + + memset(pabDeviceList, 0, ptHdr->ulLen - HIL_BUSSCAN_CNF_SIZE); for( ulCnt = 0; ulCnt < ulNumOfDevices; ulCnt++ ) { pabDeviceList[ulCnt / 8] |= 1 << (ulCnt % 8); assert((ulCnt / 8) < 64); } - ptHdr->ulLen = HIL_BUSSCAN_CNF_SIZE + 4; /* one DWORD of response data, sufficient for 32 slaves */ - if (ulNumOfDevices > 32) - { - ptHdr->ulLen += (ulNumOfDevices - 32 + 7) / 8; /* need further bytes, one for each 8 slaves */ - } } else {