-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand resource object query options #293
Comments
@jphickey Could you review/comment? |
There are a few issues with the specifics of this proposal. FM should first use I'm not convinced that OSAL needs a different callback signature that directly includes the name of the object since this info can be easily obtained after the fact with a follow-on query. Furthermore, including this introduces a race condition, as a direct string pointer to the internal object should never be accessed while "unlocked". The main thing that is missing here is just that Another worthwhile addition for OSAL might be a generic API (i.e. not type-specific) to obtain the name of any resource/object ID. As every OSAL resource has a name associated with it, stored in the "common" table, this is possible and simple to do. |
My motivation for recommending a new function is that OS_ForEachObject() requires the caller to pass in a creator_id. FM is reporting on all of the open files regardless of who created/opened the file. Once I thought a new function would help descoping the function seemed prudent. I agree with the use of OS_FDGetInfo(). I overlooked this function. |
Note that the creator ID can be passed as 0, which disables filtering by creator, allowing all items to be returned. |
I've pasted a File Manager solution below that uses the existing OSAL API. The only remaining question is whether looping over all object types is acceptable. Additional documentation would also be helpful but 6.7.1 is a pre-release and I rushed over some details when I first looked into updating FM.
|
I don't think we should close this - I do think it is worthwhile to add a new "foreach" style API that only does a single resource type, because although the proposed change to FM does work and should be ok "for now" - it is not particularly efficient. A fairly easy API addition can make it more correct. |
This issue (and the related FM issue) came up again in testing, so its probably worthwhile to address it now. |
I agree it shouldn't be closed. don't recall intentionally closing it, but it might have been a late night. |
Implement OS_GetResourceName, OS_ForEachObjectByType
Implement OS_GetResourceName, OS_ForEachObjectByType
Fix #293, Expand API for object queries
While integrating File Manager app 2.5.2 with cFE 6.7.1 (OSAL 5.0.1) I ran into an issue. FM has a
command that allows users to receive a telemetry packt listing all of the open files. In order to do this FM needs to be able to query OSAL's file stream resource objects. The current implementation only allows a creator to query all of the resources objects by using OS_ForEachObject(). I think having a more general query feature would be helpful. I added a new function OS_QueryObjectType() that allows anyone (not restricted to the creator) to query a resource type. The specific OSAL changes are below followed by the FM code that uses the function. These changes were made for OpenStaKit 2.1 that can be found at https://github.com/OpenSatKit/OpenSatKit.
osapi-os-core.h:
/*
** Typedef for object query OSAL callback functions. A query does not
** have to be performed by the object creator. All fields of the
** query_record are completed.
**
** This may be used by multiple APIs
*/
typedef struct
{
const char *name_entry;
uint32 creator;
uint16 refcount;
} OS_query_record_t;
typedef void (*OS_ObjQueryCallback_t)(OS_query_record_t *query_rec, void *callback_arg); //dcm - Added for OSK
/-------------------------------------------------------------------------------------/
/**
*/
uint32 OS_QueryObjectType (uint32 obj_type, OS_ObjQueryCallback_t callback_ptr, OS_query_record_t *query_rec, void *callback_arg); // dcm - Added for OSK
osapi-idmap.c:
/*----------------------------------------------------------------
*
-----------------------------------------------------------------/
uint32 OS_QueryObjectType (uint32 obj_type, OS_ObjQueryCallback_t callback_ptr, OS_query_record_t *query_rec, void *callback_arg)
{
return active_obj_cnt;
} /* End OS_QueryObjectType() */
fm_cmd_utils.c:
static uint32 open_file_cnt = 0;
static void LoadOpenFileData(OS_query_record_t *query_rec, void *callback_arg)
{
} /* End LoadOpenFileData() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/ /
/ FM utility function -- get open files data /
/ /
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
uint32 FM_GetOpenFilesData(FM_OpenFilesEntry_t *OpenFilesData)
{
} /* End FM_GetOpenFilesData */
The text was updated successfully, but these errors were encountered: