This commit is contained in:
Abdelhak Bougouffa 2019-11-25 10:04:12 +01:00
commit ce11f8566a
13 changed files with 106 additions and 20 deletions

View File

@ -441,7 +441,7 @@ void MainWindow::update_device_list()
// USB device speed check
if (!selected_device->name().contains("virtual")) {
int usb_speed;
int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = selected_device->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);

View File

@ -375,6 +375,18 @@ QString StoreSession::meta_gen(boost::shared_ptr<data::Snapshot> snapshot)
fprintf(meta, "hDiv = %" PRIu64 "\n", tmp_u64);
g_variant_unref(gvar);
}
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MAX_TIMEBASE);
if (gvar != NULL) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
fprintf(meta, "hDiv max = %" PRIu64 "\n", tmp_u64);
g_variant_unref(gvar);
}
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE);
if (gvar != NULL) {
uint64_t tmp_u64 = g_variant_get_uint64(gvar);
fprintf(meta, "hDiv min = %" PRIu64 "\n", tmp_u64);
g_variant_unref(gvar);
}
gvar = _session.get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS);
if (gvar != NULL) {
uint8_t tmp_u8 = g_variant_get_byte(gvar);

View File

@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "samplingbar.h"
#include <extdef.h>
#include <assert.h>
#include <boost/foreach.hpp>
@ -30,7 +32,6 @@
#include <QAbstractItemView>
#include <QApplication>
#include "samplingbar.h"
#include "../devicemanager.h"
#include "../device/devinst.h"
#include "../dialogs/deviceoptions.h"
@ -156,7 +157,7 @@ void SamplingBar::retranslateUi()
else if (dev_inst->name().contains("virtual"))
_device_type.setText(tr("File"));
else {
int usb_speed;
int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);
@ -203,7 +204,7 @@ void SamplingBar::reStyle()
else if (dev_inst->name().contains("virtual"))
_device_type.setIcon(QIcon(":/icons/data.png"));
else {
int usb_speed;
int usb_speed = LIBUSB_SPEED_HIGH;
GVariant *gvar = dev_inst->get_config(NULL, NULL, SR_CONF_USB_SPEED);
if (gvar != NULL) {
usb_speed = g_variant_get_int32(gvar);
@ -521,6 +522,7 @@ void SamplingBar::update_sample_count_selector()
uint64_t sw_depth;
uint64_t rle_depth = 0;
uint64_t max_timebase = 0;
uint64_t min_timebase = SR_NS(10);
double pre_duration = SR_SEC(1);
double duration;
bool rle_support = false;
@ -574,6 +576,11 @@ void SamplingBar::update_sample_count_selector()
max_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
gvar = dev_inst->get_config(NULL, NULL, SR_CONF_MIN_TIMEBASE);
if (gvar != NULL) {
min_timebase = g_variant_get_uint64(gvar);
g_variant_unref(gvar);
}
}
if (0 != _sample_count.count())
@ -626,7 +633,7 @@ void SamplingBar::update_sample_count_selector()
unit == SR_MIN(1) ? SR_SEC(50) : duration * 0.5);
if (dev_inst->dev_inst()->mode == DSO)
not_last = duration >= SR_NS(10);
not_last = duration >= min_timebase;
else if (dev_inst->dev_inst()->mode == ANALOG)
not_last = (duration >= SR_MS(100)) &&
(duration / SR_SEC(1) * samplerate >= SR_KB(1));
@ -957,6 +964,11 @@ void SamplingBar::enable_toggle(bool enable)
_sample_count.setDisabled(true);
_sample_rate.setDisabled(true);
}
if (_session.get_device()->name() == "virtual-session") {
_sample_count.setDisabled(true);
_sample_rate.setDisabled(true);
}
}
void SamplingBar::enable_run_stop(bool enable)
@ -1005,6 +1017,7 @@ void SamplingBar::reload()
_instant_action->setVisible(true);
enable_toggle(true);
}
retranslateUi();
reStyle();
update();

View File

@ -23,6 +23,8 @@
#ifndef DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H
#define DSVIEW_PV_TOOLBARS_SAMPLINGBAR_H
#include "../sigsession.h"
#include <stdint.h>
#include <list>
#include <map>
@ -35,8 +37,6 @@
#include <QAction>
#include <QMenu>
#include "../sigsession.h"
struct st_dev_inst;
class QAction;
@ -67,7 +67,7 @@ private:
static const uint64_t AnalogMaxSWDepth = SR_Mn(100);
static const QString RLEString;
static const QString DIVString;
static const uint64_t ZeroTimeBase = SR_US(10);
static const uint64_t ZeroTimeBase = SR_US(2);
public:
SamplingBar(SigSession &session, QWidget *parent);

