Hello,
The openhpi daemon is crashing when trying to get the sensor reading on
a sensor which is not supporting the reading (IsSupported is set to
False).
This problem is observed with OA SOAP plugin. We are implementing new
set of operational sensors whose reading is not supported.
According the SAF HPI spec B.02 section 7.2.5, if the sensor does not
support reading, then saHpiSensorReadingGet() should set the IsSupported
field in the 'Reading' structure to 'False' (2nd para in Remarks). This
means that saHpiSensorReadingGet() API is not setting (changing) the
other fields of 'Reading' structure by openhpi plugin. The other fields
are important only if the IsSupported is set to 'True'.
The marshalling code (marshal.c:477) is asserting when it is trying to
marshal the 1st out parameter (SAHPI_INOUT SaHpiSensorReadingT *Reading)
of SAF API saHpiSensorReadingGet.
The SaHpiSensorReadingT structure has 3 fields.
typedef struct {
SaHpiBoolT IsSupported;
SaHpiSensorReadingTypeT Type;
SaHpiSensorReadingUnionT Value;
} SaHpiSensorReadingT;
If I'm wrong in understanding the marshalling, please correct me.
The assertion is happening when marshalling tried on 3rd field
(SaHpiSensorReadingUnionT Value) of SaHpiSensorReadingT structure. When
IsSupported is set to False, the 'Type' and 'Value' are not set. These
fields will have some junk data. When marshal tries to marshal union and
it is not able to find the correct value. Hence, marshal code asserts.
This is a limitation in marshalling code. It expects all the fields of a
return structure to have proper values.
POSSIBLE WORKAROUND:
---------------------
1. The plugin should set 'Type' and 'Value' fields of the 'Reading'
structure to some value (can be memset) even when IsSupported is set to
'False'.
All the plugins needs to (which supports sensor without reading support)
implement this approach
2. Set all fields of the Reading structure to zero (using memset) before
calling the plugin ABI oh_get_sensor_reading.
The plugins need not worry about other fields if the IsSupported is set
to 'False'.
I'm more inclined towards option 1.
Any suggestions, thoughts or other options?
Regards,
PG
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Openhpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openhpi-devel