Various key lists: Add reminders of what needs updates upon changes.

This commit is contained in:
Uwe Hermann 2015-08-28 16:26:07 +02:00
parent 55c9f09dbc
commit ca7dbb5616
5 changed files with 36 additions and 5 deletions

View File

@ -78,10 +78,7 @@ enum sr_error_code {
SR_ERR_DATA =-10, /**< Data is invalid. */ SR_ERR_DATA =-10, /**< Data is invalid. */
SR_ERR_IO =-11, /**< Input/output error. */ SR_ERR_IO =-11, /**< Input/output error. */
/* /* Update sr_strerror()/sr_strerror_name() (error.c) upon changes! */
* Note: When adding entries here, don't forget to also update the
* sr_strerror() and sr_strerror_name() functions in error.c.
*/
}; };
#define SR_MAX_CHANNELNAME_LEN 32 #define SR_MAX_CHANNELNAME_LEN 32
@ -150,6 +147,8 @@ enum sr_datatype {
SR_T_DOUBLE_RANGE, SR_T_DOUBLE_RANGE,
SR_T_INT32, SR_T_INT32,
SR_T_MQLIST, SR_T_MQLIST,
/* Update sr_variant_type_get() (hwdriver.c) upon changes! */
}; };
/** Value for sr_datafeed_packet.type. */ /** Value for sr_datafeed_packet.type. */
@ -172,6 +171,8 @@ enum sr_packettype {
SR_DF_FRAME_END, SR_DF_FRAME_END,
/** Payload is struct sr_datafeed_analog2. */ /** Payload is struct sr_datafeed_analog2. */
SR_DF_ANALOG2, SR_DF_ANALOG2,
/* Update datafeed_dump() (session.c) upon changes! */
}; };
/** Measured quantity, sr_datafeed_analog.mq. */ /** Measured quantity, sr_datafeed_analog.mq. */
@ -233,6 +234,8 @@ enum sr_mq {
SR_MQ_APPARENT_POWER, SR_MQ_APPARENT_POWER,
/** Mass */ /** Mass */
SR_MQ_MASS, SR_MQ_MASS,
/* Update sr_key_info_mq[] (hwdriver.c) upon changes! */
}; };
/** Unit of measured quantity, sr_datafeed_analog.unit. */ /** Unit of measured quantity, sr_datafeed_analog.unit. */
@ -322,6 +325,11 @@ enum sr_unit {
SR_UNIT_TOLA, SR_UNIT_TOLA,
/** Pieces (number of items). */ /** Pieces (number of items). */
SR_UNIT_PIECE, SR_UNIT_PIECE,
/*
* Update unit_strings[] (analog.c) and fancyprint() (output/analog.c)
* upon changes!
*/
}; };
/** Values for sr_datafeed_analog.flags. */ /** Values for sr_datafeed_analog.flags. */
@ -376,6 +384,11 @@ enum sr_mqflag {
SR_MQFLAG_REFERENCE = 0x80000, SR_MQFLAG_REFERENCE = 0x80000,
/** Unstable value (hasn't settled yet). */ /** Unstable value (hasn't settled yet). */
SR_MQFLAG_UNSTABLE = 0x100000, SR_MQFLAG_UNSTABLE = 0x100000,
/*
* Update mq_strings[] (analog.c) and fancyprint() (output/analog.c)
* upon changes!
*/
}; };
enum sr_trigger_matches { enum sr_trigger_matches {
@ -669,6 +682,8 @@ enum sr_configkey {
/** The device can act as a scale. */ /** The device can act as a scale. */
SR_CONF_SCALE, SR_CONF_SCALE,
/* Update sr_key_info_config[] (hwdriver.c) upon changes! */
/*--- Driver scan options -------------------------------------------*/ /*--- Driver scan options -------------------------------------------*/
/** /**
@ -712,6 +727,8 @@ enum sr_configkey {
*/ */
SR_CONF_MODBUSADDR, SR_CONF_MODBUSADDR,
/* Update sr_key_info_config[] (hwdriver.c) upon changes! */
/*--- Device (or channel group) configuration -----------------------*/ /*--- Device (or channel group) configuration -----------------------*/
/** The device supports setting its samplerate, in Hz. */ /** The device supports setting its samplerate, in Hz. */
@ -939,6 +956,8 @@ enum sr_configkey {
/** Over-temperature protection (OTP) active. */ /** Over-temperature protection (OTP) active. */
SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE, SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE,
/* Update sr_key_info_config[] (hwdriver.c) upon changes! */
/*--- Special stuff -------------------------------------------------*/ /*--- Special stuff -------------------------------------------------*/
/** Scan options supported by the driver. */ /** Scan options supported by the driver. */
@ -976,6 +995,8 @@ enum sr_configkey {
/** The device supports setting a probe factor. */ /** The device supports setting a probe factor. */
SR_CONF_PROBE_FACTOR, SR_CONF_PROBE_FACTOR,
/* Update sr_key_info_config[] (hwdriver.c) upon changes! */
/*--- Acquisition modes, sample limiting ----------------------------*/ /*--- Acquisition modes, sample limiting ----------------------------*/
/** /**
@ -1012,6 +1033,8 @@ enum sr_configkey {
/** Self test mode. */ /** Self test mode. */
SR_CONF_TEST_MODE, SR_CONF_TEST_MODE,
/* Update sr_key_info_config[] (hwdriver.c) upon changes! */
}; };
/** /**

View File

@ -47,6 +47,7 @@ struct unit_mq_string {
char *str; char *str;
}; };
/* Please use the same order as in enum sr_unit (libsigrok.h). */
static struct unit_mq_string unit_strings[] = { static struct unit_mq_string unit_strings[] = {
{ SR_UNIT_VOLT, "V" }, { SR_UNIT_VOLT, "V" },
{ SR_UNIT_AMPERE, "A" }, { SR_UNIT_AMPERE, "A" },
@ -88,6 +89,7 @@ static struct unit_mq_string unit_strings[] = {
ALL_ZERO ALL_ZERO
}; };
/* Please use the same order as in enum sr_mqflag (libsigrok.h). */
static struct unit_mq_string mq_strings[] = { static struct unit_mq_string mq_strings[] = {
{ SR_MQFLAG_AC, " AC" }, { SR_MQFLAG_AC, " AC" },
{ SR_MQFLAG_DC, " DC" }, { SR_MQFLAG_DC, " DC" },

View File

@ -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[] = { static struct sr_key_info sr_key_info_config[] = {
/* Device classes */ /* Device classes */
{SR_CONF_LOGIC_ANALYZER, SR_T_STRING, NULL, "Logic analyzer", NULL}, {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}, {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[] = { static struct sr_key_info sr_key_info_mq[] = {
{SR_MQ_VOLTAGE, 0, "voltage", "Voltage", NULL}, {SR_MQ_VOLTAGE, 0, "voltage", "Voltage", NULL},
{SR_MQ_CURRENT, 0, "current", "Current", NULL}, {SR_MQ_CURRENT, 0, "current", "Current", NULL},
@ -247,6 +248,7 @@ static struct sr_key_info sr_key_info_mq[] = {
ALL_ZERO ALL_ZERO
}; };
/* Please use the same order as in enum sr_mqflag (libsigrok.h). */
static struct sr_key_info sr_key_info_mqflag[] = { static struct sr_key_info sr_key_info_mqflag[] = {
{SR_MQFLAG_AC, 0, "ac", "AC", NULL}, {SR_MQFLAG_AC, 0, "ac", "AC", NULL},
{SR_MQFLAG_DC, 0, "dc", "DC", NULL}, {SR_MQFLAG_DC, 0, "dc", "DC", NULL},
@ -279,6 +281,7 @@ static struct sr_key_info sr_key_info_mqflag[] = {
ALL_ZERO ALL_ZERO
}; };
/* This must handle all the keys from enum sr_datatype (libsigrok.h). */
SR_PRIV const GVariantType *sr_variant_type_get(int datatype) SR_PRIV const GVariantType *sr_variant_type_get(int datatype)
{ {
switch (datatype) { switch (datatype) {

View File

@ -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) static void fancyprint(int unit, int mqflags, float value, GString *out)
{ {
switch (unit) { switch (unit) {
@ -241,6 +242,7 @@ static void fancyprint(int unit, int mqflags, float value, GString *out)
break; break;
} }
/* Please use the same order as in enum sr_mqflag (libsigrok.h). */
if (mqflags & SR_MQFLAG_AC) if (mqflags & SR_MQFLAG_AC)
g_string_append_printf(out, " AC"); g_string_append_printf(out, " AC");
if (mqflags & SR_MQFLAG_DC) if (mqflags & SR_MQFLAG_DC)

View File

@ -663,6 +663,7 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet)
const struct sr_datafeed_analog *analog; const struct sr_datafeed_analog *analog;
const struct sr_datafeed_analog2 *analog2; const struct sr_datafeed_analog2 *analog2;
/* Please use the same order as in libsigrok.h. */
switch (packet->type) { switch (packet->type) {
case SR_DF_HEADER: case SR_DF_HEADER:
sr_dbg("bus: Received SR_DF_HEADER packet."); sr_dbg("bus: Received SR_DF_HEADER packet.");