From: Shawn Walker Date: Mon, 2 Dec 2024 06:00:04 +0000 (-0700) Subject: raspberrypi-pico: Don't derive channel type from name X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a3726437c60fe220a8aa976c8b1b4ab9a2507fcb;p=libsigrok.git raspberrypi-pico: Don't derive channel type from name --- diff --git a/src/hardware/raspberrypi-pico/api.c b/src/hardware/raspberrypi-pico/api.c index 171b5eaa..72279254 100644 --- a/src/hardware/raspberrypi-pico/api.c +++ b/src/hardware/raspberrypi-pico/api.c @@ -487,24 +487,27 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) ch = l->data; sr_dbg("c %d enabled %d name %s\n", ch->index, ch->enabled, ch->name); - if (ch->name[0] == 'A') { + if (ch->type == SR_CHANNEL_ANALOG) { devc->a_chan_mask &= ~(1 << ch->index); if (ch->enabled) { devc->a_chan_mask |= (ch->enabled << ch->index); a_enabled++; } - } - if (ch->name[0] == 'D') { + sprintf(tmpstr, "A%d%d\n", ch->enabled, ch->index); + } else if (ch->type == SR_CHANNEL_LOGIC) { devc->d_chan_mask &= ~(1 << ch->index); if (ch->enabled) { devc->d_chan_mask |= (ch->enabled << ch->index); d_enabled++; } - } + sprintf(tmpstr, "D%d%d\n", ch->enabled, ch->index); + } else { + sr_err("ERROR: Channel enable encountered unknown type %d", ch->type); + return SR_ERR; + } sr_info("Channel enable masks D 0x%X A 0x%X", devc->d_chan_mask, devc->a_chan_mask); - sprintf(tmpstr, "%c%d%d\n", ch->name[0], ch->enabled, ch->index); if (send_serial_w_ack(serial, tmpstr) != SR_OK) { sr_err("ERROR: Channel enable fail"); return SR_ERR;