[gnome-color-manager] cm: the eeprom address and size is a 32bit integer



commit 28acd35ad2bcdfd34aac8a1b819025e5d3db18ea
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jul 22 17:40:03 2010 +0100

    cm: the eeprom address and size is a 32bit integer

 libcolor-glib/gcm-buffer.c    |   64 +++++++++++++++++++++++++++++++++++++++++
 libcolor-glib/gcm-buffer.h    |    7 ++++
 tools/gcm-sensor-colormunki.c |    5 ++-
 3 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/libcolor-glib/gcm-buffer.c b/libcolor-glib/gcm-buffer.c
index 0b330c4..6a1d684 100644
--- a/libcolor-glib/gcm-buffer.c
+++ b/libcolor-glib/gcm-buffer.c
@@ -91,3 +91,67 @@ gcm_buffer_read_uint16_le (const guchar *buffer)
 {
 	return GUINT16_FROM_LE (*(guint16*)buffer);
 }
+
+/**
+ * gcm_buffer_write_uint32_be:
+ * @data: the writable data buffer
+ * @value: the value to write
+ *
+ * Writes a big endian value into a data buffer.
+ * NOTE: No validation is done on the buffer to ensure it's big enough.
+ **/
+void
+gcm_buffer_write_uint32_be (guchar *buffer, guint32 value)
+{
+	buffer[0] = (value >> 24) & 0xff;
+	buffer[1] = (value >> 16) & 0xff;
+	buffer[2] = (value >> 8) & 0xff;
+	buffer[3] = (value >> 0) & 0xff;
+}
+
+/**
+ * gcm_buffer_write_uint32_le:
+ * @data: the writable data buffer
+ * @value: the value to write
+ *
+ * Writes a little endian value into a data buffer.
+ * NOTE: No validation is done on the buffer to ensure it's big enough.
+ **/
+void
+gcm_buffer_write_uint32_le (guchar *buffer, guint32 value)
+{
+	buffer[0] = (value >> 0) & 0xff;
+	buffer[1] = (value >> 8) & 0xff;
+	buffer[2] = (value >> 16) & 0xff;
+	buffer[3] = (value >> 24) & 0xff;
+}
+
+/**
+ * gcm_buffer_read_uint32_be:
+ * @data: the writable data buffer
+ *
+ * Reads a big endian value from a data buffer.
+ * NOTE: No validation is done on the buffer to ensure it's valid.
+ *
+ * Return value: the value to read.
+ **/
+guint32
+gcm_buffer_read_uint32_be (const guchar *buffer)
+{
+	return GUINT32_FROM_BE (*(guint32*)buffer);
+}
+
+/**
+ * gcm_buffer_read_uint32_le:
+ * @data: the writable data buffer
+ *
+ * Reads a big endian value from a data buffer.
+ * NOTE: No validation is done on the buffer to ensure it's valid.
+ *
+ * Return value: the value to read.
+ **/
+guint32
+gcm_buffer_read_uint32_le (const guchar *buffer)
+{
+	return GUINT32_FROM_LE (*(guint32*)buffer);
+}
diff --git a/libcolor-glib/gcm-buffer.h b/libcolor-glib/gcm-buffer.h
index 3de670b..a1a1397 100644
--- a/libcolor-glib/gcm-buffer.h
+++ b/libcolor-glib/gcm-buffer.h
@@ -34,6 +34,13 @@ void		 gcm_buffer_write_uint16_be		(guchar			*buffer,
 							 guint16		 value);
 void		 gcm_buffer_write_uint16_le		(guchar			*buffer,
 							 guint16		 value);
+guint32		 gcm_buffer_read_uint32_be		(const guchar		*buffer);
+guint32		 gcm_buffer_read_uint32_le		(const guchar		*buffer);
+void		 gcm_buffer_write_uint32_be		(guchar			*buffer,
+							 guint32		 value);
+void		 gcm_buffer_write_uint32_le		(guchar			*buffer,
+							 guint32		 value);
+
 
 #undef __GCM_BUFFER_H_INSIDE__
 
diff --git a/tools/gcm-sensor-colormunki.c b/tools/gcm-sensor-colormunki.c
index 2ed6446..2e7fb45 100644
--- a/tools/gcm-sensor-colormunki.c
+++ b/tools/gcm-sensor-colormunki.c
@@ -301,8 +301,9 @@ gcm_sensor_colormunki_get_eeprom_data (GcmSensorColormunki *sensor_colormunki,
 	 * /         \ /         \
 	 * 04 00 00 00 04 00 00 00
 	 */
-	gcm_buffer_write_uint16_le (request, address);
-	gcm_buffer_write_uint16_le (request + 4, size);
+	egg_debug ("get EEPROM at 0x%04x for %i", address, size);
+	gcm_buffer_write_uint32_le (request, address);
+	gcm_buffer_write_uint32_le (request + 4, size);
 	gcm_sensor_colormunki_print_data ("request", request, 8);
 	handle = gcm_usb_get_device_handle (priv->usb);
 	retval = libusb_control_transfer (handle,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]