Re: FAR data lost after reset or power off.

"[email protected] [rabbit-semi]" <[email protected]> 04 Aug 2015 21:01:12 -0700
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
Thx for the information.  I think I was able to allocate enough memory but now I am not sure how to initialize the allocated memory.  Does anyone know how to initialize at startup. Any help would be very much appreciated. Thx. 


typedef struct
{
   unsigned int ID;
   long * start;   //4 byte to identify starting address of the database
   long * stop;   //4 byte to identify stop address of the database
}MemBlockMarker_t;


void main()
{
    MemBlockMarker_t MemBlockMarker[4];
   long tempsz;
   static far MemBlockMarker_t * Ptr_MemBlockMarker;

   tempsz = sizeof(Member_t);


   tempsz = (MAX_MEMBERS * sizeof(Member_t) + 8);
   printf("\n Total Desired allocate byte = %ld \n",tempsz);
   printf("\nBefore xAvail reports (Member) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));
   PtrToFamilyMemberFile = (far Member_t *) _xalloc(&tempsz, 0, XALLOC_BB);
   printf("\nAfter xAvail reports (Member) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));

   //===========================================================================
   tempsz = (MAX_NODE * 5 * sizeof(Node_t) + 8);
   printf("\n Total Desired allocate byte = %ld \n",tempsz);
   printf("\nBefore xAvail reports (Node) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));
   PtrToNodeFile = (far Node_t *) _xalloc(&tempsz, 0, XALLOC_BB);
   printf("\nAfter xAvail reports (Node) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));
   
   //===========================================================================
   tempsz = (DS_MAX * sizeof(din_t) + 8);
   printf("\n Total Desired allocate byte = %ld \n",tempsz);
   printf("\nxBefore Avail reports (Digital) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));
   PtrToDigitalSensorFile = (far din_t *) _xalloc(&tempsz, 0, XALLOC_BB);
   printf("\nAfter xAvail reports (Digital) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));
   
   //===========================================================================
   tempsz = (AS_MAX * sizeof(ain_t) + 8);
   printf("\n Total Desired allocate byte = %ld \n",tempsz);
   printf("\nBefore xAvail reports (Analog) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));
   PtrToAnalogSensorFile = (far ain_t *) _xalloc(&tempsz, 0, XALLOC_BB);
   printf("\nAfter xAvail reports (Analog) = %ld free\n", _xavail(NULL, 0, XALLOC_BB));

}


RESULT........................
                                                                                
 Total Desired allocate byte = 6194                                             
                                                                                
Before xAvail reports (Member) = 450544 free                                    
                                                                                
After xAvail reports (Member) = 450544 free                                     
                                                                                
 Total Desired allocate byte = 18220                                            
                                                                                
Before xAvail reports (Node) = 450544 free                                      
                                                                                
After xAvail reports (Node) = 432324 free                                       
                                                                                
 Total Desired allocate byte = 464                                              
                                                                                
xBefore Avail reports (Digital) = 432324 free                                   
                                                                                
After xAvail reports (Digital) = 432324 free                                    
                                                                                
 Total Desired allocate byte = 376                                              
                                                                                
Before xAvail reports (Analog) = 432324 free                                    
                                                                                
After xAvail reports (Analog) = 432324 free