From: Uwe Hermann Date: Fri, 28 Aug 2015 14:26:07 +0000 (+0200) Subject: Various key lists: Add reminders of what needs updates upon changes. X-Git-Tag: libsigrok-0.4.0~377 X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=ca7dbb56161f9f4b7f842103fca59d41d559c793;hp=55c9f09dbc7edd24b0da8dda8837aff6a932e3c5;p=libsigrok.git Various key lists: Add reminders of what needs updates upon changes. --- diff --git a/include/libsigrok/libsigrok.h b/include/libsigrok/libsigrok.h index fd2be22e..19acee97 100644 --- a/include/libsigrok/libsigrok.h +++ b/include/libsigrok/libsigrok.h @@ -78,10 +78,7 @@ enum sr_error_code { SR_ERR_DATA =-10, /**< Data is invalid. */ SR_ERR_IO =-11, /**< Input/output error. */ - /* - * Note: When adding entries here, don't forget to also update the - * sr_strerror() and sr_strerror_name() functions in error.c. - */ + /* Update sr_strerror()/sr_strerror_name() (error.c) upon changes! */ }; #define SR_MAX_CHANNELNAME_LEN 32 @@ -150,6 +147,8 @@ enum sr_datatype { SR_T_DOUBLE_RANGE, SR_T_INT32, SR_T_MQLIST, + + /* Update sr_variant_type_get() (hwdriver.c) upon changes! */ }; /** Value for sr_datafeed_packet.type. */ @@ -172,6 +171,8 @@ enum sr_packettype { SR_DF_FRAME_END, /** Payload is struct sr_datafeed_analog2. */ SR_DF_ANALOG2, + + /* Update datafeed_dump() (session.c) upon changes! */ }; /** Measured quantity, sr_datafeed_analog.mq. */ @@ -233,6 +234,8 @@ enum sr_mq { SR_MQ_APPARENT_POWER, /** Mass */ SR_MQ_MASS, + + /* Update sr_key_info_mq[] (hwdriver.c) upon changes! */ }; /** Unit of measured quantity, sr_datafeed_analog.unit. */ @@ -322,6 +325,11 @@ enum sr_unit { SR_UNIT_TOLA, /** Pieces (number of items). */ SR_UNIT_PIECE, + + /* + * Update unit_strings[] (analog.c) and fancyprint() (output/analog.c) + * upon changes! + */ }; /** Values for sr_datafeed_analog.flags. */ @@ -376,6 +384,11 @@ enum sr_mqflag { SR_MQFLAG_REFERENCE = 0x80000, /** Unstable value (hasn't settled yet). */ SR_MQFLAG_UNSTABLE = 0x100000, + + /* + * Update mq_strings[] (analog.c) and fancyprint() (output/analog.c) + * upon changes! + */ }; enum sr_trigger_matches { @@ -669,6 +682,8 @@ enum sr_configkey { /** The device can act as a scale. */ SR_CONF_SCALE, + /* Update sr_key_info_config[] (hwdriver.c) upon changes! */ + /*--- Driver scan options -------------------------------------------*/ /** @@ -712,6 +727,8 @@ enum sr_configkey { */ SR_CONF_MODBUSADDR, + /* Update sr_key_info_config[] (hwdriver.c) upon changes! */ + /*--- Device (or channel group) configuration -----------------------*/ /** The device supports setting its samplerate, in Hz. */ @@ -939,6 +956,8 @@ enum sr_configkey { /** Over-temperature protection (OTP) active. */ SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE, + /* Update sr_key_info_config[] (hwdriver.c) upon changes! */ + /*--- Special stuff -------------------------------------------------*/ /** Scan options supported by the driver. */ @@ -976,6 +995,8 @@ enum sr_configkey { /** The device supports setting a probe factor. */ SR_CONF_PROBE_FACTOR, + /* Update sr_key_info_config[] (hwdriver.c) upon changes! */ + /*--- Acquisition modes, sample limiting ----------------------------*/ /** @@ -1012,6 +1033,8 @@ enum sr_configkey { /** Self test mode. */ SR_CONF_TEST_MODE, + + /* Update sr_key_info_config[] (hwdriver.c) upon changes! */ }; /** diff --git a/src/analog.c b/src/analog.c index 2116ad75..dfb38cec 100644 --- a/src/analog.c +++ b/src/analog.c @@ -47,6 +47,7 @@ struct unit_mq_string { char *str; }; +/* Please use the same order as in enum sr_unit (libsigrok.h). */ static struct unit_mq_string unit_strings[] = { { SR_UNIT_VOLT, "V" }, { SR_UNIT_AMPERE, "A" }, @@ -88,6 +89,7 @@ static struct unit_mq_string unit_strings[] = { ALL_ZERO }; +/* Please use the same order as in enum sr_mqflag (libsigrok.h). */ static struct unit_mq_string mq_strings[] = { { SR_MQFLAG_AC, " AC" }, { SR_MQFLAG_DC, " DC" }, diff --git a/src/hwdriver.c b/src/hwdriver.c index 99f3ee3f..811c7292 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -45,7 +45,7 @@ * @{ */ -/* Same key order/grouping as in enum sr_configkey (libsigrok.h). */ +/* Please use the same order/grouping as in enum sr_configkey (libsigrok.h). */ static struct sr_key_info sr_key_info_config[] = { /* Device classes */ {SR_CONF_LOGIC_ANALYZER, SR_T_STRING, NULL, "Logic analyzer", NULL}, @@ -211,6 +211,7 @@ static struct sr_key_info sr_key_info_config[] = { {0, 0, NULL, NULL, NULL}, }; +/* Please use the same order as in enum sr_mq (libsigrok.h). */ static struct sr_key_info sr_key_info_mq[] = { {SR_MQ_VOLTAGE, 0, "voltage", "Voltage", NULL}, {SR_MQ_CURRENT, 0, "current", "Current", NULL}, @@ -247,6 +248,7 @@ static struct sr_key_info sr_key_info_mq[] = { ALL_ZERO }; +/* Please use the same order as in enum sr_mqflag (libsigrok.h). */ static struct sr_key_info sr_key_info_mqflag[] = { {SR_MQFLAG_AC, 0, "ac", "AC", NULL}, {SR_MQFLAG_DC, 0, "dc", "DC", NULL}, @@ -279,6 +281,7 @@ static struct sr_key_info sr_key_info_mqflag[] = { ALL_ZERO }; +/* This must handle all the keys from enum sr_datatype (libsigrok.h). */ SR_PRIV const GVariantType *sr_variant_type_get(int datatype) { switch (datatype) { diff --git a/src/output/analog.c b/src/output/analog.c index 82e7ad9c..9d6f56a3 100644 --- a/src/output/analog.c +++ b/src/output/analog.c @@ -95,6 +95,7 @@ static void si_printf(float value, GString *out, char *unitstr) } +/* Please use the same order as in enum sr_unit (libsigrok.h). */ static void fancyprint(int unit, int mqflags, float value, GString *out) { switch (unit) { @@ -241,6 +242,7 @@ static void fancyprint(int unit, int mqflags, float value, GString *out) break; } + /* Please use the same order as in enum sr_mqflag (libsigrok.h). */ if (mqflags & SR_MQFLAG_AC) g_string_append_printf(out, " AC"); if (mqflags & SR_MQFLAG_DC) diff --git a/src/session.c b/src/session.c index 605ab2cc..158b33cf 100644 --- a/src/session.c +++ b/src/session.c @@ -663,6 +663,7 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet) const struct sr_datafeed_analog *analog; const struct sr_datafeed_analog2 *analog2; + /* Please use the same order as in libsigrok.h. */ switch (packet->type) { case SR_DF_HEADER: sr_dbg("bus: Received SR_DF_HEADER packet.");