/*
* Check device by its physical USB bus/port address.
*/
- usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
+ if (usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)) < 0)
+ continue;
+
if (strcmp(sdi->connection_id, connection_id))
/* This is not the one. */
continue;
memset(cmdstring, 0, sizeof(cmdstring));
/* Command */
cmdstring[0] = CMD_2250_SET_TRIGGERSOURCE;
- sr_dbg("Trigger source %s.", devc->triggersource);
- if (!strcmp("CH2", devc->triggersource))
+ sr_dbg("Trigger source %s.", devc->triggersource ? : "<none>");
+ if (!devc->triggersource)
+ tmp = 0;
+ else if (!strcmp("CH2", devc->triggersource))
tmp = 3;
else if (!strcmp("CH1", devc->triggersource))
tmp = 2;
}
tmp = base / devc->samplerate;
- if (tmp) {
+ /* Downsample only if really necessary */
+ if (tmp > 1) {
/* Downsampling on */
cmdstring[2] |= 2;
/* Downsampler = 1comp((Base / Samplerate) - 2)
memset(cmdstring, 0, sizeof(cmdstring));
cmdstring[0] = CMD_2250_SET_TRIGGERPOS_AND_BUFFER;
- sr_dbg("Capture ratio: %d.", devc->capture_ratio);
+ sr_dbg("Capture ratio: %" PRIu64 ".", devc->capture_ratio);
trig = devc->capture_ratio;
dso2250_set_triggerpos(trig,
devc->framesize != FRAMESIZE_SMALL, cmdstring, 2);
cmdstring[0] = CMD_SET_TRIGGER_SAMPLERATE;
/* Trigger source */
- sr_dbg("Trigger source %s.", devc->triggersource);
- if (!strcmp("CH2", devc->triggersource))
+ sr_dbg("Trigger source %s.", devc->triggersource ? : "<none>");
+ if (!devc->triggersource)
+ tmp = 2;
+ else if (!strcmp("CH2", devc->triggersource))
tmp = 0;
else if (!strcmp("CH1", devc->triggersource))
tmp = 1;
cmdstring[5] = (tmp >> 8) & 0xff;
/* Horizontal trigger position */
- sr_dbg("Capture ratio: %d.", devc->capture_ratio);
+ sr_dbg("Capture ratio: %" PRIu64 ".", devc->capture_ratio);
tmp = 0x77fff + 0x8000 * devc->capture_ratio / 100;
cmdstring[6] = tmp & 0xff;
cmdstring[7] = (tmp >> 8) & 0xff;
if (devc->coupling[1] != COUPLING_AC)
relays[6] = ~relays[6];
- if (!strcmp(devc->triggersource, "EXT"))
+ if (devc->triggersource && strcmp(devc->triggersource, "EXT") == 0)
relays[7] = ~relays[7];
if (sr_log_loglevel_get() >= SR_LOG_DBG) {