[gnome-color-manager] trivial: improve the dump format
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: improve the dump format
- Date: Thu, 22 Jul 2010 12:15:37 +0000 (UTC)
commit 412e00a97f806ad977e5de6dd4a64f4afcd8b553
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 22 13:15:26 2010 +0100
trivial: improve the dump format
libcolor-glib/gcm-sensor-huey.c | 6 +++---
libcolor-glib/gcm-sensor.c | 10 +++++-----
libcolor-glib/gcm-sensor.h | 2 +-
tools/gcm-dump-sensor.c | 7 +++++--
tools/gcm-sensor-colormunki.c | 25 +++++++++++++++++++++++++
5 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/libcolor-glib/gcm-sensor-huey.c b/libcolor-glib/gcm-sensor-huey.c
index ba5fbde..63ede01 100644
--- a/libcolor-glib/gcm-sensor-huey.c
+++ b/libcolor-glib/gcm-sensor-huey.c
@@ -820,8 +820,8 @@ gcm_sensor_huey_dump (GcmSensor *sensor, GString *data, GError **error)
guint8 value;
/* dump the unlock string */
- g_string_append_printf (data, "huey dump version: %i\n", 1);
- g_string_append_printf (data, "unlock string: %s\n", priv->unlock_string);
+ g_string_append_printf (data, "huey-dump-version:%i\n", 1);
+ g_string_append_printf (data, "unlock-string:%s\n", priv->unlock_string);
/* read all the register space */
for (i=0; i<0xff; i++) {
@@ -829,7 +829,7 @@ gcm_sensor_huey_dump (GcmSensor *sensor, GString *data, GError **error)
if (!ret)
goto out;
/* write details */
- g_string_append_printf (data, "0x%02x: 0x%02x\n", i, value);
+ g_string_append_printf (data, "register[0x%02x]:0x%02x\n", i, value);
}
out:
return ret;
diff --git a/libcolor-glib/gcm-sensor.c b/libcolor-glib/gcm-sensor.c
index c32c887..c453106 100644
--- a/libcolor-glib/gcm-sensor.c
+++ b/libcolor-glib/gcm-sensor.c
@@ -404,11 +404,11 @@ gcm_sensor_dump (GcmSensor *sensor, GString *data, GError **error)
/* write common sensor details */
g_string_append (data, "// AUTOMATICALLY GENERATED -- DO NOT EDIT\n");
- g_string_append_printf (data, "generic dump version: %i\n", 1);
- g_string_append_printf (data, "kind: %s\n", gcm_sensor_kind_to_string (priv->kind));
- g_string_append_printf (data, "vendor: %s\n", priv->vendor);
- g_string_append_printf (data, "model: %s\n", priv->model);
- g_string_append_printf (data, "device: %s\n", priv->device);
+ g_string_append_printf (data, "generic-dump-version:%i\n", 1);
+ g_string_append_printf (data, "kind:%s\n", gcm_sensor_kind_to_string (priv->kind));
+ g_string_append_printf (data, "vendor:%s\n", priv->vendor);
+ g_string_append_printf (data, "model:%s\n", priv->model);
+ g_string_append_printf (data, "device:%s\n", priv->device);
/* dump sensor */
if (klass->dump == NULL) {
diff --git a/libcolor-glib/gcm-sensor.h b/libcolor-glib/gcm-sensor.h
index 4f84344..2a3c81e 100644
--- a/libcolor-glib/gcm-sensor.h
+++ b/libcolor-glib/gcm-sensor.h
@@ -155,7 +155,7 @@ gboolean gcm_sensor_supports_display (GcmSensor *sensor);
gboolean gcm_sensor_supports_projector (GcmSensor *sensor);
gboolean gcm_sensor_supports_printer (GcmSensor *sensor);
gboolean gcm_sensor_supports_spot (GcmSensor *sensor);
-gboolean gcm_sensor_is_native (GcmSensor *sensor);
+gboolean gcm_sensor_is_native (GcmSensor *sensor);
const gchar *gcm_sensor_kind_to_string (GcmSensorKind sensor_kind);
GcmSensorKind gcm_sensor_kind_from_string (const gchar *sensor_kind);
diff --git a/tools/gcm-dump-sensor.c b/tools/gcm-dump-sensor.c
index e5b28e3..202d211 100644
--- a/tools/gcm-dump-sensor.c
+++ b/tools/gcm-dump-sensor.c
@@ -39,6 +39,7 @@ main (int argc, char **argv)
GOptionContext *context;
GcmSensorClient *sensor_client;
GcmSensor *sensor;
+ gchar *filename = NULL;
setlocale (LC_ALL, "");
@@ -69,7 +70,8 @@ main (int argc, char **argv)
}
/* dump details */
- g_print ("Dumping sensor details... ");
+ filename = g_strdup_printf ("./%s-sensor-dump.txt", gcm_sensor_kind_to_string (gcm_sensor_get_kind (sensor)));
+ g_print ("Dumping sensor details to %s... ", filename);
data = g_string_new ("");
ret = gcm_sensor_dump (sensor, data, &error);
if (!ret) {
@@ -79,7 +81,7 @@ main (int argc, char **argv)
}
/* write to file */
- ret = g_file_set_contents ("./sensor-dump.txt", data->str, data->len, &error);
+ ret = g_file_set_contents (filename, data->str, data->len, &error);
if (!ret) {
g_print ("FAILED: Failed to write file: %s\n", error->message);
g_error_free (error);
@@ -89,6 +91,7 @@ main (int argc, char **argv)
/* success */
g_print ("SUCCESS!!\n");
out:
+ g_free (filename);
if (data != NULL)
g_string_free (data, TRUE);
g_object_unref (sensor_client);
diff --git a/tools/gcm-sensor-colormunki.c b/tools/gcm-sensor-colormunki.c
index 32cfa2d..da1003b 100644
--- a/tools/gcm-sensor-colormunki.c
+++ b/tools/gcm-sensor-colormunki.c
@@ -409,6 +409,30 @@ out:
return ret;
}
+
+/**
+ * gcm_sensor_huey_dump:
+ **/
+static gboolean
+gcm_sensor_colormunki_dump (GcmSensor *sensor, GString *data, GError **error)
+{
+ gboolean ret = TRUE;
+ GcmSensorColormunki *sensor_colormunki = GCM_SENSOR_COLORMUNKI (sensor);
+ GcmSensorColormunkiPrivate *priv = sensor_colormunki->priv;
+
+ /* dump the unlock string */
+ g_string_append_printf (data, "colormunki-dump-version: %i\n", 1);
+ g_string_append_printf (data, "chip-id:%s", priv->chip_id);
+ g_string_append_printf (data, "version:%s", priv->version_string);
+ g_string_append_printf (data, "firmware-revision:%s", priv->firmware_revision);
+ g_string_append_printf (data, "tick-duration:%i", priv->tick_duration);
+ g_string_append_printf (data, "min-int:%i", priv->min_int);
+ g_string_append_printf (data, "eeprom-blocks:%i", priv->eeprom_blocks);
+ g_string_append_printf (data, "eeprom-blocksize:%i", priv->eeprom_blocksize);
+//out:
+ return ret;
+}
+
/**
* gcm_sensor_colormunki_class_init:
**/
@@ -424,6 +448,7 @@ gcm_sensor_colormunki_class_init (GcmSensorColormunkiClass *klass)
// parent_class->set_leds = gcm_sensor_colormunki_set_leds;
// parent_class->sample = gcm_sensor_colormunki_sample;
parent_class->startup = gcm_sensor_colormunki_startup;
+ parent_class->dump = gcm_sensor_colormunki_dump;
g_type_class_add_private (klass, sizeof (GcmSensorColormunkiPrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]