Quantcast
Channel: Active questions tagged autosar - Stack Overflow
Viewing all articles
Browse latest Browse all 102

How to Extend OSEK-Based OS to Support Multiple Schedule Tables for SyncScheduleTable API Implementation?

$
0
0

Question:

I am working on extending an OSEK-based OS to implement the SyncScheduleTable API as specified in AUTOSAR 4.4.0. Our current OS only supports a single schedule table, but synchronization requires managing multiple schedule tables. Below is the list of APIs supported in our existing OS for schedule table management:

Existing APIs:

  1. Os_StatusType Os_Fn_StartScheduleTableRel(Os_ScheduleTBLType ScheduleTableID, Os_Base_Type Offset);

  2. Os_StatusType Os_Fn_StartScheduleTableAbs(Os_ScheduleTBLType ScheduleTableID, Os_Base_Type Start);

  3. Os_StatusType Os_Fn_StopScheduleTable(Os_ScheduleTBLType ScheduleTableID);

  4. void Os_Fn_ScheduleTblMainFunction(void);

  5. void Os_Fn_ScheduleTblInit(void);

  6. void Os_Fn_ScheduleTblDeInit(void);

Newly Implemented APIs:

  1. Os_StatusType Os_Fn_SyncScheduleTable(ScheduleTableType ScheduleTableID, uint32_t Sync_Counter);

  2. Os_StatusType Os_Fn_GetScheduleTableStatus(ScheduleTableType ScheduleTableID, ScheduleTableStatusRefType ScheduleStatus);

  3. Os_StatusType Os_Fn_NextScheduleTable(ScheduleTableType ScheduleTableID_From, ScheduleTableType ScheduleTableID_To);

    Here is my implementation of the Os_Fn_SyncScheduleTable API:

    Os_StatusType Os_Fn_SyncScheduleTable(ScheduleTableType ScheduleTableID, uint32_t Sync_Counter){   /* Local Variables */   Os_Schedule_Tbl_Type_St* fl_SchdTbL_St;   uint32_t fl_deviation_size_u32 = 0u;   uint32_t fl_duration_size_u32 = 0u;   Os_StatusType status = E_OS_OK;   /* Check if the Schedule Table ID is valid */   if (ScheduleTableID >= MAX_SCHEDULE_TBL_ID)   {       return E_OS_ID; // Invalid Schedule Table ID   }   /* Get the schedule table object */   fl_SchdTbL_St = &OS_Core_Dynamic_st[g_Os_Current_App_Mode_u32].Schedule_Tbl_St[ScheduleTableID];   /* Ensure the schedule table is configured for synchronization */   if (fl_SchdTbL_St->Schd_Tbl_SyncType == OS_SCHT_SYNC_IMPLICIT ||       fl_SchdTbL_St->Schd_Tbl_SyncType == OS_SCHT_SYNC_NON)   {       return E_OS_ID; // Synchronization not supported or misconfigured   }   /* Ensure the schedule table is running */   if (fl_SchdTbL_St->Schd_Tbl_State == SCHEDULETABLE_STOPPED || fl_SchdTbL_St->Schd_Tbl_State == SCHEDULETABLE_NEXT)   {       return E_OS_STATE; // Schedule table is not running   }   /* Retrieve the duration of the schedule table */   fl_duration_size_u32 = fl_SchdTbL_St->Schd_Final_Delay;   /* Calculate the fl_deviation_size_u32 */   fl_deviation_size_u32 = (Sync_Counter - fl_SchdTbL_St->Schd_SysTick_Counter_Stamp) % fl_duration_size_u32;   /* Adjust fl_deviation_size_u32 to be positive */   if (fl_deviation_size_u32 < 0) {       fl_deviation_size_u32 += fl_duration_size_u32;   }   /* Check if fl_deviation_size_u32 exceeds allowed bounds */   if (fl_deviation_size_u32 > OS_COUNTER_MAX_ALLOWED_VALUE)   {       status = E_OS_VALUE; // fl_deviation_size_u32 too large   } else {       /* Update the system tick stamp for synchronization */       fl_SchdTbL_St->Schd_SysTick_Counter_Stamp = Sync_Counter % fl_duration_size_u32;       fl_SchdTbL_St->Schd_Current_Expiry_Point = fl_deviation_size_u32; // Adjust expiry point       fl_SchdTbL_St->Schd_Expiry_Point_State = SERVE_EXP_POINT_OFFSET; // Sync state   }   return status;}

    This implementation assumes that the OS can manage multiple schedule tables, but our current OS supports only one. I am trying to determine how to extend our OS to manage multiple schedule tables effectively.

    My Questions:

    1. How can I modify or extend the current OS to support multiple schedule tables for synchronization?

    2. Does my implementation of Os_Fn_SyncScheduleTable meet the AUTOSAR 4.4.0 specification requirements? If not, what improvements are needed?

    3. How do the existing APIs like Os_Fn_StartScheduleTableRel and Os_Fn_NextScheduleTable interact with the newly implemented synchronization API?


Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>