From: Gareth McMullin Date: Sat, 19 Nov 2011 00:41:41 +0000 (+1300) Subject: Changed SR_T_NULL to SR_T_BOOL and adjusted RLE option. X-Git-Tag: libsigrok-0.1.0~226 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4d436e71ba6059b217a3d90775033e850944ad42;p=libsigrok.git Changed SR_T_NULL to SR_T_BOOL and adjusted RLE option. --- diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 35db8402..57881f83 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -618,7 +618,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) ret = SR_OK; break; case SR_HWCAP_RLE: - if (!strcmp(value, "on")) { + if (GPOINTER_TO_INT(value)) { sr_info("ols: enabling RLE"); ols->flag_reg |= FLAG_RLE; } diff --git a/hwplugin.c b/hwplugin.c index f3401dc7..43e6ef79 100644 --- a/hwplugin.c +++ b/hwplugin.c @@ -39,7 +39,7 @@ struct sr_hwcap_option sr_hwcap_options[] = { {SR_HWCAP_SAMPLERATE, SR_T_UINT64, "Sample rate", "samplerate"}, {SR_HWCAP_CAPTURE_RATIO, SR_T_UINT64, "Pre-trigger capture ratio", "captureratio"}, {SR_HWCAP_PATTERN_MODE, SR_T_CHAR, "Pattern generator mode", "patternmode"}, - {SR_HWCAP_RLE, SR_T_CHAR, "Run Length Encoding", "rle"}, + {SR_HWCAP_RLE, SR_T_BOOL, "Run Length Encoding", "rle"}, {0, 0, NULL, NULL}, }; @@ -115,7 +115,8 @@ int sr_init_hwplugins(struct sr_device_plugin *plugin) g_message("initializing %s plugin", plugin->name); num_devices = plugin->init(NULL); for (i = 0; i < num_devices; i++) { - num_probes = (int)plugin->get_device_info(i, SR_DI_NUM_PROBES); + num_probes = GPOINTER_TO_INT( + plugin->get_device_info(i, SR_DI_NUM_PROBES)); sr_device_new(plugin, i, num_probes); } diff --git a/sigrok-proto.h b/sigrok-proto.h index ee099ecc..9a9614c5 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -144,5 +144,6 @@ char **sr_parse_triggerstring(struct sr_device *device, const char *triggerstring); uint64_t sr_parse_sizestring(const char *sizestring); uint64_t sr_parse_timestring(const char *timestring); +gboolean sr_parse_boolstring(const char *boolstring); #endif diff --git a/sigrok.h.in b/sigrok.h.in index b3ca41ae..929b5c3f 100644 --- a/sigrok.h.in +++ b/sigrok.h.in @@ -81,7 +81,7 @@ typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data); enum { SR_T_UINT64, SR_T_CHAR, - SR_T_NULL, + SR_T_BOOL, }; #if 0 diff --git a/strutil.c b/strutil.c index 9bdf4336..380d78f5 100644 --- a/strutil.c +++ b/strutil.c @@ -267,3 +267,18 @@ uint64_t sr_parse_timestring(const char *timestring) return time_msec; } + +gboolean sr_parse_boolstring(const char *boolstr) +{ + if (!boolstr) + return FALSE; + + if (!g_strcasecmp(boolstr, "true") || + !g_strcasecmp(boolstr, "yes") || + !g_strcasecmp(boolstr, "on") || + !g_strcasecmp(boolstr, "1")) + return TRUE; + + return FALSE; +} +