avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] pointer to program memory string


From: gouy yann
Subject: Re: [avr-gcc-list] pointer to program memory string
Date: Wed, 24 Nov 2004 16:01:12 +0100 (CET)

 --- "E. Weddington" <address@hidden> a écrit : 
> On 24 Nov 2004 at 15:39, Leo Hendrawan wrote:
> 
> > Hello all,
> > 
> > suppose i have a struct which is:
> > 
> >     struct a {
> >             char*data;      // data to be sent
> >             unsigned int datalen;
> >             char*datasrc;   // data source
> >     };
> > 
> > and i have some program memory strings:
> > 
> >     char b[] PROGMEM = {"........"};
> >     char c[] PROGMEM = {"............."};
> > 
> > then could point the datasrc above to these
> program memory strings like
> > this:
> > 
> >     a->data = &buffer[0];   // point to the data buffer
> to be sent
> > 
> >     a->datasrc = &b[0]; (or) a->datasrc = &c[0];
> > 
> >     a->datalen = strlen_P(datasrc);
> > 
> >     for(i=0 ; i<(a->datalen-1) ; i++)
> >     {
> >             a->data[i]=PRG_RDB(a->datasrc[i]);
> >     }
> > 
> > i have tried this once but it doesn't work.
> > any suggestion?
> > 
> 
> 
> for(i=0 ; i<(a->datalen-1) ; i++)
> {
>       a->data[i]=PRG_RDB(a->datasrc + i);
> }
> 

memcpy_P(a->data, a->datasrc, a->datalen-1) seems to
fit the need without considering the problem of the
PRG_RDB depreciated macro.



=====



        

        
                
Vous manquez d’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis. A télécharger gratuitement sur 
http://fr.messenger.yahoo.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]