Untitled
unknown
c_cpp
a year ago
1.3 kB
2
Indexable
Never
case AMCOM_FOOD_UPDATE_REQUEST: printf("Got FOOD_UPDATE.request. \n"); //printf("%d \n\n",sizeof(packet->payload)); int tabNumber=0; int foodCount=0; for(int i=0;i<packet->header.length/11;i++) { foodCount=packet->payload[0+i*11]; foodCount=foodCount|((packet->payload[1+i*11])<<8); //printf("%d foodCount \n",foodCount); if(foodCount+1>foodNumber) { foodNumber=foodCount+1; // printf("%d foodnumber \n",foodnumber); } tabNumber=floor(((float)foodCount)/AMCOM_MAX_FOOD_UPDATES); //printf("%d tabinfood \n",tabNumber); foodUpdate[tabNumber].foodState[foodCount%AMCOM_MAX_FOOD_UPDATES].foodNo=foodCount; foodUpdate[tabNumber].foodState[foodCount%AMCOM_MAX_FOOD_UPDATES].state=packet->payload[2+i*11]; printf("%d nr ", foodCount); printf("%d foodstate \n",foodUpdate[tabNumber].foodState[foodCount%AMCOM_MAX_FOOD_UPDATES].state); foodUpdate[tabNumber].foodState[foodCount%AMCOM_MAX_FOOD_UPDATES].x= readMultipleFloat(packet,3+i*11); foodUpdate[tabNumber].foodState[foodCount%AMCOM_MAX_FOOD_UPDATES].y= readMultipleFloat(packet,7+i*11); } break;