From: Lionel T. (Boulot) <lio...@di...> - 2007-06-12 12:10:59
|
Renier Morales a écrit : > The function's purpose is to give the plugin a chance to generate > events. In the simulator's case, it doesn't generate any events except > for the ones created during discovery. > The reason I told you to put your code (e.g. switch case generating > failed resource event) in get_event was to make it easier for you to > see it as you would only have had to run hpievents to do that. As requested, i put the generation of the failed resource event into get_event() but it segfault now ... Since you need to have a pointer on the ressource to generate the event, i put it into the global variable VG_rpt from get_sensor_reading() and set the VG_EVENT flag to 1 to tell get_event() to generate the event. The example below will explain you how it's coded. extern int VG_EVENT; extern SaHpiRptEntryT *VG_rpt; SaErrorT sim_get_event(void *hnd, struct oh_event *event, struct timeval *timeout ) { struct oh_event *e = NULL; if (!hnd) return SA_ERR_HPI_INVALID_PARAMS; if (VG_EVENT) { VG_EVENT = 0; e = (struct oh_event *)malloc(sizeof(*e)); if (!e) { dbg("unable to allocate event"); return SA_ERR_HPI_OUT_OF_SPACE; } memset(e, '\0', sizeof(struct oh_event)); e->resource = *VG_rpt; e->event.Severity = e->resource.ResourceSeverity; e->event.Source = e->resource.ResourceId; e->event.EventType = SAHPI_ET_RESOURCE; e->event.EventDataUnion.ResourceEvent.ResourceEventType = SAHPI_RESE_RESOURCE_FAILURE; oh_gettimeofday(&e->event.Timestamp); *event = *e; //g_free(e); printf("** evenement envoye ....\n"); return 1; } But, in the actual state of art, the simulator plugin cannot generate events at all since the get_event function do nothing. The prototype function is even not complete. SaErrorT sim_get_event(void *hnd) { if (!hnd) return SA_ERR_HPI_INVALID_PARAMS; return SA_OK; } > The code you modified had been commented out because eventq is not > supposed to be used that way anymore. That's how it's describes from the actual documentation ... How openhpi can pull events from plugins if the get_event function cannot be used in that way ? > Did you try running both hpievents and hpitree in the way I said > before? or tried running hpiel? Yes, i tried it both without correct results. Lionel Tricon |