How to Read AD Memory


#1

Hi :
I am writing a string to the A&D memory and trying to read it back. below is my code and why do I read all FFFF back instead of the string I wrote in A&D. The adl_adWrite is successful with the same CellID.

int8_t read_AND(uint32_t CellID, uint32_t Size, ascii * pData )
{
int8_t retVal = 0;
int32_t cellHandle = -1;
int32_t adSize;
uint8_t * Buffer;

/* Subscribe to the cell */
cellHandle = adl_adSubscribe (CellID, Size);
if(cellHandle < 0){
	TRACE((1,"AnD subscription failed %d\r\n", cellHandle));
    return (retVal = ERROR);
}

adSize = adl_adInfo(cellHandle, &info );
if (info.size < 0){
	TRACE((1,"AnD get info fail %d\r\n", cellHandle));
	return (retVal = ERROR);
}
Buffer = (uint8_t *) adl_memGet( info.size + 1 );
if ( NULL == Buffer ){
    TRACE((1,"\r\n Memory allocation failure \r\n"));
    return (retVal = ERROR);
}
wm_memset(Buffer, 0x00, (info.size+1));
wm_memcpy(Buffer, info.data, info.size);
DUMP(1, Buffer, 32);

/* Unsubscribe */
adl_adUnsubscribe (cellHandle);
return retVal;

}


#2

Hi
I tried using your code with the following changes and i was succesfully able to read from the A&D memory.
{
pdata=adl_memGet(Info.size+1);
wm_memset((void*) pdata,0x00, (Info.size+1));
wm_memcpy((void*) pdata, (void*)(Info.data),Info.size);
adl_atSendResponse(ADL_PORT_UART1,(void *)pdata);
TRACE((1,“Dumping the value”));
DUMP(1,pdata,32);
}
Please see that i had declared pdata as ascii.

Regards
Paruthiv


#3

What’s the declaration of “info”? I hope you’re not passing a pointer to a pointer…

Also what “CellID” and “Size” are you using in the parameters?


#4

Hi
info is of the type adl_adInfo_t struct which gives brief structure of cell informations.
Further i have made use of ptr to access mem loc of cell provided during write operation.

Regards
paruthiv