Example #1
0
void adl_main(adl_InitType_e initType) {
    s8 flashHandle = -1;
    u8 counter = 1;

    flashHandle = adl_flhSubscribe(PERSISTENT_COUNTER, 1);
    if (adl_flhExist(PERSISTENT_COUNTER, 0) == 0) {
        adl_flhWrite(PERSISTENT_COUNTER, 0, sizeof(counter), &counter);
    } else {
        adl_flhRead(PERSISTENT_COUNTER, 0, sizeof(counter), &counter);
        counter++;
        adl_flhWrite(PERSISTENT_COUNTER, 0, sizeof(counter), &counter);
    }

    if (initType == ADL_INIT_REBOOT_FROM_EXCEPTION) {
        wm_sprintf(ltsc_Temp, "\r\nA Fatal Error Occurred Test is restarting (%d)", counter);
        adl_atSendResponse(ADL_AT_UNS, ltsc_Temp);
    } else {
        wm_sprintf(ltsc_Temp, "\r\nTest modbus starting(%d) in 15s...'%d'", counter, initType);
        adl_atSendResponse(ADL_AT_UNS, ltsc_Temp);
    }

    UART_Init();

    // The application will switch the UART to data mode n seconds later, so the user has 15s to enter
    adl_tmrSubscribe(FALSE, 150, ADL_TMR_TYPE_100MS, MAIN_StartAppTimerHandler);
}
Example #2
0
/** @brief Calls the adl_flhWrite function on the provided handle
 *
 * @par description: Calls the adl_flhWrite function on the provided handle at the specified ID. The data in o_Data is the data to be written
 *
 * @param i_Handle
 * @param i_Id
 * @param i_Length
 * @param i_Data
 * @return < 0 on failure
 * @return >= 0 on Success
 */
s8 FlashWrite(char const *const i_Handle, u16 i_Id, u16 i_Length, u8 const *const i_Data)
{
	s8 RetCode = 0;

	TRACE((1, "FlashWrite %d", i_Length));

	RetCode = adl_flhWrite((char *)i_Handle, i_Id, i_Length, (u8 *)i_Data);
	//wm_sprintf(g_traceBuf, "\r\nRetCode from adl_flhWrite: %d\r\n", RetCode);
	//DumpMessage(g_traceBuf);
	if (RetCode >= 0)
	{
		TRACE((1, "Successfully wrote to the flash"));
	}
	else
	{
		DisplayErrorCode("adl_flhWrite", __FILE__, __LINE__ - 8, RetCode);
	}

	return RetCode;
}