X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fopenbench-logic-sniffer%2Fapi.c;h=b99d8e72125545258214a1513389482ef5fa116c;hb=1e1dac0c0707f73a4c86e27cd02bb90515550354;hp=8284db1530765c1467b680de8fd7f3f3a530949a;hpb=56d0d24535700fb53e47a25ad5c73d34697695fa;p=libsigrok.git diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index 8284db15..b99d8e72 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -62,7 +62,7 @@ static const char *patterns[] = { }; /* Channels are numbered 0-31 (on the PCB silkscreen). */ -SR_PRIV const char *ols_channel_names[NUM_PROBES + 1] = { +SR_PRIV const char *ols_channel_names[NUM_CHANNELS + 1] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", @@ -177,7 +177,7 @@ static GSList *scan(GSList *options) "Sump", "Logic Analyzer", "v1.0"); sdi->driver = di; for (i = 0; i < 32; i++) { - if (!(ch = sr_channel_new(i, SR_PROBE_LOGIC, TRUE, + if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, ols_channel_names[i]))) return 0; sdi->channels = g_slist_append(sdi->channels, ch); @@ -323,10 +323,10 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, case SR_CONF_SWAP: if (g_variant_get_boolean(data)) { sr_info("Enabling channel swapping."); - devc->flag_reg |= FLAG_SWAP_PROBES; + devc->flag_reg |= FLAG_SWAP_CHANNELS; } else { sr_info("Disabling channel swapping."); - devc->flag_reg &= ~FLAG_SWAP_PROBES; + devc->flag_reg &= ~FLAG_SWAP_CHANNELS; } ret = SR_OK; break; @@ -399,6 +399,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, if (devc->channel_mask & (0xff << (i * 8))) num_channels++; } + if (num_channels == 0) { + /* This can happen, but shouldn't cause too much drama. + * However we can't continue because the code below would + * divide by zero. */ + break; + } grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES); grange[1] = g_variant_new_uint64(devc->max_samples / num_channels); *data = g_variant_new_tuple(grange, 2);