| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		msimplicio
 
 
  Joined: 18 May 2010 Posts: 3
 
  | 
		
			
				 Posted: Wed May 19, 2010 7:51 pm    Post subject: Problem when writting on persistent data | 
				     | 
			 
			
				
  | 
			 
			
				I?m having trouble managing persistent data and EEPROM<->RAM relationships. I want to store an array as persistent data. For this, I defined the following structure:
 
 
typedef struct _appData
 
{
 
	u8 length;  
 
	u8 *contents;
 
}appData
 
 
If I make:
 
 
u8 i;
 
u8* edata = emalloc(length);
 
for(i = 0 ; i < length; i++){	
 
   wb(&edata[i], i);
 
}
 
 
I do can read the bytes using ?rb(&edata[i])?. However, if I make (as suggested in the ?fake_sim.c? example):
 
 
appData *p = app_data();
 
ww (&p->contents, edata);
 
 
I am unable to read the bytes using ?rb(&p->contents[i])? afterward.
 
 
Any ideas on what is wrong?
 
 
Thank you!
 
 
BR,
 
 
Marcos | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pz Guest
 
 
 
 
 
  | 
		
			
				 Posted: Thu May 20, 2010 6:08 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| Read the pointer first, u8 * edata=rw(&p->contents); and then use rb(&edata[i]); | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		msimplicio
 
 
  Joined: 18 May 2010 Posts: 3
 
  | 
		
			
				 Posted: Wed Jun 09, 2010 12:51 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				It becomes just obvious when you say it... 
 
 
Thanks a lot for saying it!!!  
 
 
Marcos. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |