Hi List,
The changes I've sent to Lukasz seem to work well for him and might be worth 
evaluating for inclusion in a future version of ipmitool to get a correct 
reading on non-linear analog sensors.

Best regards,
Holger Liebig

-----Original Message-----
From: Lukasz Michalski [mailto:[EMAIL PROTECTED]
Sent: Monday, May 19, 2008 8:32 PM
To: Liebig, Holger
Subject: Re: [Ipmitool-devel] FSC-1501 motherboard

On Monday 19 of May 2008 15:44:48 you wrote:
> > More or less. We do not have CVS Access from behind the corporate
> > firewall, so I took a snapshot some time ago at home. I can send you
> > a complete tarball if you need it.
> >
> >
> >
> > Let me know if it works for you.
>
> Correction: This is from an older version, based on 1.8.2.
> A quick hacked/merged version based on 1.8.9 is attached.
>
> Please let me know if it works for you.
>

Yes, it works perfectly! I have reading from CPU Fan and System Fan 3. They are 
replaced - CPU Fan is reported as System Fan 3 and System Fan 3 is reported as 
CPU Fan. I discovered it by disconnecting System Fan 3 for a while.

As far as I understand this is because BMC is reporting it like that and this 
is not a problem for me.

I attached your changes without commented code as a patch made against 1.8.9 
sources. Although I don't have any knowedge about IPMI standard and OpenIPMI 
API, from your changes I see that they are generic and this patch can be added 
to ipmitool?

Best Regards and thanks again for help,
Ɓukasz
diff -ur ipmitool-1.8.9/lib/ipmi_sensor.c ipmitool-1.8.9-patched/lib/ipmi_sensor.c
--- ipmitool-1.8.9/lib/ipmi_sensor.c	2007-02-22 09:38:57.000000000 +0100
+++ ipmitool-1.8.9-patched/lib/ipmi_sensor.c	2008-05-19 20:04:18.584540671 +0200
@@ -47,6 +47,57 @@
 #define READING_UNAVAILABLE	0x20
 
 static
+int
+ipmi_sensor_get_sensor_reading_factors(
+	struct ipmi_intf * intf, 
+	struct sdr_record_full_sensor * sensor, 
+	uint8_t reading)
+{
+	struct ipmi_rq req;
+	struct ipmi_rs * rsp;
+	uint8_t req_data[2];
+
+	char id[17];
+
+	if (intf == NULL || sensor == NULL)
+		return -1;
+
+	memset(id, 0, sizeof(id));
+	memcpy(id, sensor->id_string, 16);
+
+	req_data[0] = sensor->keys.sensor_num;
+	req_data[1] = reading;
+
+	memset(&req, 0, sizeof(req));
+	req.msg.netfn = IPMI_NETFN_SE;
+	req.msg.cmd   = GET_SENSOR_FACTORS;
+	req.msg.data  = req_data;
+	req.msg.data_len = sizeof(req_data);
+
+	rsp = intf->sendrecv(intf, &req);
+
+	if (rsp == NULL) {
+		lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)",
+			id, sensor->keys.sensor_num);
+		return -1;
+	} else if (rsp->ccode) {
+		return -1;
+	} else {
+		/* Update SDR copy with updated Reading Factors for this reading */
+		/* Note: 
+		 * The Format of the returned data is exactly as in the SDR definition (Little Endian Format), 
+		 * therefore we can use raw copy operation here. 
+		 * Note: rsp->data[0] would point to the next valid entry in the sampling table
+		 */
+		 // BUGBUG: uses 'hardcoded' length information from SDR Definition
+		memcpy(&sensor->mtol, &rsp->data[1], sizeof(sensor->mtol));
+		memcpy(&sensor->bacc, &rsp->data[3], sizeof(sensor->bacc));
+		return 0;
+	}
+
+}
+
+static
 struct ipmi_rs *
 ipmi_sensor_set_sensor_thresholds(struct ipmi_intf *intf,
 				  uint8_t sensor,
@@ -177,12 +228,6 @@
 	memset(id, 0, sizeof (id));
 	memcpy(id, sensor->id_string, 16);
 
-	/* only handle linear and linearized sensors (for now) */
-	if (sensor->linearization >= SDR_SENSOR_L_NONLINEAR) {
-		printf("sensor %s non-linear!\n", id);
-		return -1;
-	}
-
 	/*
 	 * Get current reading
 	 */
@@ -199,6 +244,15 @@
 	} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
 		validread = 0;
 	} else {
+
+		/* Non linear sensors might provide updated reading factors */
+		if (sensor->linearization>=SDR_SENSOR_L_NONLINEAR && sensor->linearization<=0x7F) {
+			if (ipmi_sensor_get_sensor_reading_factors(intf, sensor, rsp->data[0]) < 0){
+				printf("sensor %s non-linear!\n", id);
+				return -1;
+			}
+		}
+
 		/* convert RAW reading into units */
 		val = (rsp->data[0] > 0)
 		    ? sdr_convert_sensor_reading(sensor, rsp->data[0])

Attachment: signature.asc
Description: signature.asc

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to