View File

@ -62,6 +62,7 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
Signal(dev_inst, probe),
_data(data),
_scale(0),
_stop_scale(1),
_en_lock(false),
_show(true),
_vDialActive(false),
@ -120,7 +121,7 @@ boost::shared_ptr<pv::data::Dso> DsoSignal::dso_data() const
void DsoSignal::set_scale(int height)
{
_scale = height / (_ref_max - _ref_min);
_scale = height / (_ref_max - _ref_min) * _stop_scale;
}
float DsoSignal::get_scale()
@ -216,8 +217,10 @@ bool DsoSignal::go_vDialPre(bool manul)
_vDial->set_sel(_vDial->get_sel() - 1);
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value()));
if (_view->session().get_capture_state() == SigSession::Stopped)
_scale *= pre_vdiv/_vDial->get_value();
if (_view->session().get_capture_state() == SigSession::Stopped) {
_stop_scale *= pre_vdiv/_vDial->get_value();
set_scale(get_view_rect().height());
}
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset));
@ -244,8 +247,10 @@ bool DsoSignal::go_vDialNext(bool manul)
_vDial->set_sel(_vDial->get_sel() + 1);
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value()));
if (_view->session().get_capture_state() == SigSession::Stopped)
_scale *= pre_vdiv/_vDial->get_value();
if (_view->session().get_capture_state() == SigSession::Stopped) {
_stop_scale *= pre_vdiv/_vDial->get_value();
set_scale(get_view_rect().height());
}
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
g_variant_new_uint16(_zero_offset));
@ -782,6 +787,8 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
assert(_view);
assert(right >= left);
if (_view->session().get_capture_state() == SigSession::Running)
_stop_scale = 1;
if (enabled()) {
const int index = get_index();

View File

@ -1248,6 +1248,11 @@ SR_PRIV int dsl_config_get(int id, GVariant **data, const struct sr_dev_inst *sd
channel_modes[devc->ch_mode].min_samplerate /
DS_CONF_DSO_HDIVS));
break;
case SR_CONF_MIN_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(SR_SEC(1) / channel_modes[devc->ch_mode].hw_max_samplerate);
break;
case SR_CONF_PROBE_COUPLING:
if (!ch)
return SR_ERR;

View File

@ -347,6 +347,11 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
return SR_ERR;
*data = g_variant_new_uint64(MAX_TIMEBASE);
break;
case SR_CONF_MIN_TIMEBASE:
if (!sdi)
return SR_ERR;
*data = g_variant_new_uint64(MIN_TIMEBASE);
break;
case SR_CONF_PROBE_COUPLING:
*data = g_variant_new_byte(ch->coupling);
break;

View File

