Writing struct to flash

Hi,

I’m trying to save a Struct to flash, but I think I have typecast&pointer problems…

typedef struct
{
    u32             ReadingInterval;    // Reading interval, in 100ms Steps
    u32             BaudRateParam1;     // BaudRate Paramter 1
    u32             BaudRateParam2;     // BaudRate Paramter 2
}set_SerialParam;

I tried two methods to write and read, none of them is working…

First method :

void SaveSerialParam(u8 *devId, set_SerialParam param)
{
    adl_flhWrite( devId, 0, sizeof(param),  &param );
}

set_SerialParam GetSerialParam(u8 *devId)
{
    set_SerialParam param;
    adl_flhRead ( devId, 0, sizeof(param), &param );
    return param;
}

Any ideas where is the problem ?

thanks…

EDIT: I forgot subscribing to handle… now everthing working.

In what way, “not working”?

What happens?
What were you expecting?
What have you done to attempt to explain the difference?

What return codes do you get from the API calls?

OMG, I forgot subscribing handle after format :slight_smile:

I never checked return codes of flh_read & write… now it works…

thanks again awneil…

Ah yes - the first rule of Unmaintainable Code… :unamused:

:slight_smile:

At least you should do this in case of most OAT APIs. Could save you a lot of time later.

ret_s32 = adl_doSomething();
if ( ret_s32 != OK )
TRACE (( TRACE_LEVEL, "-something KO- ret [%d]", ret_s32 ));

Absolutely!

Note that some APIs return values >OK which indicate “success”;

Note also that some API returns <OK are not strictly failures as such; eg, WIP_BERROKINPROGRESS

no not to make the code unmaintainable :slight_smile: I have problems with trace : http://www.wavecom.com/modules/movie/scenes/forums/viewtopic.php?f=3&t=2038&p=8208#p8208

so untill I found a solution, I’m trying to use minimum TRACE’s…

That’s no excuse for not checking the return codes!