static int received_anykey(int fd, int revents, void *cb_data)
{
struct sr_session *session;
+
(void)fd;
(void)revents;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-#include <string.h>
#include "sigrok-cli.h"
#include "config.h"
+#include <stdlib.h>
+#include <string.h>
#include <glib.h>
#ifdef HAVE_SRD
return channel_map;
}
-/* Register the given PDs for this session.
+/*
+ * Register the given PDs for this session.
* Accepts a string of the form: "spi:sck=3:sdata=4,spi:sck=3:sdata=5"
* That will instantiate two SPI decoders on the clock but different data
* lines.
channels = NULL;
}
- /* If no annotation list was specified, add them all in now.
+ /*
+ * If no annotation list was specified, add them all in now.
* This will be pared down later to leave only the last PD
* in the stack.
*/
if ((ret = srd_inst_stack(srd_sess, di_from, di_to)) != SRD_OK)
return 1;
- /* Don't show annotation from this PD. Only the last PD in
+ /*
+ * Don't show annotation from this PD. Only the last PD in
* the stack will be left on the annotation list (unless
* the annotation list was specifically provided).
*/
char **ann_descr;
gboolean show;
- /* 'cb_data' is not used in this specific callback. */
(void)cb_data;
if (!pd_ann_visible)
void show_pd_meta(struct srd_proto_data *pdata, void *cb_data)
{
-
- /* 'cb_data' is not used in this specific callback. */
(void)cb_data;
if (!g_hash_table_lookup_extended(pd_meta_visible,
gpointer classp;
int class;
- /* 'cb_data' is not used in this specific callback. */
(void)cb_data;
if (!g_hash_table_lookup_extended(pd_binary_visible,
fflush(stdout);
}
#endif
-
#include <string.h>
#include <glib.h>
-#define BUFSIZE 16384
+#define BUFSIZE (16 * 1024)
static void load_input_file_module(void)
{
sr_session_datafeed_callback_add(session, &datafeed_in, NULL);
got_sdi = FALSE;
- while(TRUE) {
+ while (TRUE) {
g_string_truncate(buf, 0);
len = read(fd, buf->str, BUFSIZE);
if (len < 0)
break;
sdi = sr_input_dev_inst_get(in);
- if(!got_sdi && sdi) {
+ if (!got_sdi && sdi) {
/* First time we got a valid sdi. */
if (select_channels(sdi) != SR_OK)
return;
}
got_sdi = TRUE;
}
-
}
sr_input_end(in);
sr_input_free(in);
gchar *opt_get = NULL;
gchar *opt_set = NULL;
-/* defines a callback function that generates
- an error if an option occurs twice */
+/*
+ * Defines a callback function that generates an error if an
+ * option occurs twice.
+ */
#define CHECK_ONCE(option) \
static gboolean check_ ## option \
(const gchar *option_name, const gchar *value, \
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
-/* Parses the command line and sets all the 'opt_...' variables.
- Returns zero on success, non-zero otherwise. */
+/*
+ * Parses the command line and sets all the 'opt_...' variables.
+ * Returns zero on success, non-zero otherwise.
+ */
int parse_options(int argc, char **argv)
{
GError *error = NULL;
break;
}
if (strchr(tokens[i], '-')) {
- /* A range of channels in the form a-b. This will only work
+ /*
+ * A range of channels in the form a-b. This will only work
* if the channels are named as numbers -- so every channel
* in the range must exist as a channel name string in the
- * device. */
+ * device.
+ */
range = g_strsplit(tokens[i], "-", 2);
if (!range[0] || !range[1] || range[2]) {
/* Need exactly two arguments. */
return TRUE;
}
-
if (!out || (out->len == 0
&& !opt_output_format
&& packet->type == SR_DF_ANALOG)) {
- /* The user didn't specify an output module,
- * but needs to see this analog data. */
+ /*
+ * The user didn't specify an output module,
+ * but needs to see this analog data.
+ */
sr_output_send(oa, packet, &out);
}
if (out && out->len > 0) {
}
}
- /* SR_DF_END needs to be handled after the output module's receive()
- * is called, so it can properly clean up that module. */
+ /*
+ * SR_DF_END needs to be handled after the output module's receive()
+ * is called, so it can properly clean up that module.
+ */
if (packet->type == SR_DF_END) {
g_debug("cli: Received SR_DF_END.");
}
if (maybe_config_list(driver, sdi, NULL, SR_CONF_LIMIT_SAMPLES,
&gvar) == SR_OK) {
- /* The device has no compression, or compression is turned
- * off, and publishes its sample memory size. */
+ /*
+ * The device has no compression, or compression is turned
+ * off, and publishes its sample memory size.
+ */
g_variant_get(gvar, "(tt)", &min_samples, &max_samples);
g_variant_unref(gvar);
if (limit_samples < min_samples) {
sr_session_destroy(session);
}
-
return;
}
- /* Selected channels and channel group may affect which options are
- * returned, or which values for them. */
+ /*
+ * Selected channels and channel group may affect which options are
+ * returned, or which values for them.
+ */
select_channels(sdi);
channel_group = select_channel_group(sdi);
&num_elements, sizeof(int32_t));
printf(" Supported triggers: ");
for (i = 0; i < num_elements; i++) {
- switch(int32[i]) {
+ switch (int32[i]) {
case SR_TRIGGER_ZERO:
c = '0';
break;
} else if (key == SR_CONF_LIMIT_SAMPLES
&& config_key_has_cap(driver, sdi, NULL, key, SR_CONF_LIST)) {
- /* If implemented in config_list(), this denotes the
+ /*
+ * If implemented in config_list(), this denotes the
* maximum number of samples a device can send. This
* really applies only to logic analyzers, and then
* only to those that don't support compression, or
* have it turned off by default. The values returned
- * are the low/high limits. */
+ * are the low/high limits.
+ */
if (sr_config_list(driver, sdi, channel_group, key,
&gvar) == SR_OK) {
g_variant_get(gvar, "(tt)", &low, &high);
#include <libsigrok/libsigrok.h>
#define DEFAULT_OUTPUT_FORMAT "bits:width=64"
-#define SAVE_CHUNK_SIZE 524288
+#define SAVE_CHUNK_SIZE (512 * 1024)
/* main.c */
int select_channels(struct sr_dev_inst *sdi);