Hi,
Can anyone tell me the exact usage of A&D memory? Can it be used only for storing .dwl files before installation or can it be used to store normal data and retrieve later? I have this Qn. as i didnt find a adl_adread() command. It would be Gr8 if get sample application to get the exact size of A&D memory available and how to allocate memory, write, and read data.
I also need the steps involved in doing the same as i got the error “ADL_RET_ERR_UNKNOWN_HDL” when i tried to subscribe for the cell and write data.
Of course you can use it for normal data, the “D” means data. Limitations:
[]When you access for writing at a cell of this memory the ADL, gives you access to the end of the cell. So the best way to change something already written is: delete, recompact, create a and write.
[]Because of this kind of writing management, the most usefull ways of using it are .dwl storage and datalogging.
Yeah… This is always confusing the first time you work with A&D. You must use adl_adInfo(). In the adl_adInfo structure you have a pointer (*data) to the data stored (DO NOT USE THIS POINTER FOR WRITTING, I’ve never tried but gcc would not like that, sure!!).
First you must subscribe the cell (always, even if it has already been created), use the s32 returned by adl_adSubscribe to evaluate the subscription (check the documentation). If it’s >=0 use the returned value for cell operation (adl_adWrite, adl_adInfo…). If you do this I have never had a “ADL_RET_ERR_UNKNOWN_HDL” as response.
If you do not finalize the cell you can append data to the end of the cell with adl_adWrite command. What you can’t do is to change already written data.
There’s no NUL. The data i write are “Hello World” and “1223445445677778658668678”. But, only “Hello World” is read. But, if you see “Memory Size: 60”. It should have been only 30 if only the first write was successful.
Also, what’s the difference between writting data in flash and A&D memory? which is the better way to store and retrieve data frequently?
int adStorage_WriteMem(ascii *BufferWrMem,int BufferWrMemLenght,int CELLID)
{
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:Inside adStorage_WriteMem"));
if(CELLID>=0)
{
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:adl_adSubscribe OK"));
s32 respuesta=adl_adInfo(adStorage_SuscribeCELLHandler[CELLID],&adStorage_Info);
switch(respuesta)
{
case OK: //on success
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:adl_adInfo OK"));
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]: Espacio disponible para escribir %d",adStorage_Info.remaining));
s32 WriteAnswer;
WriteAnswer=adl_adWrite(adStorage_SuscribeCELLHandler[CELLID],BufferWrMemLenght,BufferWrMem);
TRACE((1,"Valor de WriteAnswer %d",WriteAnswer));
switch(WriteAnswer)
{
case OK: //on success
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:adStorage_WriteMem OK"));
return BufferWrMemLenght;
break;
case ADL_RET_ERR_UNKNOWN_HDL: //if the handle was not subscribed
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_UNKNOWN_HDL"));
return -1;
break;
case ADL_RET_ERR_PARAM: //on parameter error
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_PARAM"));
return -1;
break;
case ADL_RET_ERR_BAD_STATE: //if the cell is finalized
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_BAD_STATE"));
return -1;
break;
case ADL_AD_RET_ERR_OVERFLOW: //if the write operation exceeds the cell size
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_AD_RET_ERR_OVERFLOW"));
return -1;
break;
case ADL_RET_ERR_SERVICE_LOCKED: //if the function was called from a low level interrupt handler (the function is forbidden in this context)
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_SERVICE_LOCKED"));
return -1;
break;
}
return FALSE;
break;
case ADL_RET_ERR_PARAM:
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_PARAM"));
return FALSE;
break;
case ADL_RET_ERR_UNKNOWN_HDL: //if the handle was not subscribed
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_UNKNOWN_HDL"));
return FALSE;
break;
case ADL_RET_ERR_BAD_STATE: //if the required cell is a not finalized or an undefined size
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_BAD_STATE"));
return FALSE;
break;
case ADL_RET_ERR_SERVICE_LOCKED: //if the function was called from a low level interrupt handler (the function is forbidden in this context)
TRACE((1,"[wav_adStorage.c][adStorage_WriteMem]:ADL_RET_ERR_SERVICE_LOCKED"));
return FALSE;
break;
}
}
else
{
return -1;
}
return 0;
}
The read code is this.
When i read the data i read always the same thus i write in the memory and the free space is always less than before.
Thanks!!
bool adStorage_ReadMem(ascii *BufferRdMem,int CELLID)
{
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]:Inside adStorage_ReadMem"));
if(CELLID>=0)
{
TRACE((1,"[wav_adStorage.c][adStorage_SuscribeCELLHandler]:sadl_adSubscribe OK"));
s32 respuesta=adl_adInfo(adStorage_SuscribeCELLHandler[CELLID],&adStorage_Info);
switch(respuesta)
{
case OK: //on success
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]:adl_adInfo OK"));
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]: Espacio disponible para escribir %d",adStorage_Info.remaining));
ascii datoaux[200];
BufferRdMem= (ascii*)(adStorage_Info.data);
TRACE((1,BufferRdMem));
return TRUE;
break;
case ADL_RET_ERR_PARAM:
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]:ADL_RET_ERR_PARAM"));
return FALSE;
break;
case ADL_RET_ERR_UNKNOWN_HDL: //if the handle was not subscribed
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]:ADL_RET_ERR_UNKNOWN_HDL"));
return FALSE;
break;
case ADL_RET_ERR_BAD_STATE: //if the required cell is a not finalized or an undefined size
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]:ADL_RET_ERR_BAD_STATE"));
return FALSE;
break;
case ADL_RET_ERR_SERVICE_LOCKED: //if the function was called from a low level interrupt handler (the function is forbidden in this context)
TRACE((1,"[wav_adStorage.c][adStorage_ReadMem]:ADL_RET_ERR_SERVICE_LOCKED"));
return FALSE;
break;
}
}
return FALSE;
}