@ -129,6 +129,7 @@ enum {
* Oscilloscope
*/
#define MAX_TIMEBASE SR_SEC(10)
#define MIN_TIMEBASE SR_NS(10)
extern char DS_RES_PATH[256];
@ -842,6 +843,7 @@ enum {
/** Time base. */
SR_CONF_MAX_TIMEBASE,
SR_CONF_MIN_TIMEBASE,
SR_CONF_TIMEBASE,
/** Filter. */

View File

@ -85,6 +85,8 @@ struct session_vdev {
int num_probes;
int enabled_probes;
uint64_t timebase;
uint64_t max_timebase;
uint64_t min_timebase;
uint8_t unit_bits;
uint32_t ref_min;
uint32_t ref_max;
@ -364,6 +366,8 @@ static int dev_open(struct sr_dev_inst *sdi)
vdev->unit_bits = 1;
vdev->ref_min = 0;
vdev->ref_max = 0;
vdev->max_timebase = MAX_TIMEBASE;
vdev->min_timebase = MIN_TIMEBASE;
vdev->max_height = 0;
vdev->mstatus.measure_valid = TRUE;
@ -431,9 +435,18 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
return SR_ERR;
break;
case SR_CONF_MAX_TIMEBASE:
if (!sdi)
if (sdi) {
vdev = sdi->priv;
*data = g_variant_new_uint64(vdev->max_timebase);
} else
return SR_ERR;
break;
case SR_CONF_MIN_TIMEBASE:
if (sdi) {
vdev = sdi->priv;
*data = g_variant_new_uint64(vdev->min_timebase);
} else
return SR_ERR;
*data = g_variant_new_uint64(MAX_TIMEBASE);
break;
case SR_CONF_UNIT_BITS:
if (sdi) {
@ -593,6 +606,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
vdev->timebase = g_variant_get_uint64(data);
sr_info("Setting timebase to %" PRIu64 ".", vdev->timebase);
break;
case SR_CONF_MAX_TIMEBASE:
vdev->max_timebase = g_variant_get_uint64(data);
sr_info("Setting max timebase to %" PRIu64 ".", vdev->max_timebase);
break;
case SR_CONF_MIN_TIMEBASE:
vdev->min_timebase = g_variant_get_uint64(data);
sr_info("Setting min timebase to %" PRIu64 ".", vdev->min_timebase);
break;
case SR_CONF_UNIT_BITS:
vdev->unit_bits = g_variant_get_byte(data);
sr_info("Setting unit bits to %d.", vdev->unit_bits);

View File

@ -220,6 +220,14 @@ SR_API int sr_session_load(const char *filename)
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_TIMEBASE,
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
} else if (!strcmp(keys[j], "hDiv min")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_MIN_TIMEBASE,
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
} else if (!strcmp(keys[j], "hDiv max")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_MAX_TIMEBASE,
g_variant_new_uint64(tmp_u64), sdi, NULL, NULL);
} else if (!strcmp(keys[j], "bits")) {
tmp_u64 = strtoull(val, NULL, 10);
sdi->driver->config_set(SR_CONF_UNIT_BITS,

View File

@ -699,6 +699,9 @@ SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, char **error)
/* none matched */
di->abs_cur_matched = FALSE;
/* skip zero flag */
di->skip_zero = FALSE;
/* Set self.samplenum to 0. */
PyObject_SetAttrString(di->py_inst, "samplenum", PyLong_FromLong(0));
@ -859,7 +862,7 @@ static void update_old_pins_array_initial_pins(struct srd_decoder_inst *di)
}
}
static gboolean term_matches(const struct srd_decoder_inst *di,
static gboolean term_matches(struct srd_decoder_inst *di,
struct srd_term *term, gboolean *skip_allow)
{
uint8_t old_sample, sample;
@ -869,8 +872,11 @@ static gboolean term_matches(const struct srd_decoder_inst *di,
/* Caller ensures di, di->dec_channelmap, term, sample_pos != NULL. */
*skip_allow = FALSE;
if (term->type == SRD_TERM_SKIP)
if (term->type == SRD_TERM_SKIP) {
if (di->abs_cur_matched && term->num_samples_to_skip == 0)
di->skip_zero = TRUE;
return sample_matches(0, 0, term);
}
ch = term->channel;
if (*(di->inbuf + ch) == NULL) {
@ -886,7 +892,7 @@ static gboolean term_matches(const struct srd_decoder_inst *di,
return sample_matches(old_sample, sample, term);
}
static gboolean all_terms_match(const struct srd_decoder_inst *di,
static gboolean all_terms_match(struct srd_decoder_inst *di,
const GSList *cond, gboolean *skip_allow)
{
const GSList *l;
@ -900,6 +906,10 @@ static gboolean all_terms_match(const struct srd_decoder_inst *di,
return FALSE;
}
if (di->skip_zero) {
di->abs_cur_samplenum--;
di->skip_zero = FALSE;
}
return TRUE;
}

View File

@ -309,6 +309,9 @@ struct srd_decoder_inst {
/** First entry of wait(). */
gboolean first_pos;
/** skip zero flag. */
gboolean skip_zero;
/** Indicates the current state of the decoder stack. */
int decoder_state;

View File

@ -685,7 +685,7 @@ static int create_term_list(PyObject *py_dict, GSList **term_list, gboolean cur_
term = g_malloc(sizeof(struct srd_term));
term->type = SRD_TERM_SKIP;
term->num_samples_to_skip = num_samples_to_skip;
term->num_samples_already_skipped = cur_matched ? 1 : 0;
term->num_samples_already_skipped = cur_matched ? (term->num_samples_to_skip != 0) : 0;
} else {
srd_err("Term key is neither a string nor a number.");
goto err;
@ -841,7 +841,7 @@ static int set_skip_condition(struct srd_decoder_inst *di, uint64_t count)
term = g_malloc(sizeof(*term));
term->type = SRD_TERM_SKIP;
term->num_samples_to_skip = count;
term->num_samples_already_skipped = di->abs_cur_matched ? 1 : 0;
term->num_samples_already_skipped = di->abs_cur_matched ? (term->num_samples_to_skip != 0) : 0;
term_list = g_slist_append(NULL, term);
di->condition_list = g_slist_append(di->condition_list, term_list);