Hi,

I have a piece of code which perfectly works on C ,but when
I try to adapt it on nesC everything collapse.

So imagine that I have a task called updateMyCost which calls
an internal function findNewSubset at some point and amongst all
passes &nstEffectiveSubsetSize as an argument.
As in the function findNewSubset,I have this line :

*newNeighborSubsetEffectiveSubsetSize=counter;

I expect that when fuction findNewSubset returns ,in task
updateMyCost the value of  nstEffectiveSubsetSize be equal to the
value of counter variable in   findNewSubset.
but the return value is always equal to zero!!!!!


Any thoughts?
Thanks,
Regards,
B.


  task void updateMyCost()
        {
                uint8_t i;
                uint32_t minSubsetCost,effectiveNumberOfNeighbors;
                minSubsetCost=0xFFFFFFFF;
                countNumberOfNeighbors(&effectiveNumberOfNeighbors);

                {
                        uint32_t neighborTableMask[effectiveNumberOfNeighbors];
                        {
                                neighbor_table_entry_t nstsubset[CRS_MAX_SIZE];
                                uint32_t nstEffectiveSubsetSize;
                                nstEffectiveSubsetSize=0;
                                
creatMask(neighborTableMask,effectiveNumberOfNeighbors);
                                
next(neighborTableMask,effectiveNumberOfNeighbors);

                                  
findNewSubset(neighborTableMask,NeighborTable,effectiveNumberOfNeighbors,nstsubset,&nstEffectiveSubsetSize);
                                foundEffectiveSubsetSize=nstEffectiveSubsetSize;


                                .
                                 .
                                 .
                                 .



                        }

                }

                 void findNewSubset(uint32_t  
mask[],neighbor_table_entry_t givenSet[],uint32_t  
effectiveSizeOfGivenSet,neighbor_table_entry_t*  
newNeighborSubset,uint32_t* newNeighborSubsetEffectiveSubsetSize)
        {
                uint32_t i,counter,idx,r,g;
                neighbor_table_entry_t temp;
                counter=0;


                for (i = 0; i <effectiveSizeOfGivenSet; ++i)
                {       if (mask[i])
                        {
                                counter=counter+1;
                        }


                }


                {
                        uint32_t result[counter];

                        if(counter<= CRS_MAX_SIZE )
                        {
                                idx=0;

                                for(i=0;i<effectiveSizeOfGivenSet;++i)
                                {

                                        if (mask[i]&&idx<counter)
                                        {
                                                result[idx]=i;
                                                idx=idx+1;
                                        }
                                }
                        }
                        for(i=0;i<counter;i++)
                        {
                                newNeighborSubset[i]=givenSet[(result[i])];
                        }
                        *newNeighborSubsetEffectiveSubsetSize=counter;
                        for(r=0;r<counter;r++)
                        {
                                for(g=r+1;g<counter;g++)
                                {
                                        
if((newNeighborSubset[r]).neighborCost>(newNeighborSubset[g]).neighborCost)
                                        {
                                                temp=newNeighborSubset[r];
                                                
newNeighborSubset[r]=newNeighborSubset[g];
                                                newNeighborSubset[g]=temp;
                                        }


                                }

                        }
                }


        }









                }

        }

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to